SaveToPDFFile with Tabs and underlines

General TRichView support forum. Please post your questions here
Post Reply
medstar
Posts: 4
Joined: Fri Dec 16, 2011 10:23 am

SaveToPDFFile with Tabs and underlines

Post by medstar »

Hi!

We're using SaveToPDFFile from a RichView control:

Given this RTF Source Code (just one line with a tab character and the whole line is underlined; the second line has no underlinings)

{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\lang3079\ul\fs20 t\tab test\ulnone\par
nix\par
}

and issuing SaveToPDF, de resulting PDF file contains the underlined text as it should, but the underlined tab character is printed way off (it seems the paper margins are not calculated properly)

I am looking forward to any pointers into the right direction.

Stefan
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1. Make sure that you have the newest version of TRichView
2. Open RV_Defs.inc and remove the dot from the line
{$DEFINE RVUSEBASELINE}
Recompile your application.

If the steps below did not help, the problem is most probably in the PDF generation tool. Which one do you use (I forget what SaveToPDFFile is)?
medstar
Posts: 4
Joined: Fri Dec 16, 2011 10:23 am

Post by medstar »

Hi!

just read your replyafter finding a potential fix for that issue. The problem is, that in PtRVData.pas for painting nontext items, the page offset is not respected.

After DrawItemBorder, I introduced and changed the following lines

Code: Select all

GetRVStyle.GraphicInterface.GetWindowOrgEx(Canvas, WinOrg);
item.Print(Canvas, dli.ObjectLeft+LeftOffs-WinOrg.X, FItemTop-WinOrg.Y,0, Preview, Correction, sad, nil, dli, part, GetColorMode, Self);
The question is, if and where this code might be harmful...

I have to leave the office now, but I will check your suggestions tomorrow.

Thanks Sergey!
medstar
Posts: 4
Joined: Fri Dec 16, 2011 10:23 am

Post by medstar »

No, the advice didn't help.

I used the current trial version to compile this piece of code:

Code: Select all

uses RichView, RVEdit, RVStyle, trvpdf;
 (...)
with TRichViewEdit.Create(self) do
  begin
  Style := TRVStyle.Create(self);
  Top := 0;
  Left := 0;
  Width := 400;
  Height := 200;
  Parent := self;
  RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
  LoadRTF('C:\temp\tot1.rtf');

  With TRichViewPDF.Create(nil) do
    try
      AutoLaunch      := false;
      CreateOutLines  := true;
      SaveToPDFFile('C:\temp\tot1.rtf', 'C:\temp\tot1.pdf',50,50,50,50,'','');
    finally
      try
        Free;
      except
      end;
    end;
  end;
tot1.rtf is the RTF file posted yesterday.

The current version still draws the underlines wrong.

With our version (13.13.5 according to readme.txt), changing the compiler symbol doesn't have any effect).

Could you look into this, if my yesterday's suggestion breaks other things? (There should be a +1 with both WinOrg-coordinates)

Stefan

p.s.: If there are tables in an RTF, the borders are also way off. There's a workaround here, if you're interested - I'd have to create a diff, first.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I forget what is SaveToPDF. Which PDF components do you use?

Probably you use PDF generation tool that cannot handle window/viewport offsets correctly. In this case, I suggest to use another PDF components rather than compensate its problems in TRichView code.
Post Reply