You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Nick Brockett <NB...@datasys.co.uk> on 2015/10/07 09:36:52 UTC

Error encountered : Destination of a GoTo action must be a page dictionary object

Hi
Please can someone help explain the above error?
I am using
       <dependency>
              <groupId>org.apache.pdfbox</groupId>
              <artifactId>pdfbox</artifactId>
              <version>1.8.10</version>
       </dependency>
I am creating a report using PDFBox.
My report  is a master-detail style layout.
First few pages present a table of records, followed by a minimum of one single page for each entry.
So 20 rows in the first page will be followed by at least 20 pages of separate detail pages.
Each record (row) in the master table then needs a hyperlink to GoTo the relevant page.

My design requires that the first column in the master table has its Text value working as a hyperlink.

My attempts with the following code structure (which for now simply tries to place a rectangle at the bottom of each page is giving me the error in the title of this email.
Once this is achieved I can then move to place each page Link behind the first cell.
                      //set a pageLink
                  PDAnnotationLink goToLink         = new PDAnnotationLink();
                  PDPageDestination destination = new PDPageFitWidthDestination();
                  PDActionGoTo goToAction           = new PDActionGoTo();
                  destination.setPageNumber(1);
                  goToAction.setDestination(destination);
                  goToLink.setAction(goToAction);
                   PDRectangle pos = new PDRectangle();
                  pos.setLowerLeftX(150);
                  pos.setLowerLeftY(20);
                   pos.setUpperRightX(200);
                   pos.setUpperRightY(10);
                   goToLink.setRectangle(pos);
                   page.getAnnotations().add(goToLink);



Help greatly appreciated!!
Thanks
Nick


Re: Error encountered : Destination of a GoTo action must be a page dictionary object

Posted by Gilad Denneboom <gi...@gmail.com>.
Try using setPage instead of setPageNumber. It's a better approach because
if you then swap pages around your bookmarks will automatically update,
unlike with setPageNumber.

On Wed, Oct 7, 2015 at 9:36 AM, Nick Brockett <NB...@datasys.co.uk>
wrote:

> Hi
> Please can someone help explain the above error?
> I am using
>        <dependency>
>               <groupId>org.apache.pdfbox</groupId>
>               <artifactId>pdfbox</artifactId>
>               <version>1.8.10</version>
>        </dependency>
> I am creating a report using PDFBox.
> My report  is a master-detail style layout.
> First few pages present a table of records, followed by a minimum of one
> single page for each entry.
> So 20 rows in the first page will be followed by at least 20 pages of
> separate detail pages.
> Each record (row) in the master table then needs a hyperlink to GoTo the
> relevant page.
>
> My design requires that the first column in the master table has its Text
> value working as a hyperlink.
>
> My attempts with the following code structure (which for now simply tries
> to place a rectangle at the bottom of each page is giving me the error in
> the title of this email.
> Once this is achieved I can then move to place each page Link behind the
> first cell.
>                       //set a pageLink
>                   PDAnnotationLink goToLink         = new
> PDAnnotationLink();
>                   PDPageDestination destination = new
> PDPageFitWidthDestination();
>                   PDActionGoTo goToAction           = new PDActionGoTo();
>                   destination.setPageNumber(1);
>                   goToAction.setDestination(destination);
>                   goToLink.setAction(goToAction);
>                    PDRectangle pos = new PDRectangle();
>                   pos.setLowerLeftX(150);
>                   pos.setLowerLeftY(20);
>                    pos.setUpperRightX(200);
>                    pos.setUpperRightY(10);
>                    goToLink.setRectangle(pos);
>                    page.getAnnotations().add(goToLink);
>
>
>
> Help greatly appreciated!!
> Thanks
> Nick
>
>