[fpc-pascal] fpPDF and support of Latin2 charset
LacaK
lacak at zoznam.sk
Tue Mar 19 09:46:45 CET 2019
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.pdf
Type: application/pdf
Size: 1208 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190319/b406ba1d/attachment.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.pdf
Type: application/pdf
Size: 18030 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190319/b406ba1d/attachment-0001.pdf>
More information about the fpc-pascal
mailing list