I trying to create a PDF file with empty pages, but the code throws java.io.IOException: P when I’m trying to read the temp file. Why?
PDF header signature not found
Relevant code:
Document testDoc = new Document();
File testFile = File.createTempFile("pdfTemp", ".tmp");
String test = testFile.getName();
PdfWriter testWriter = PdfWriter.getInstance(document, new FileOutputStream(test));
testDoc.open();
for (int x=1; x<=pdfReader.getNumberOfPages(); x++){
testWriter.setPageEmpty(false);
testDoc.newPage();
}
testDoc.close();
PdfReader testReader = new PdfReader(test);
This may be a coding issue. Your code uses
but
documentvariable isn’t declared anywhere. I suspect you meant to use the following instead: