List of usage examples for com.lowagie.text.pdf PdfDictionary size
public int size()
PdfDictionary
. From source file:questions.javascript.RemoveJavaScript.java
public static void main(String[] args) throws DocumentException, IOException { // creating the form with JS AddJavaScriptToForm.main(args);//from w w w . j a v a 2s. c o m // removing the document level JS PdfReader reader = new PdfReader(AddJavaScriptToForm.RESULT); PdfDictionary root = reader.getCatalog(); PdfDictionary names = root.getAsDict(PdfName.NAMES); names.remove(PdfName.JAVASCRIPT); if (names.size() == 0) { root.remove(PdfName.NAMES); } reader.removeUnusedObjects(); // filling out and flattening the form // (if you don't flatten, you'll get JS errors!) PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT)); AcroFields form = stamper.getAcroFields(); form.setField("married", "no"); stamper.setFormFlattening(true); stamper.close(); }