RTF to HTML conversion

General TRichView support forum. Please post your questions here
Post Reply
dmitrys
Posts: 10
Joined: Fri Aug 09, 2013 6:31 am

RTF to HTML conversion

Post 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;
dmitrys
Posts: 10
Joined: Fri Aug 09, 2013 6:31 am

Post by dmitrys »

Looks like the link included an extra dot. The correct link is http://www.dimastr.com/temp/conversion_problem.zip .
Sergey Tkachenko
Site Admin
Posts: 17306
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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
dmitrys
Posts: 10
Joined: Fri Aug 09, 2013 6:31 am

Post by dmitrys »

Sergey, where can I download the updated version from?

Thank you!
dmitrys
Posts: 10
Joined: Fri Aug 09, 2013 6:31 am

Post 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!
dmitrys
Posts: 10
Joined: Fri Aug 09, 2013 6:31 am

Post by dmitrys »

Never mind, I was able to merge the changes with my older version :-)

Thank you!
Post Reply