mkl-public / testarea-pdfbox2

Test area for public PDFBox v2 issues on stackoverflow etc
Apache License 2.0
83 stars 44 forks source link

how to modify form object stream? #9

Closed zhongguogu closed 2 years ago

zhongguogu commented 3 years ago

https://github.com/mkl-public/testarea-pdfbox2/blob/master/src/test/java/mkl/testarea/pdfbox2/content/RemoveText.java#L49 ` public void processForm(PDFormXObject form) throws IOException {

    final PDStream formContentStream = form.getContentStream();
    final PDResources resources = form.getResources();
    formReplacementStream=formContentStream.createOutputStream(COSName.FLATE_DECODE);
    formReplacement = new ContentStreamWriter(formReplacementStream);
    super.showForm(form);

}

` how to update the PDFormXObjects' stream?

zhongguogu commented 3 years ago

"Indeed, I would create a new form XObject and replace the reference to the old one in the page resources by a reference to the new one"

mkl-public commented 3 years ago

Please share an example PDF for testing that.

mkl-public commented 2 years ago

Closing due to missing response