Hi Everyone, I filled in an interactive PDF document using Pdfbox. It works in the sense that the right field does get the value, but after it gets saved, it becomes read-only and can't be manually changed using pdf reader.
I have attached the form for your reference. Thank you. PDDocument pdfTemplate = PDDocument.load(file); PDDocumentCatalog docCatalog = pdfTemplate.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); // Get field names List<PDField> fieldList = acroForm.getFields(); // String the object array String[] fieldArray = new String[fieldList.size()]; int i = 0; for (PDField sField : fieldList) { fieldArray[i] = sField.getFullyQualifiedName(); i++; } for (String f : fieldArray) { PDField field = acroForm.getField(f); System.out.println("field is: " + f); System.out.println(" type: " + field.getFieldType()); if (f.contains("area")) { field.setValue("York"); } } try { pdfTemplate.setAllSecurityToBeRemoved(true); pdfTemplate.save(output_file); pdfTemplate.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } -- Best Wishes, Jason
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org