Hi,

I am trying work with fpPDF. I can create PDF document, but character out of ASCII range are displayed wrong (in PDF file they are stored as UTF8). Probably it is because I use standard Courier font, which is expecting only "Latin characters" ? I use:

FontIndex := PDF.AddFont('Courier'); // --> test1.pdf

When I want to use TTF font:

FontIndex := PDF.AddFont('cour.ttf','CourierNew');  // --> test2.pdf
(nothing else this line has changed)

I get strange PDF file (I can open it but content is wrong)

What I am doing wrong? Is there way how to get correct PDF with characters from Latin2 code page? Is there way how to get correct PDF file WITHOUT embedding full Courier font?

Thanks

-Laco.

Full source code is:

var
  PDF: TPDFDocument;
  FontIndex: integer;
begin
  PDF := TPDFDocument.Create(Self);
  PDF.Infos.Producer := '';
  PDF.Infos.CreationDate := Now;
  PDF.Options := [poPageOriginAtTop, {poNoEmbeddedFonts,} poSubsetFont, poCompressFonts, poCompressImages];
  PDF.DefaultOrientation := ppoPortrait;
  PDF.DefaultPaperType := ptA4;
  PDF.DefaultUnitOfMeasure := uomMillimeters;
  PDF.FontDirectory := 'C:\WINDOWS\FONTS';
  PDF.StartDocument;
  PDF.Sections.AddSection;
  PDF.Sections[0].AddPage(PDF.Pages.AddPage);;

  //FontIndex := PDF.AddFont('Courier');
  FontIndex := PDF.AddFont('cour.ttf', 'CourierNew');
  PDF.Pages[0].SetFont(FontIndex, 10);
  PDF.Pages[0].WriteText(10,10,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
  PDF.Pages[0].WriteText(10,15,'----------------');
  PDF.Pages[0].WriteText(10,20,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');

  PDF.SaveToFile('test.pdf');
end;

Attachment: test1.pdf
Description: Adobe PDF document

Attachment: test2.pdf
Description: Adobe PDF document

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to