fppfd writing localized floating point strings
Original Reporter info from Mantis: wp @wpam
-
Reporter name:
Original Reporter info from Mantis: wp @wpam
- Reporter name:
Description:
Unit fpPDF contains several places in which floating point values are written to the pdf document as strings like this:
t1 := FormatFloat('0.###;;0', Cos(rad));
or
AddObject(TPDFFreeFormString.Create(Document,
Format('%s %s %s %s %.4f %.4f cm', [t1, t2, t3, t1, p1.X, p1.Y]) + CRLF));
Since these FormatFloat() or Format() calls does not specifiy the FormatSettings as last parameter the string is created using the localized DefaultFormatSettings, i.e. it may contain a decimal comma in certain countries (e.g. Germany, like mine).
I think this is against PDF specification. Standard pdf readers at least cannot open such files.
Steps to reproduce:
The bug appears when rotated images are embedded into the PDF. Please run attached demo. It first sets the default decimal separator to a ',' so that everybody can see the bug. Then it adds a rotated jpeg image to the PDF.
Open the generated 'test.pdf' file in Adobe Reader, foxit reader, SumatraPDF, GoogleChrome, FireFox etc. The page with the rotated image will not be displayed. Adobe Reader will display a generic error message that the file is faulty.
Additional information:
The provided patch fixed the issue. It adds its own non-localized FormatSettings to the PDFDocument and calls FormatFloat() and Format() with it as last parameter.
Mantis conversion info:
- Mantis ID: 34077
- Version: 3.0.4
- Fixed in version: 3.1.1
- Fixed in revision: 39585 (#7e6416b1)
- Monitored by: » AntonK (Anton Kavalenka)
- Target version: 3.2.0