You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Edward Kupershlak (JIRA)" <ji...@apache.org> on 2016/09/05 02:39:21 UTC
[jira] [Created] (PDFBOX-3481) Localization in XRef generation
results in unusable PDFs
Edward Kupershlak created PDFBOX-3481:
-----------------------------------------
Summary: 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: 2.0.2
Reporter: Edward Kupershlak
PDFBox appears to be using a localized number formatter when encoding the XRef table. Depending on locale settings, this can result in non-ascii characters being used, which prevents PDFBox from loading the PDF.
The following code demonstrates this:
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);
}
}
}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org