[ 
https://issues.apache.org/jira/browse/PDFBOX-3481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15471099#comment-15471099
 ] 

Tilman Hausherr commented on PDFBOX-3481:
-----------------------------------------

Thanks, I've removed it on 1.8 and 2.0. "Animal sniffer" doesn't look at the 
tests.

I've left it in 2.1 for now, as there have been thoughts to use JDK 1.7. If 
somebody complains I'll delete it there too.

> 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
>             Fix For: 1.8.13, 2.0.3, 2.1.0
>
>         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]

Reply via email to