You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Adam Nichols <Ad...@swmc.com> on 2009/06/02 20:24:48 UTC

Re: Get page number for bookmark

toArray returns an array of PDPage objects.  Since the PDPage objects do 
not contain the page ID (as far as  can tell), this will not suffice. 
Likewise iterator() and listIterator() both iterate over collections of 
PDPages.  What I need is a list of object IDs for the pages; I don't want 
the actual data in the pages.

--Adam




Andreas Lehmkühler <an...@lehmi.de> 
05/31/2009 10:25
Please respond to
pdfbox-dev@incubator.apache.org


To
pdfbox-dev@incubator.apache.org
cc

Subject
Re: Get page number for bookmark






Hi Adam,

did you ever try to use one of the following methods:

COSArrayList.iterator
COSArrayList.listIterator
COSArrayList.toArray

All of them should return the data you're looking for.

Andreas Lehmkühler

Adam Nichols schrieb:
> I propose the following function is added to COSArrayList.
> 
>     public COSArray toList() 
>     {
>         COSArray copy = new COSArray();
>         for(int i=0; i < array.size(); ++i)
>             copy.add(array.get(i));
>         return copy;
>     }
> 
> This returns a copy of the array to ensure the callers can't modify the 
> internal array variable.  Callers already have access to this 
information 
> as it is the same data as is returned by toString() just in a more 
useful 
> format.  If it's OK to give the callers the ability to modify array 
> directly, a reference could simply be returned.
> 
> I needed this because I got the "indirect reference to a page object" 
from 
> the target listed in a GoTo action and needed the page number.  By using 

> the method above I was able to get the page references in the catalog 
and 
> thus was able to determine the page number based on the page object id I 

> had.
>