Extra Paragraphs, just load / save rtf to rtf/docx?

General TRichView support forum. Please post your questions here
Sergey Tkachenko
Site Admin
Posts: 17553
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Extra Paragraphs, just load / save rtf to rtf/docx?

Post by Sergey Tkachenko »

It looks like the problem is in saving tables that have table.BestWidth = 0 (i.e. table width must be calculated from widths of cells).
Widths of cells and borders are saved correctly.

By default, for auto-width tables, the component saves a table width equal to the width of this table in TRichView window, and it may be not exactly precise.
To save such tables as auto-width tables in RTF, assign the global variable from RVTable.pas.

Code: Select all

RichViewTableDefaultRTFAutofit := True
In order to make this variable work for DocX as well, change in RVTable.pas function GetTableWidthStr.
The part "if BestWidth = 0 then" must be:

Code: Select all

  function GetTableWidthStr: TRVAnsiString;
  begin
    if BestWidth = 0 then
    begin
      if RichViewTableDefaultRTFAutofit or (rvtoRTFAllowAutofit in Options) then
        Result := '<w:tblW w:w="0" w:type="auto"/>'
      else
        Result := RVFormatA('<w:tblW w:w="%d" w:type="dxa"/>',
          [RV_UnitsToTwips(GetWidth(ARVStyle, GetPixelsPerInch, 1), rvuPixels, GetPixelsPerInch)])
    end
This change will be included in the next update.
a.weber
Posts: 63
Joined: Wed Mar 02, 2022 7:02 am

Re: Extra Paragraphs, just load / save rtf to rtf/docx?

Post by a.weber »

Hello Sergey,
I have tried to the the global variable and changed the code location you showed. This gives another result, but still wrong and different between rtf /docx after loading again in Word. Do I miss something, there are other properties which influence this behavior?
Unbenannt-1.png
Unbenannt-1.png (139.48 KiB) Viewed 5708 times
Do you need more informations - to find a solution for this issue?

André
Sergey Tkachenko
Site Admin
Posts: 17553
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Extra Paragraphs, just load / save rtf to rtf/docx?

Post by Sergey Tkachenko »

Well, it looks lile this is the reason why this option is not enabled by default.
I'll see what I can do.
Probably, I can save auto-width option only for the table, not for cells.
Post Reply