You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Stefan Helfert (JIRA)" <ji...@apache.org> on 2014/04/14 13:25:14 UTC
[jira] [Created] (PDFBOX-2027) PDF Page completely white/empty
Stefan Helfert created PDFBOX-2027:
--------------------------------------
Summary: PDF Page completely white/empty
Key: PDFBOX-2027
URL: https://issues.apache.org/jira/browse/PDFBOX-2027
Project: PDFBox
Issue Type: Bug
Components: FontBox, PDModel
Affects Versions: 2.0.0
Environment: Windows XP 32bit
JDK 1.7.0_51
Reporter: Stefan Helfert
Hello,
i am using pdfbox to split the last pages of a pdf to single documents for some calculations.
Unfortunatly for some PDF files i get only white pages. I already found the following post on:
https://issues.apache.org/jira/browse/PDFBOX-2000
So I switched from 1.8.4 to pdfbox-2.0.0-20140412.210944-279 but the problem is still present.
My code is as seen here:
{code:title=Bar.java|borderStyle=solid}
PDDocument doc = new PDDocument();
try {
doc = PDDocument.load(file);
List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
//process last 4 pages
for (int i = pages.size(); i > pages.size() - 4; i--) {
// Get Page
PDPage page = pages.get(i - 1);
// get rotation of page
int rotation = page.findRotation();
//check for landscape
if (rotation == 90 || rotation == -90) {
// create a temp file
File tempFile = File.createTempFile("pdfPage", ".pdf");
// Create a new PDF File
PDDocument tempDoc = new PDDocument();
tempDoc.addPage(page);
// Save pdf to a temporary file
tempDoc.setDocumentInformation(new PDDocumentInformation());
tempDoc.save(tempFile);
tempDoc.close();
//DO SOMETHING
tempFile.delete();
} else {
return "";
}
}
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
if (doc != null) {
doc.close();
}
}
{code}
If i check the temp file its only a white page
--
This message was sent by Atlassian JIRA
(v6.2#6252)