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 ----