Pleasure to meet a fellow named destination seeker!

You have done what I was able to do and more, so far. I have only been able
to edit existing named destinations so far, I'm afraid.

In fact, I found that if you use this method to change the names of named
destinations, their properties are changed to the point that they are not
usable. I am still working on this as time permits.

What version of PDFBox are you on, BTW? It's up to 1.2 now, FYI. Not sure if
that would help, or not. I'm still on the last version.



On Mon, Jul 19, 2010 at 5:11 AM, Chemi <[email protected]> wrote:

>  I have investigated further... and I have added already a
> PDPageXYZDestination to my PDF file. But I have some issues/questions:
>
> 1.- I would like to add a destination pointing to a specific String. I got
> COString reference but, I don't know how to find its X, Y coords. Any help?
>
> 2.- When I open my new PDF file with Adobe Acrobat (not Reader) and I show
> all the defined destinations, I can't see the names... I have to click right
> button on top of where theoretically they should be listed, select rename
> and then, "magically" the name appears. Any idea? Perhaps I am creating the
> PDPageXYZDestination with wrong data.
>
> Here is the piece of code I used to create and add my test destination (it
> is based on Kevin piece of code).
> Note: It is working with a PDF which already has destinations defined... it
> is important because I think if there is no destinations already defined
> this piece of code will crash.
> Any comment on it?
>
> PDDocument document = PDDocument.load("D:\\dev\\PDFOpenParameters.pdf",
> false);
> PDDocumentCatalog log = document.getDocumentCatalog();
> PDDocumentNameDictionary dic = log.getNames();
> PDDestinationNameTreeNode dests = dic.getDests();
>
> PDPageXYZDestination d = new PDPageXYZDestination();
> d.setLeft(500);
> d.setTop(500);
> d.setPageNumber(0);
>
> List<PDNameTreeNode> destList = dests.getKids();
> Map<String, Object> destList2 = destList.get(0).getNames();
> Map<String, COSObjectable> newList = new HashMap<String, COSObjectable>();
>
> Iterator<String> it = destList2.keySet().iterator();
> while(it.hasNext())
> {
>  String key = it.next();
>  newList.put(key,(COSObjectable)destList2.get(key));
> }
> newList.put("CHEMI",d);
> destList.get(0).setNames(newList);
> document.save("D:\\dev\\PDFOpenParameters2.pdf");
>
> Thanks in advance,
>
>    Chemi.
>
> On 7/18/2010 9:53 AM, Chemi wrote:
>
>>  Hi, I would like to add named destinations to a PDf file.
>>
>> Reading Adobe Reader documentation (
>> http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf),
>> it seems there is an open parameter called:
>>
>>    nameddest=name (Specifies a named destination in the PDF).
>>
>> Such named destination seems not to be a bookmark but a different thing. I
>> have reviewed PDFBox docs and was not able to fund such named destination
>> concept.
>> Do you know if it is possible to add named destinations to a PDF file
>> using PDFBox library?
>>
>> Thanks in advance,
>>
>>     Chemi.
>>
>
>

Reply via email to