Hi,
if I understand the documentation
(https://partners.adobe.com/public/developer/en/pdf/PDFReference13.pdf) right, it should be possible to contain in the Latin Character Set in a PDF, also with fpPDF (which uses WinAnsiEncoding) and also with standard fonts.
These characters are shown in table D.1 Latin Character Set and Encodings on page 551 of the documentation.
If I now try to insert such characters, they aren't shown right in the created PDF (Adobe Reader XI, 64bit Windows 7, 32bit Lazarus 1.7 r52225 FPC 3.1.1 r33528 i386-win32-win32/win64).
Simple try these steps to understand, what I mean:
- open Example "testfppdf" and add Run Parameters "-p 1" to only create the first page.
- add in the Source Editor in "testfppdf.lpr" line 139 some of the Latin Characters:
P.WriteText(25, 20, 'Sample Text A???????BC?DE??????');- run your app and see the result (Adobe Reader XI, 64bit Windows 7):
Sample Text A???????BC?DE?????
If I convert the string to a UTF8-encoded one, the result is:
Sample Text A???????BC?DE??????
(I also eliminated FtText1 := D.AddFont('FreeSans.ttf', 'FreeSans', clGreen); and the lines after line 139 to reduce the size of the attached PDFs, the result is the same)
I add the two PDFs (one with ACP encoding, one with UTF-8 encoding) to show you the results. I also add "UTF8_Encoded_PDFString.patch" to show you, what I have done.
I'm not sure, if this workaround is valid or there is a better solution. Please have a you
Kind regards
Michl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_ACP.pdf
Type: application/pdf
Size: 1383 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160421/1fdeb029/attachment.pdf> -------------- next part --------------
A non-text attachment was scrubbed...
Name: test_UTF8.pdf
Type: application/pdf
Size: 1384 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160421/1fdeb029/attachment-0001.pdf> -------------- next part --------------
Index: packages/fcl-pdf/src/fppdf.pp
=================================================================== --- packages/fcl-pdf/src/fppdf.pp (revision 33528) +++ packages/fcl-pdf/src/fppdf.pp (working copy)
@@ -2380,6 +2380,7 @@
FValue := AValue;
if (Pos('(', FValue) > 0) or (Pos(')', FValue) > 0) or (Pos('\', FValue) > 0) then
FValue := InsertEscape(FValue);+ SetCodePage(RawByteString(FValue), CP_UTF8, True); end;
{ TPDFUTF8String }
