pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Vacondio <andrea.vacon...@gmail.com>
Subject Form flattening with or without refresh
Date Mon, 13 May 2019 14:11:58 GMT
Hi, we are having some issue when we try to flatten the form in the file
f1040_sample.pdf
We get slightly different results depending on the value of refresh
appearance, in particular when we set it to true we get a slightly wrong
positioning of the text field value.
Shouldn't we expect the same result in both cases?
This is the test code (PDFBox 2.0.15):

@Test
    public void testFlatten() throws IOException {
        PDDocument testPdf = PDDocument.load(new
File("/home/torakiki/tmp/delete/f1040_sample.pdf"));
        PDAcroForm form = testPdf.getDocumentCatalog().getAcroForm();
        List<PDField> fields = new ArrayList<PDField>();

fields.add(form.getField("topmostSubform[0].Page1[0].YourSocial[0].f1_04[0]"));
        testPdf.getDocumentCatalog().getAcroForm().flatten(fields, false);
        File file = new
File("/home/torakiki/tmp/delete/f1040_sample_pdfbox_no_refresh.pdf");
        testPdf.save(file);
    }

I isolated the field in the test case but we also get the same result when
flattening the whole form, I included the Acrobat version of the flattened
pdf.
If we flatten the whole form with refreshAppearance=false we get pretty
much the same result as Acrobat, same number From XObjects, but if we
flatten with refreshAppearance=true we get a lot of Form XObjects (I guess
one for each field, even empty ones) and a slightly wrong positioning of
the text field.
Could you please help me understand what's the issue here?
Thanks

Here the files:
https://www.dropbox.com/sh/rmywlrmftolvwil/AADcz1Djfe59YAm8ykKnpIN5a?dl=0

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message