You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "ganesh j.a" <ga...@live.in> on 2013/11/12 11:19:37 UTC

NullPointerException in StandardSecurityHandler.java

Hi All, I have a encrypted PDF Form document, where need to fill in the forms with desired value and at last need to save the document Here is my piece of code of what I triedPDDocument document;document = PDDocument.load(sourcePath);if( document.isEncrypted() ){try{document.decrypt("" );}catch( InvalidPasswordException e ){}}PDAcroForm form = document.getDocumentCatalog().getAcroForm();PDField Field_1= form.getField("topmostSubform[0].CMS1500Form[0].PatientName[0]");Field_1.setValue("ABC");document.save("C:\\Users\\347702\\Desktop\\21.pdf");document.close();
   But it throws me the below exceptionjava.lang.NullPointerException at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.prepareDocumentForEncryption(StandardSecurityHandler.java:303)I have also tried with adding the below statement, above doc.save(""); document.setAllSecurityToBeRemoved(true); Now I can execute the program without any errors but the desired value (Value : "ABC") is not been filled in saved document .. it looks blank Can anyone help me out please !!Thanks  RegardsGanesh