Page 2 of 2

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

Posted: Mon Nov 07, 2022 6:01 pm
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.

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

Posted: Thu Nov 10, 2022 10:29 am
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 5651 times
Do you need more informations - to find a solution for this issue?

André

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

Posted: Thu Nov 10, 2022 11:20 am
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.