[ https://issues.apache.org/jira/browse/PDFBOX-481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12717045#action_12717045 ]
Andreas Lehmkühler commented on PDFBOX-481: ------------------------------------------- I've tried to set several values in the Source_Target.pdf and it works fine. I'm using the trunk version of pdfbox but I guess 0.7.3. should work too. But the problem is, pdfbox can't display the whole pdf with PDFReader because of some problems with the PDSeperation during setting the nonstroking color (see stacktrace). This issue doesn't depend on the modifications done to the acroform, the NPE already appears if you try to display Source_Original.pdf. Jun 7, 2009 5:21:21 PM org.apache.pdfbox.util.PDFStreamEngine processOperator WARNING: java.lang.NullPointerException at org.apache.pdfbox.util.operator.SetNonStrokingSeparation.process(SetNonStrokingSeparation.java:51) org.apache.pdfbox.util.operator.SetStrokingColor.process(SetStrokingColor.java:61) org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:500) org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:220) org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:179) org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:90) org.apache.pdfbox.pdfviewer.PDFPagePanel.paint(PDFPagePanel.java:76) > renaming a field and not able to set value to the saved PDF document ... > ------------------------------------------------------------------------ > > Key: PDFBOX-481 > URL: https://issues.apache.org/jira/browse/PDFBOX-481 > Project: PDFBox > Issue Type: Bug > Components: PDModel.AcroForm > Affects Versions: 0.7.3 > Environment: Windows XP Professional SP3, jre1.6.0_07/jdk1.6.0_11 , > PDFBox-0.7.3.jar > Reporter: Venkatesh Prasad.B.K. > Fix For: 0.7.3 > > Attachments: Source_Original.pdf, Source_Target.pdf > > > I will explain what I want to do. > 1. I have a PDF Document with Fields and let us call this > 'Source_Original.PDF'. The field names in this PDF document have to be > renamed and stored as 'Source_Target.PDF'. I then have to set/change the > values of form-fields in 'Source_Target.PDF'. > The issue I am facing is given below: > 1. I renamed the form fields in 'Source_Original.PDF" using the code given in > my earlier mail (below) and saved it as 'Source_Target.PDF'. > 2. I checked the form fields in 'Source_Target.PDF" and form-fields were > renamed correctly. > 3. However when I tried to set/change values of form-fields in > 'Source_Target.PDF' using PDFBox code, I was not able to do so. > I used iText to set/change values of form-fields in 'Source_Target.PDF' and > was successful. But we want to use only PDFBox. > To summarize - We are not able to set/change values of form fields of a PDF > Document whose form-fields have been renamed. There is no issue if the > form-fields are renamed manually using Adobe Acrobat 9. The issue is only > when the form-fields are renamed using PDFBox option - > setPartialName(newFieldName); > > Only to be sure, changing values in 'Source_Original.PDF' works with the > > same code you use to > > manipulate 'Source_Target.PDF'?? > Yes > I have attached the 2 files - "Source_Original.PDF' and 'Source_Target.PDF', > ----- Code > try > { > PDDocument pdfDocument = > PDDocument.load(pdfSource); > try > { > if (pdfDocument.isEncrypted()) > { > pdfDocument.decrypt(""); > } > PDDocumentCatalog docCatalog = > pdfDocument.getDocumentCatalog(); > PDAcroForm acroForm = > docCatalog.getAcroForm(); > if (acroForm != null) > { > List pdfFields = > acroForm.getFields(); > if (pdfFields != null) > { > PDField > pdfField; > for (int i = 0; > i < pdfFields.size(); i++) > { > > pdfField = (PDField) pdfFields.get(i); > String > fieldName = pdfField.getPartialName(); > if( > pdfFieldNames.containsKey(fieldName) ){ > > String newFieldName = (String) pdfFieldNames.get(fieldName); > > pdfField.setPartialName(newFieldName); > } > } > > pdfDocument.save(pdfOutput); > } else { > return "No Acro > Form Fields found in PDF Document " + pdfSource + "!"; > } > } else { > return "PDF document " > + pdfSource + " not able to access!"; > } > } catch (Exception e) { > return "PDF Document " + > pdfSource + " is encrypted! Cannot process."; > } > pdfDocument.close(); > } catch (Exception e) { > return "PDF Document " + pdfSource + " > cannot be found!"; > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.