Am Mittwoch, dem 26.05.2021 um 07:53 +0200 schrieb Ranjeet Kuruvilla:
> I know how Itext works and PDFBox does not work the same. In Itext the
> result is that only the right fields are flattened. It seems there is a
> bug.
I've created a small test which is running fine:
PDDocument document = Loader.loadPDF(new File(IN_DIR, NAME_OF_PDF));
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
int numFieldsBefore = acroForm.getFields().size();
List<PDField> toBeFlattened = new ArrayList<>();
PDTextField field = (PDTextField) acroForm.getField("AlignLeft-
Filled");
toBeFlattened.add(field);
acroForm.flatten(toBeFlattened,false);
assertEquals(numFieldsBefore, acroForm.getFields().size() + 1, "The
number of form fields shall be reduced by one");
A manual inspection of the result shows that all fields but one are
still accessible.
The file being used was
src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/Multiline
Fields.pdf
Version used was the current trunk.
So please do a similar test with your files. I'm not saying there is no
bug but we have to be able to reproduce it to be able to solve it. With
the files I've tested with the result is fine.
BR
Maruan
>
> In PdfBox every field is flattened, even though I delivered a list of
> fields, that were meant to be flattened.
>
> It seems the PDF is destroyed by flattening.
>
> I have attached the code.
>
> On 25.05.21 19:27, Tilman Hausherr wrote:
> > Here's a PDF flattened by itext
> > https://github.com/itext/i7js-examples/blob/develop/cmpfiles/sandbox/acroforms/cmp_checkbox_flatten.pdf
> >
> > and they do something similar to what we do, i.e. remove the fields
> > and converting it to form XObjects.
> > Tilman
> >
> > Am 25.05.2021 um 19:03 schrieb [email protected]:
> > > Am Dienstag, dem 25.05.2021 um 18:33 +0200 schrieb Ranjeet
> > > Kuruvilla:
> > > > Hallo.
> > > > It is clear, that flattening does have a bug. Compare flattening
> > > > of
> > > > PDFBox with IText and you realize, that PDFBox destroys all
> > > > fields,
> > > > once
> > > > I call
> > > >
> > > > acroform.flatten(fields, true) or acroform.flatten(fields, false)
> > > >
> > > >
> > > the purpose of flatten is that the flattened fields are removed and
> > > become part of the regular page content.
> > >
> > > If you'd like to keep the field but would like it to be protected
> > > you
> > > have to set the field to read only. Keep in mind that one could use
> > > a
> > > lib and remove the flag and change the content afterwards.
> > >
> > > Now, if there is really a bug I need to have a clear description
> > > how to
> > > reproduce it together with sample content. If you're able to
> > > provide
> > > that I'm happy to take a look.
> > >
> > > BR
> > > Maruan
> > >
> > > > .
> > > >
> > > > How can I request someone to fix flattening and make it work like
> > > > in
> > > > IText. That is that the right fields are flattened while all the
> > > > other
> > > > fields remain untouched!
> > > >
> > > >
> > > >
> > > > -----------------------------------------------------------------
> > > > ----
> > > > To unsubscribe, e-mail: [email protected]
> > > > For additional commands, e-mail: [email protected]
> > > >
> > >
> > >
> > >
> > > -------------------------------------------------------------------
> > > --
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
--
--
Maruan Sahyoun
FileAffairs GmbH
Josef-Schappe-Straße 21
40882 Ratingen
Tel: +49 (2102) 89497 88
Fax: +49 (2102) 89497 91
[email protected]
www.fileaffairs.de
Geschäftsführer: Maruan Sahyoun
Handelsregister: AG Düsseldorf, HRB 53837
UST.-ID: DE248275827
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]