[
https://issues.apache.org/jira/browse/PDFBOX-3481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15465311#comment-15465311
]
Tilman Hausherr commented on PDFBOX-3481:
-----------------------------------------
I was able to reproduce it with JDK8 and the change I mentioned fixes the
problem you discovered (thanks!). So I was wondering about other occurences,
and yes, some of our {{String.format()}} calls must be changed, I'll do that.
(I'll leave calls in log / gui messages unchanged)
> Localization in XRef generation results in unusable PDFs
> --------------------------------------------------------
>
> Key: PDFBOX-3481
> URL: https://issues.apache.org/jira/browse/PDFBOX-3481
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.8.12, 1.8.13, 2.0.2, 2.0.3, 2.1.0
> Reporter: Edward Kupershlak
> Assignee: Tilman Hausherr
> Labels: easyfix, locale, newbie, patch
> Attachments: xref_format.patch
>
>
> PDFBox appears to be using a localized number formatter when encoding the
> XRef table. Depending on locale settings, this can result in unicode
> characters being used, which prevents PDFBox from loading the PDF.
> The following code demonstrates this:
> {code}
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.FileOutputStream;
> import java.util.Locale;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.PDPage;
> import org.apache.pdfbox.pdmodel.common.PDRectangle;
> class Example {
> public static void main(String [] args) throws Exception {
> File tempFile = File.createTempFile("example", ".pdf");
> Locale arabicLocale = new
> Locale.Builder().setLanguageTag("ar-EG-u-nu-arab").build();
> Locale.setDefault(arabicLocale);
> try (FileOutputStream out = new FileOutputStream(tempFile)) {
> PDDocument doc = new PDDocument();
> doc.addPage(new PDPage(PDRectangle.LETTER));
> doc.save(out);
> doc.close();
> }
> try (FileInputStream in = new FileInputStream(tempFile)) {
> PDDocument doc = PDDocument.load(in);
> // This will throw.
> doc.getPage(0);
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]