Page 1 of 1

RTF to HTML conversion

Posted: Fri Oct 25, 2013 3:34 pm
by dmitrys
I am having problems converting HTML to RTF. I uploaded the problematic files (original HTML and the resulting RTF) to http://www.dimastr.com/temp/conversion_problem.zip.

The relevant snippet of code is below

RvHtmlImporter := TRvHtmlImporter2.Create(Msg);
RVReportHelper := TRVReportHelper.Create(nil);
canvas:= TCanvas.Create;
RVStyle:= TRVStyle.Create(nil);
try
canvas.Handle := GetWindowDC (GetDesktopWindow);
RVReportHelper.RichView.Style := RVStyle;
RVReportHelper.RichView.OnReadHyperlink := RvHtmlImporter.OnReadHyperlink;
RVReportHelper.RichView.OnWriteHyperlink := RvHtmlImporter.OnWriteHyperlink;
RVReportHelper.Init(canvas, Screen.Width);

//RvHtmlImporter.RichView := TempRichView;
RvHtmlImporter.RichView := RVReportHelper.RichView;
RvHtmlImporter.ClearDocument := false;
RvHtmlImporter.BasePath := '';
RvHtmlImporter.LoadHtml(Value);
Stream := TMemoryStream.Create;
try
RVReportHelper.RichView.SaveRTFToStream(Stream, false);
if Stream.Size > 0 then begin
Stream.Position := 0;
SetLength(Result, Stream.Size);
Stream.Read(Result[1], Length(Result));
end;
bRtfConverted := true;
finally
Stream.Free;
end;
finally
RvHtmlImporter.Free;
RVStyle.Free;
RVReportHelper.Free;
canvas.Free;
end;

Posted: Fri Oct 25, 2013 3:35 pm
by dmitrys
Looks like the link included an extra dot. The correct link is http://www.dimastr.com/temp/conversion_problem.zip .

Posted: Tue Oct 29, 2013 9:37 am
by Sergey Tkachenko
I uploaded a fixed version of rvHtmlImporter (table and cell background color reading is fixed).
However, I highly recommend to use rvHtmlViewImporter instead

Posted: Wed Oct 30, 2013 3:19 pm
by dmitrys
Sergey, where can I download the updated version from?

Thank you!

Posted: Wed Oct 30, 2013 7:11 pm
by dmitrys
Sergey,
I got the file from the private forum, thanks!
However I am using version 13.6.3, is it possible to fix the problem in that version?

Thank you!

Posted: Wed Oct 30, 2013 9:33 pm
by dmitrys
Never mind, I was able to merge the changes with my older version :-)

Thank you!