You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2009/05/07 23:34:45 UTC

[jira] Commented: (PDFBOX-463) Not able to list fields

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

Andreas Lehmkühler commented on PDFBOX-463:
-------------------------------------------

Please attach the whole stack trace, so that we have an idea what to look  for.

> 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
>         Attachments: SIMPLEIRAApp.pdf
>
>   Original Estimate: 144h
>  Remaining Estimate: 144h
>
> 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.