#1 2014-02-11 11:29:00

piotr.brzezinski
Member
From: Kielce, Poland
Registered: 2014-02-11
Posts: 3

Additional chars in PDF

I'm using PDF Engine from the end of 2012 (SynPdf.pas is from 28-nov-2012)

Here is code:

procedure TForm1.Button1Click(Sender: TObject);
var
  lPdf: TPdfDocument;
  lPage: TPdfPage;
  n: Integer;
  s: String;
begin
  lPdf := TPdfDocument.Create;
  try
    lPdf.Info.CreationDate := Now;
    lPdf.Info.Creator := 'SynPDF';
    lPdf.DefaultPaperSize := psA4;

    lPage := lPdf.AddPage;

    lPdf.Canvas.SetFont('Consolas', 9.0, [], EASTEUROPE_CHARSET);
    lPdf.Canvas.SetLeading(lPdf.Canvas.Page.FontSize);
    lPdf.Canvas.BeginText;

    s := 'abcdefghijklmnopqrstuvwxyz';

    for n := 2 to 33 do
    begin
      lPdf.Canvas.TextOut(100, lPage.PageHeight - n * 20, 'ĄĘŚĆŃÓŁŻŹ ' + s);
      lPdf.Canvas.TextOut(100, lPage.PageHeight - n * 20 - 10, 'ąęśćńółżź');
    end;

    lPdf.Canvas.EndText;
    lPdf.SaveToFile('TEST.PDF');

  finally
    lPdf.Free;
  end;
end;

It generate nice PDF :-)
ok.png

But when I change PDF engine to new one there are an extra characters in generated PDF and after few lines font is change to Arial.
bug.png

I'm using Delphi 7.

Offline

#2 2014-02-11 16:11:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Additional chars in PDF

Which charset are you using?

Offline

#3 2014-02-12 07:33:41

piotr.brzezinski
Member
From: Kielce, Poland
Registered: 2014-02-11
Posts: 3

Re: Additional chars in PDF

ab wrote:

Which charset are you using?

CharSet = 238 (EastEurope), CodePage = 1250

Offline

#4 2014-02-12 19:27:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Additional chars in PDF

Could you try TextOutW() instead, and a conversion to unicode?

What if you use a temporary metafile (e.g. TPdfDocumentGDI) before rendering?

What if you set UseFontFallBack=false and/or UseUniscribe=false/true?

Offline

#5 2014-02-13 10:08:44

piotr.brzezinski
Member
From: Kielce, Poland
Registered: 2014-02-11
Posts: 3

Re: Additional chars in PDF

ab wrote:

Could you try TextOutW() instead, and a conversion to unicode?

What if you use a temporary metafile (e.g. TPdfDocumentGDI) before rendering?

What if you set UseFontFallBack=false and/or UseUniscribe=false/true?

First solution works (TextOutW and conversion to unicode). Thank You.

Offline

Board footer

Powered by FluxBB