Not able to list fields
-----------------------
Key: PDFBOX-463
URL: https://issues.apache.org/jira/browse/PDFBOX-463
Project: PDFBox
Issue Type: Bug
Components: PDModel.AcroForm
Affects Versions: 0.7.3
Environment: Windows XP, JAVA jre6
Reporter: Venkatesh Prasad
Priority: Critical
I am trying to list form fields using the following code. There is no issue for
a few PDF documents but for some I am getting the error -
java.lang.NullPointerException.
String pdfSource = "SIMPLE IRA App 1.828247.101 & Ret Acct
Customer Agmt 1.830486.102 -- as of 6-6-08.pdf";
try {
FileOutputStream outputObj;
PrintStream outputFile;
String fileName = pdfSource.replace(".","_") + ".txt";
outputObj = new FileOutputStream(fileName);
outputFile = new PrintStream(outputObj);
PDDocument document = PDDocument.load(pdfSource);
try {
if (document.isEncrypted()) {
document.decrypt("");
}
} catch (Exception e) {
System.out.println("Failed to decrypt document
#");
}
List list =
document.getDocumentCatalog().getAcroForm().getFields();
PDField pdfield;
for (int i = 0; i < list.size(); i++)
{
pdfield = (PDField) list.get(i);
String fldName = pdfield.getPartialName();
outputFile.println(fldName);
}
document.close();
outputFile.close();
} catch (Exception e) {
System.out.println("Error!" + e);
}
Please let me know what the issue is.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.