Mr. Andreas, Thanks for responding to my mail. I am using PDFBox-0.7.3 version. 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); I hope I am clear or please let me know. I can send the 'Source_Original.PDF' and 'Source_Target.PDF' if it helps. Thanks & Regards Venkatesh Prasad.B.K.
________________________________ From: Andreas Lehmkühler [mailto:andr...@lehmi.de] Sent: Fri 6/5/2009 12:17 PM To: pdfbox-users@incubator.apache.org Subject: Re: renaming a field and not able to set value to the saved PDF document ... Hi, I still try to understand what you're doing. Do you want to set/change the value of a form-field, e.g. a variable textfield? Or do you try to change the internal name of a form-field? How do you check if you're successful or not? What version of pdfbox are you using? Andreas Lehmkühler ----- original Nachricht -------- Betreff: renaming a field and not able to set value to the saved PDF document ... Gesendet: Mi, 03. Jun 2009 Von: Venkatesh Prasad<venkatesh.pra...@trv.envestnet.com> > I renamed fields in a PDF document "source.PDF" and saved the document as > 'target.PDF". I was then not able to set values to the fields in the saved > document 'target.PDF". I also observed reduction in the size of the saved > PDF - source.PDF (3.34 MB) - target.PDF (911 KB). > > Can anyone help? The code I used to rename the fields is given below: > > 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( fieldName.equalsIgnoreCase("Test1") ){ > String newFieldName = "acco...@name1"; > 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(); > > Thanks & Regards > > Venkatesh Prasad.B.K. > > --- original Nachricht Ende ----