I need my rv content to be save into non css html. But for those which can only be achieved by using css style like text highlight, an inline css style will be added.
e.g:
font style="background-color: #99ccff" highlighted text</font>
If there is no direct solution, do you have any suggestion for this ?
Save HTML
-
- Posts: 57
- Joined: Wed Aug 31, 2005 6:46 pm
Re: Save HTML
cychia wrote:I need my rv content to be save into non css html.
SaveHTMLEx exports contents of RichView to HTML file, using CSS.
SaveHTML exports contents of RichView to HTML file, using HTML tags like <FONT>, <B>, <DIV>, etc.
I am sorry for not giving a clear question.
I totally understand the usage of these two functions, SaveHTML and SaveHTMLEx.
My question is I would like to save rv as non css html (so i will call SaveHTML), but then since some of the function provided in the editor like text highlighting does not supported by non css html. Therefore, i need this particular style only to be exported as inline css for my html.
I've tried to search around for possible ways that rv could provide, but I failed to find one.
There is an event in rv named "OnSaveParaToHTML"
TRVSaveParaToHTMLEvent =
procedure (Sender: TCustomRichView;
RVData: TCustomRVData; ItemNo: Integer;
ParaStart, CSSVersion: Boolean;
var HTMLCode: String) of object;
but it is not suitable for my purpose because i need to write the style to tag like <font>
"<font style="background-color: #99ccff"> highlighted text</font> "
Therefore, I would like to ask:
1. if it is possible for rv to achieve this need?
2. if not possible, any other suggestions or workaround?
3. is there any event like OnSaveItemStyleToHTML, in which the ItemNo is provided, so that i can add extra html code to the tag as mentioned above?
I totally understand the usage of these two functions, SaveHTML and SaveHTMLEx.
My question is I would like to save rv as non css html (so i will call SaveHTML), but then since some of the function provided in the editor like text highlighting does not supported by non css html. Therefore, i need this particular style only to be exported as inline css for my html.
I've tried to search around for possible ways that rv could provide, but I failed to find one.
There is an event in rv named "OnSaveParaToHTML"
TRVSaveParaToHTMLEvent =
procedure (Sender: TCustomRichView;
RVData: TCustomRVData; ItemNo: Integer;
ParaStart, CSSVersion: Boolean;
var HTMLCode: String) of object;
but it is not suitable for my purpose because i need to write the style to tag like <font>
"<font style="background-color: #99ccff"> highlighted text</font> "
Therefore, I would like to ask:
1. if it is possible for rv to achieve this need?
2. if not possible, any other suggestions or workaround?
3. is there any event like OnSaveItemStyleToHTML, in which the ItemNo is provided, so that i can add extra html code to the tag as mentioned above?
-
- Posts: 57
- Joined: Wed Aug 31, 2005 6:46 pm
I am not able to test it, but please try it (OnSaveItemToFile event), something like this:
if (SaveFormat = rvsfHTML) and (RVData.GetItemStyle(ItemNo) >= 0) and
(Trim(RVData.GetItemText(ItemNo)) <> '') then begin
ItemStyle := RVData.GetItemStyle(ItemNo);
Style := rvs.TextStyles[ItemStyle];
(analyse the style and change OutStr)
DoDefault := False;
end;
if (SaveFormat = rvsfHTML) and (RVData.GetItemStyle(ItemNo) >= 0) and
(Trim(RVData.GetItemText(ItemNo)) <> '') then begin
ItemStyle := RVData.GetItemStyle(ItemNo);
Style := rvs.TextStyles[ItemStyle];
(analyse the style and change OutStr)
DoDefault := False;
end;
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I have tried out the event you have mentioned, it seems like working. So I would like to confirm with you something before I can 100% sure it is worked.
Below is my code:
if ((SaveFormat in [rvsfHTML]) and (RVData.GetItemStyle(ItemNo) >= 0)) then
begin
if Sender.Style.TextStyles[RVData.GetItemStyle(ItemNo)].BackColor <> clNone then
begin
OutStr := Format('<font style="background-color: %s">%s</font>',
[ColorToHex(Sender.Style.TextStyles[RVData.GetItemStyle(ItemNo)].BackColor),
OutStr]);
DoDefault := False;
end;
end;
In my application when I will only call SaveHTML with rvsoUTF8 is add into SaveOptions. From the code above, do i need to do any conversion to make sure the output is in utf8?
Below is my code:
if ((SaveFormat in [rvsfHTML]) and (RVData.GetItemStyle(ItemNo) >= 0)) then
begin
if Sender.Style.TextStyles[RVData.GetItemStyle(ItemNo)].BackColor <> clNone then
begin
OutStr := Format('<font style="background-color: %s">%s</font>',
[ColorToHex(Sender.Style.TextStyles[RVData.GetItemStyle(ItemNo)].BackColor),
OutStr]);
DoDefault := False;
end;
end;
In my application when I will only call SaveHTML with rvsoUTF8 is add into SaveOptions. From the code above, do i need to do any conversion to make sure the output is in utf8?
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Code: Select all
var s1, s2: String;
if ((SaveFormat in [rvsfHTML]) and (RVData.GetItemStyle(ItemNo) >= 0)) then
begin
if Sender.Style.TextStyles[RVData.GetItemStyle(ItemNo)].BackColor <> clNone then
begin
s1 := Format('<font style="background-color: %s">', [ColorToHex(Sender.Style.TextStyles[RVData.GetItemStyle(ItemNo)].BackColor)]);
s2 := </font>;
if Unicode then
begin
s1 := RVU_GetRawUnicode(s1);
s2 := RVU_GetRawUnicode(s2);
end;
OutStr := s1+OutStr+s2;
DoDefault := False;
end;
end;