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

PDActionEmbeddedGoTo does not accept a Destination with a page number or string

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.26
    • 2.0.27, 3.0.0 PDFBox
    • AcroForm
    • None

    Description

      According to Table 202 of the PDF 32000-1:2008 specs, the P key under the Target Directory of an Embedded Go-To Action is an "integer or byte string", with the following description "If the value is an integer, it specifies the page number (zero-based) in the current document containing the file attachment annotation. If the value is a string, it specifies a named destination in the current document that provides the page number of the file attachment annotation."

      However, the current implementation of PDActionEmbeddedGoTo does not accept using the setPageNumber command by itself when setting the Destination dictionary, and throws an IllegalArgumentException unless setPage is used to set the target page as a PDPage object, which is not specified in the documentation. Also, there doesn't seem to be a way to specify the target as a string, if a named destination is to be used.
      This applies to both the Destination dictionary and the Target Directory, but when creating such a link in Acrobat the Target Directory does not contain a P value at all, only the Destination dictionary does, and in the form of a number. This should be possible to replicate using PDFBox.

       

      Attached are a sample file with a pre-existing link and a PDF attachment, the code trying to set that link's action to open the attachment on page 3, and the resulting error message stack trace.

      Attachments

        1. image-2022-07-03-17-31-04-424.png
          23 kB
          Gilad Denneboom
        2. image-2022-07-03-17-30-29-113.png
          23 kB
          Gilad Denneboom
        3. screenshot-1.png
          141 kB
          Tilman Hausherr
        4. LinkTest_Acrobat.pdf
          8 kB
          Gilad Denneboom
        5. LinkTest_edited.pdf
          9 kB
          Gilad Denneboom
        6. EmbeddedActionTest-1.java
          3 kB
          Gilad Denneboom
        7. LinkTest.pdf
          8 kB
          Gilad Denneboom
        8. StackTrace.txt
          0.3 kB
          Gilad Denneboom

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              giladd Gilad Denneboom
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: