Hi!

I want to remove all form fields from a PDF-document. But everything I try does 
not work.
Can you give me an advice?

Thanks and best regards
Lukas


Here are some attempts I tried but they did not work:

PDDocument pdDocument = PDDocument.load(new File("E:\\test.pdf"));
PDDocumentCatalog pdDocumentCatalog = pdDocument.getDocumentCatalog();
PDAcroForm pdAcroForm = pdDocumentCatalog.getAcroForm();
COSDictionary acroFormDict = pdAcroForm.getDictionary();

// pdDocumentCatalog.setAcroForm(null);

// acroFormDict.clear();

// COSArray fields = (COSArray) 
acroFormDict.getDictionaryObject(COSName.FIELDS);
// fields.clear();

// acroFormDict.removeItem(COSName.FIELDS);

pdDocument.save("E:\\test-result.pdf");

Reply via email to