LeftIndent and LoadHtml issue

General TRichView support forum. Please post your questions here
Post Reply
box712
Posts: 4
Joined: Thu Apr 23, 2009 6:32 pm

LeftIndent and LoadHtml issue

Post by box712 »

Hi all,
I ‘m trying to save HTM to stream and load the same HTML from stream.
To save data I’m using SaveHTMLToStreamEx , to load -TRvHtmlImporter.LoadHtml.
LeftIndent disappeared.
When I save this HTML to file and load it with IE, Indent works fine.

Is it possible to have this working (may be some other way)?
Thank you.

There are simple test example:
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
vStream: TMemoryStream;
s: TRVRawByteString;
begin
vStream := TMemoryStream.Create;
try
RichViewEdit1.Clear;
RichViewEdit1.Add('Test Line', 0);
RVStyle1.ParaStyles[0].LeftIndent := 40;
RVStyle1.ParaStyles[0].Standard := False;
RichViewEdit1.Format;

RichViewEdit1.SaveHTMLToStreamEx(vStream, '', '', '', '', '', '', [rvsoInlineCSS, rvsoMiddleOnly]);
// RichViewEdit1.SaveHTMLToStreamEx(vStream, '', '', '', '', '', '', []);
vStream.Position := 0;
SetLength(s, vStream.Size);
vStream.ReadBuffer(PRVAnsiChar(s)^, Length(s));
RvHtmlImporter1.LoadHtml(s);
RichViewEdit1.Format;
finally
vStream.Free;
end;
end;
box712
Posts: 4
Joined: Thu Apr 23, 2009 6:32 pm

Just to have code more readable

Post by box712 »

Just to have code more readable

Code: Select all

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  vStream: TMemoryStream;
  s: TRVRawByteString;
begin
  vStream := TMemoryStream.Create;
  try
    // init some data with Left Indent = 40 first
    RichViewEdit1.Clear;
    RichViewEdit1.Add('Test Line', 0);
    RVStyle1.ParaStyles[0].LeftIndent := 40;
    RVStyle1.ParaStyles[0].Standard := False;
    RichViewEdit1.Format;

    // save HTML to stream
    RichViewEdit1.SaveHTMLToStreamEx(vStream, '', '', '', '', '', '', [rvsoInlineCSS, rvsoMiddleOnly]);
    // RichViewEdit1.SaveHTMLToStreamEx(vStream, '', '', '', '', '', '', []); 

    // load HTML from stream
    vStream.Position := 0;
    SetLength(s, vStream.Size);
    vStream.ReadBuffer(PRVAnsiChar(s)^, Length(s));
    RvHtmlImporter1.LoadHtml(s);
    RichViewEdit1.Format;
  finally
    vStream.Free;
  end;
end;
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This is a bug in the RvHtmlImporter. A fixed version is uploaded in http://www.trichview.com/resources/html ... import.zip

PS: for better results, I recommend using rvHtmlViewImporter instead of RvHtmlImporter, you can find it on http://www.trichview.com/resources/
box712
Posts: 4
Joined: Thu Apr 23, 2009 6:32 pm

Still not working

Post by box712 »

Unfortunately RvHtmlImporter.LoadHtml still not working. Left Indent (Bold, Italik Font styles as well) are ignored by the HtmlImporter
There is an example of HTML which I have

Code: Select all

<p style=" text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 20px;"><span style=" font-size: 10pt; font-family: 'Arial', 'Helvetica', sans-serif; font-style: normal; font-weight: bold; color: #000000; background-color: transparent; text-decoration: none;">Test Line</span></p>
I was also not able to install RvHtmlImporter component (I have D2007).
Files "Htmlsubs.pas" and "HTMLUn2.pas" form Step 2 of the Installation Guide are not included in any RichView projects. Step 4 is not clear - what does it mean "Install HTML Viewer Components"?
Eventually I have an Error "[DCC Error] rvHtmlViewImportD2007.dpk(32): E2202 Required package 'FrameViewer2007' not found"
Thank you
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

RvHtmlImporter does not understand CSS. The only exception is CSS saved using SaveHTMLEx method without rvsoInlineCSS option.

RvHtmlViewImporter imports HTML from THTMLViewer. It must be installed before, download it from http://www.pbear.com
It is freeware with source code.
HTML must be loaded in THTMLViewer, then imported in TRichView using TRvHtmlViewImporter.
box712
Posts: 4
Joined: Thu Apr 23, 2009 6:32 pm

Post by box712 »

Thanks a lot,
SaveHTMLEx method without rvsoInlineCSS option
working fine.

Also I was able to install HtmlViewImporter and it works in both cases - with and without rvsoInlineCSS option.

Looks like the Issue is resolved.
Thanks again.
Post Reply