Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-952

getParent method of class PDField doesn't consider both parent keys "P" and "Parent".

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.4.0
    • 1.5.0
    • PDModel
    • None
    • Irrelevant for this issue.

    Description

      The getParent method should lookup a parent using both valid parent keys: "P" and "Parent". The method findFieldType of this class already performs it's lookup using both keys.

      Additionally method getParent of the class PDField has a return type of PDField. While this is appropriate for nested fields this doesn't work for PDPages. I have an AcroForm I'm working with that sets a Page object to be the parent of an AcroForm Field. It does this specifically by setting the "P" key to the object reference for a particular page (e.g. << /P 102 0 R/FT/Btn >> with "102 0 R" being the aforementioned object reference).

      As a result of this design decision there is no way of getting a field's parent page from the getParent method. We are required to get the backing COSDictionary, call getDictionaryObject("P") and create a PDPage Object from scratch. This is workable, but not optimal. We'd prefer to avoid the COS data types wherever possible.

      Thanks,

      Robert McHugh

      Attachments

        Activity

          People

            lehmi Andreas Lehmkühler
            rmchugh Robert McHugh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 8h
                8h
                Remaining:
                Remaining Estimate - 8h
                8h
                Logged:
                Time Spent - Not Specified
                Not Specified