How to convert RichText (RTF) document with images in HTML in Delphi?

I am trying to find a free (preferably open source) component or library that will convert an RTF file with embedded images into HTML files and image files or improve the flow of HTML and images.

The ideal solution, whether it is a DLL or a Delphi component, will allow you to transfer data to IStream / TStream using callbacks, so I can convert and save the images in the selection format, returning the relative image file name for the RTF analyzer to include in generated HTML file, however saving as-is is also good, especially if the code is open.

I came across commercial solutions, but I can’t consider them, because the prices for the (relatively) simple conversion of one type of document to another are quite high, and both formats are 20 years old, which suggests the existence of an existing library (native, failed) to do this conversion.

If I don’t find a solution, I will probably convert this code to a Delphi dll and make it available, but maybe someone has already done this?

EDIT:

We decided to use the aforementioned .Net RtfConverter compiled as a DLL, generate the Delphi TLB module and force the clients to install the .Net framework (built into the installer). Now the conversion works like a charm, another sign to go to .Net from Delphi ...

+3
source share
3

Microsoft Office RTF, HTML , , , Microsoft Word OLE, RTF HTML...

+3

RTF HTML 4.01/HTML5 RTF XHTML ScroogeXHTML Delphi. 5.0 , WMF PNG. ( Java).

+3

P.S: .

.Net RTF HTML 3.2, 4.01, XHTML 1.01 HTML 5.

supports conversion with tables and nested tables, ordered and bulleted lists, images embedded in HTML, Unicode, special HTML characters, etc.

This is a sample C # code:

        SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
        r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
        r.ImageStyle.IncludeImageInHtml = true;
        r.ConvertFile(@"d:\document.rtf",@"d:\html5.htm");
-1
source

Source: https://habr.com/ru/post/1784921/


All Articles