Page 1 of 1

[Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Wed Aug 26, 2020 3:56 pm
by Sergey Tkachenko
With TRichView, converting RTF to DocX is simple:

Code: Select all

rv.Clear;
rv.LoadRTF(InputFileName);
rv.Format; // necessary if the document contains tables
rv.SaveDocX(OutputFileName, False);
Some property settings are needed to specify loading and saving page information (page size, margins, etc.) and document properties (author, title, etc.)

However, TRichView can store only the main document, without headers and footers. So headers and footers will be lost on conversion.
There are several solutions for this problem.
1. Using TSRichViewEdit from ScaleRichView. ScaleRichView editor can contain both the main document and headers/footers in a single component, so it can load and save them.
2. Create separate TRichView, TRichViewEdit, or TRVReportHelper components for each header and footer. This approach is used in the demo <TRichView Dir>\TRichView\Demos\DelphiUnicode\Assorted\Printing\Headers\
(or identical projects for C++Builder and Lazarus).
This demo projects uses TRichViewEdit for the main document, and for 6 headers and footers.
3. Using TRVReportHelperWithHeaderFooters.
This approach is used in the attached demo.
This project converts RTF to DocX. But with minor modifications, it can convert any of {RTF, RVF} to {RTF, DocX, RVF}.

Re: [Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Thu Aug 27, 2020 9:59 pm
by jgkoehn
Greetings Sergey,
I would be interested in how to bring in the DocX do I need a special component?

Re: [Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Fri Aug 28, 2020 10:43 am
by Sergey Tkachenko
Sorry, I do not understand the question.

Re: [Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Fri Aug 28, 2020 8:26 pm
by jgkoehn
But with minor modifications, it can convert DocX to RTF,
Does this mean that DocX import is available? If so how does one do it?

Re: [Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Sat Aug 29, 2020 11:14 am
by Sergey Tkachenko
DocX import is not yet available (I corrected the text).
It is in development, you can expect it in this autumn.

Re: [Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Thu Dec 10, 2020 10:43 pm
by jgkoehn
No pressure just checking on the Docx progress. Any news? Thanks sir!

Re: [Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Fri Dec 11, 2020 7:27 am
by Sergey Tkachenko
It will be released in this month.

Re: [Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Sat Oct 16, 2021 9:32 am
by Zevine
Does this mean that DocX import is available? If so how does one do it?

Re: [Demo] Convert RTF to DocX (keeping headers and page information)

Posted: Sat Oct 16, 2021 11:48 am
by Sergey Tkachenko
Yes, DocX import is available (for Delphi 2009 and newer). There are LoadDocX and LoadDocXFromStream methods.
Details are here: https://www.trichview.com/forums/viewto ... 885#p38885