You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Gilad Denneboom <gi...@gmail.com> on 2022/03/14 23:21:48 UTC

Re: Add new Named Dest to file

It's been quite a while since I posted this question, and this issue still
doesn't have a clear answer, as far as I can see...
Any new thoughts on the matter?

On Tue, Nov 20, 2012 at 8:21 PM Gilad Denneboom <gi...@gmail.com>
wrote:

> Hi people,
>
> Another query here... I'm trying to add a new named destination to a file,
> but for some reason it doesn't show up...
>
> Here's the relevant piece of code I'm using for it:
>
>         PDDestinationNameTreeNode dests =
> doc.getDocumentCatalog().getNames().getDests();
>
>         PDPageXYZDestination d = new PDPageXYZDestination();
>         d.setLeft(500);
>         d.setTop(500);
>         d.setPageNumber(0);
>
>         Map<String, Object> destList = dests.getNames();
>         Map<String, COSObjectable> newList = new HashMap<String,
> COSObjectable>();
>
>         Iterator<String> it = destList.keySet().iterator();
>         while(it.hasNext()) {
>             String key = it.next();
>             System.out.println(key);
>             System.out.println(destList.get(key));
>             newList.put(key, (COSObjectable)destList.get(key));
>         }
>         newList.put("1", d);
>         dests.setNames(newList);
>
> Does anyone see any obvious problems, or am I going at it the wrong way?
>

Re: Add new Named Dest to file

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 15.03.2022 um 12:21 schrieb Gilad Denneboom:
> Actually, I was trying to do it in an old project that uses PDFBox 1.8.16
> and it was failing, so I switched over to 2.0.25 and it worked much
> better... If I need help doing it in the former would you be able to
> provide support, or is it too late for that?

Too late indeed. There haven't been an update for a long time now. Your 
original post is from 10 years ago. I did look at setNames() and the 
code is identical. So whatever the problem, it's likely deeper. Update 
that application to 2.0.25.

Tilman



>
> On Tue, Mar 15, 2022 at 5:14 AM Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Please upload the file "before" and "after" somewhere, and add load and
>> save code so we can have a look what happens
>>
>> Tilman
>>
>> Am 15.03.2022 um 00:21 schrieb Gilad Denneboom:
>>> It's been quite a while since I posted this question, and this issue
>> still
>>> doesn't have a clear answer, as far as I can see...
>>> Any new thoughts on the matter?
>>>
>>> On Tue, Nov 20, 2012 at 8:21 PM Gilad Denneboom <
>> gilad.denneboom@gmail.com>
>>> wrote:
>>>
>>>> Hi people,
>>>>
>>>> Another query here... I'm trying to add a new named destination to a
>> file,
>>>> but for some reason it doesn't show up...
>>>>
>>>> Here's the relevant piece of code I'm using for it:
>>>>
>>>>           PDDestinationNameTreeNode dests =
>>>> doc.getDocumentCatalog().getNames().getDests();
>>>>
>>>>           PDPageXYZDestination d = new PDPageXYZDestination();
>>>>           d.setLeft(500);
>>>>           d.setTop(500);
>>>>           d.setPageNumber(0);
>>>>
>>>>           Map<String, Object> destList = dests.getNames();
>>>>           Map<String, COSObjectable> newList = new HashMap<String,
>>>> COSObjectable>();
>>>>
>>>>           Iterator<String> it = destList.keySet().iterator();
>>>>           while(it.hasNext()) {
>>>>               String key = it.next();
>>>>               System.out.println(key);
>>>>               System.out.println(destList.get(key));
>>>>               newList.put(key, (COSObjectable)destList.get(key));
>>>>           }
>>>>           newList.put("1", d);
>>>>           dests.setNames(newList);
>>>>
>>>> Does anyone see any obvious problems, or am I going at it the wrong way?
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Add new Named Dest to file

Posted by Gilad Denneboom <gi...@gmail.com>.
Actually, I was trying to do it in an old project that uses PDFBox 1.8.16
and it was failing, so I switched over to 2.0.25 and it worked much
better... If I need help doing it in the former would you be able to
provide support, or is it too late for that?

On Tue, Mar 15, 2022 at 5:14 AM Tilman Hausherr <TH...@t-online.de>
wrote:

> Please upload the file "before" and "after" somewhere, and add load and
> save code so we can have a look what happens
>
> Tilman
>
> Am 15.03.2022 um 00:21 schrieb Gilad Denneboom:
> > It's been quite a while since I posted this question, and this issue
> still
> > doesn't have a clear answer, as far as I can see...
> > Any new thoughts on the matter?
> >
> > On Tue, Nov 20, 2012 at 8:21 PM Gilad Denneboom <
> gilad.denneboom@gmail.com>
> > wrote:
> >
> >> Hi people,
> >>
> >> Another query here... I'm trying to add a new named destination to a
> file,
> >> but for some reason it doesn't show up...
> >>
> >> Here's the relevant piece of code I'm using for it:
> >>
> >>          PDDestinationNameTreeNode dests =
> >> doc.getDocumentCatalog().getNames().getDests();
> >>
> >>          PDPageXYZDestination d = new PDPageXYZDestination();
> >>          d.setLeft(500);
> >>          d.setTop(500);
> >>          d.setPageNumber(0);
> >>
> >>          Map<String, Object> destList = dests.getNames();
> >>          Map<String, COSObjectable> newList = new HashMap<String,
> >> COSObjectable>();
> >>
> >>          Iterator<String> it = destList.keySet().iterator();
> >>          while(it.hasNext()) {
> >>              String key = it.next();
> >>              System.out.println(key);
> >>              System.out.println(destList.get(key));
> >>              newList.put(key, (COSObjectable)destList.get(key));
> >>          }
> >>          newList.put("1", d);
> >>          dests.setNames(newList);
> >>
> >> Does anyone see any obvious problems, or am I going at it the wrong way?
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Add new Named Dest to file

Posted by Tilman Hausherr <TH...@t-online.de>.
Please upload the file "before" and "after" somewhere, and add load and 
save code so we can have a look what happens

Tilman

Am 15.03.2022 um 00:21 schrieb Gilad Denneboom:
> It's been quite a while since I posted this question, and this issue still
> doesn't have a clear answer, as far as I can see...
> Any new thoughts on the matter?
>
> On Tue, Nov 20, 2012 at 8:21 PM Gilad Denneboom <gi...@gmail.com>
> wrote:
>
>> Hi people,
>>
>> Another query here... I'm trying to add a new named destination to a file,
>> but for some reason it doesn't show up...
>>
>> Here's the relevant piece of code I'm using for it:
>>
>>          PDDestinationNameTreeNode dests =
>> doc.getDocumentCatalog().getNames().getDests();
>>
>>          PDPageXYZDestination d = new PDPageXYZDestination();
>>          d.setLeft(500);
>>          d.setTop(500);
>>          d.setPageNumber(0);
>>
>>          Map<String, Object> destList = dests.getNames();
>>          Map<String, COSObjectable> newList = new HashMap<String,
>> COSObjectable>();
>>
>>          Iterator<String> it = destList.keySet().iterator();
>>          while(it.hasNext()) {
>>              String key = it.next();
>>              System.out.println(key);
>>              System.out.println(destList.get(key));
>>              newList.put(key, (COSObjectable)destList.get(key));
>>          }
>>          newList.put("1", d);
>>          dests.setNames(newList);
>>
>> Does anyone see any obvious problems, or am I going at it the wrong way?
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org