Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.0
    • Fix Version/s: 2.0.5, 3.0.0
    • Component/s: Utilities
    • Labels:
    • Environment:
      Windows 2008 R2

      Description

      Merging two PDFs with form fields results in a PDF with empty fields.
      The issue seems to be similar to PDFBOX-1031, but in my case i see the fields but not the value in the fields.

      I use the following command to merge the PDFs:
      java -classpath pdfbox-app-1.6.0.jar org.apache.pdfbox.PDFMerger a.pdf b.pdf c.pdf

      1. a.pdf
        31 kB
        Gerhard Temper
      2. b.pdf
        26 kB
        Gerhard Temper
      3. c.pdf
        47 kB
        Gerhard Temper
      4. c-1.8.13.pdf
        67 kB
        Maruan Sahyoun
      5. c-2.0.4.pdf
        46 kB
        Maruan Sahyoun
      6. dereferenceObjectStreams.patch
        0.9 kB
        Ernst Eibensteiner

        Activity

        Hide
        ernst.eibensteiner Ernst Eibensteiner added a comment -

        I created a short test program for that case:

        PDDocument pdf = PDDocument.load("C:\\tmp
        a.pdf");
        PDDocumentCatalog docCatalog = pdf.getDocumentCatalog();
        PDAcroForm acroForm = docCatalog.getAcroForm();
        List<PDField> list = acroForm.getFields();
        Iterator<PDField> it = list.iterator();
        while (it.hasNext())

        { PDField field = it.next(); System.out.println("FQ Name: "+field.getFullyQualifiedName()); System.out.println("Value: "+field.getValue()); }

        Output shows:
        =============
        FQ Name: Testfeld
        Value: null
        FQ Name: Testfeld2
        Value: null

        So it seems that "field.getValue()" does not work correctly or does not get the latest value from the form field.

        Show
        ernst.eibensteiner Ernst Eibensteiner added a comment - I created a short test program for that case: PDDocument pdf = PDDocument.load("C:\\tmp a.pdf"); PDDocumentCatalog docCatalog = pdf.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); List<PDField> list = acroForm.getFields(); Iterator<PDField> it = list.iterator(); while (it.hasNext()) { PDField field = it.next(); System.out.println("FQ Name: "+field.getFullyQualifiedName()); System.out.println("Value: "+field.getValue()); } Output shows: ============= FQ Name: Testfeld Value: null FQ Name: Testfeld2 Value: null So it seems that "field.getValue()" does not work correctly or does not get the latest value from the form field.
        Hide
        ernst.eibensteiner Ernst Eibensteiner added a comment -

        obviously the COSDictionary does not contain the correct value:

        PDDocument pdf = PDDocument.load("C:\\tmp
        a.pdf");
        PDDocumentCatalog docCatalog = pdf.getDocumentCatalog();
        PDAcroForm acroForm = docCatalog.getAcroForm();
        System.out.println("acroForm COSObject: "+acroForm.getCOSObject().toString());
        List<PDField> list = acroForm.getFields();
        Iterator<PDField> it = list.iterator();
        while (it.hasNext())

        { PDField field = it.next(); System.out.println("fieldCOSObject: "+field.getCOSObject().toString()); }

        Output shows:
        acroForm COSObject: ..... COSName

        {Fields}

        :COSArray{[COSObject

        {31, 0}

        , COSObject

        {32, 0}

        ]})
        correct COSObject 31 and 32 found for the Fields!

        but
        COSObject 31 does not contain COSName

        {V}
        COSObject 32 does not contain COSName{V}

        if I open the same document using http://www.pdftron.com/ I can see the correct
        COSName

        {V}

        for both COSObjects (Object number 31 and 32) containing the correct value.

        Show
        ernst.eibensteiner Ernst Eibensteiner added a comment - obviously the COSDictionary does not contain the correct value: PDDocument pdf = PDDocument.load("C:\\tmp a.pdf"); PDDocumentCatalog docCatalog = pdf.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); System.out.println("acroForm COSObject: "+acroForm.getCOSObject().toString()); List<PDField> list = acroForm.getFields(); Iterator<PDField> it = list.iterator(); while (it.hasNext()) { PDField field = it.next(); System.out.println("fieldCOSObject: "+field.getCOSObject().toString()); } Output shows: acroForm COSObject: ..... COSName {Fields} :COSArray{[COSObject {31, 0} , COSObject {32, 0} ]}) correct COSObject 31 and 32 found for the Fields! but COSObject 31 does not contain COSName {V} COSObject 32 does not contain COSName{V} if I open the same document using http://www.pdftron.com/ I can see the correct COSName {V} for both COSObjects (Object number 31 and 32) containing the correct value.
        Hide
        ernst.eibensteiner Ernst Eibensteiner added a comment -

        I've created a short patch that worked for me, but there is certainly a reason for the if clause!

        I found out that COSObect 31 and 32 were added twice into the COSDictionary. The first one did not contain a

        {V}

        attribute, the second one did. So the patch adds both versions into the COOSDictionary.

        Hopefully this helps.

        Show
        ernst.eibensteiner Ernst Eibensteiner added a comment - I've created a short patch that worked for me, but there is certainly a reason for the if clause! I found out that COSObect 31 and 32 were added twice into the COSDictionary. The first one did not contain a {V} attribute, the second one did. So the patch adds both versions into the COOSDictionary. Hopefully this helps.
        Hide
        msahyoun Maruan Sahyoun added a comment -

        I've checked with 1.8.13 and 2.0.4 and the issue is gone - probably fixed a while ago. I'll add a unit test later to ensure that this will remain so.

        Show
        msahyoun Maruan Sahyoun added a comment - I've checked with 1.8.13 and 2.0.4 and the issue is gone - probably fixed a while ago. I'll add a unit test later to ensure that this will remain so.
        Hide
        msahyoun Maruan Sahyoun added a comment -

        results done using 1.8.13 c-1.8.13.pdf and 2.0.4 c-2.0.4.pdf

        Show
        msahyoun Maruan Sahyoun added a comment - results done using 1.8.13 c-1.8.13.pdf and 2.0.4 c-2.0.4.pdf
        Hide
        msahyoun Maruan Sahyoun added a comment -

        the issue here was that the /AP entry and the /V entry were not merged/added.

        Show
        msahyoun Maruan Sahyoun added a comment - the issue here was that the /AP entry and the /V entry were not merged/added.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1780893 from Maruan Sahyoun in branch 'pdfbox/trunk'
        [ https://svn.apache.org/r1780893 ]

        PDFBOX-1100: add unit test to ensure /AP and /V entry

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1780893 from Maruan Sahyoun in branch 'pdfbox/trunk' [ https://svn.apache.org/r1780893 ] PDFBOX-1100 : add unit test to ensure /AP and /V entry
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1780894 from Maruan Sahyoun in branch 'pdfbox/branches/2.0'
        [ https://svn.apache.org/r1780894 ]

        PDFBOX-1100: add unit test to ensure /AP and /V entry

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1780894 from Maruan Sahyoun in branch 'pdfbox/branches/2.0' [ https://svn.apache.org/r1780894 ] PDFBOX-1100 : add unit test to ensure /AP and /V entry
        Hide
        msahyoun Maruan Sahyoun added a comment -

        setting to fixed after adding a unit test. The issue itself was fixed a while ago - see comments.

        Show
        msahyoun Maruan Sahyoun added a comment - setting to fixed after adding a unit test. The issue itself was fixed a while ago - see comments.

          People

          • Assignee:
            msahyoun Maruan Sahyoun
            Reporter:
            gerhardt Gerhard Temper
          • Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development