ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 20 forks source link

How to name a destination #54

Open sciurius opened 2 years ago

sciurius commented 2 years ago

Annotations have a method link.

$annotation->link($destination, $location, @args);

According to the docs, $destination is a PDF::API2::Page object or the name of a named destination defined elsewhere. I must be overlooking something, but how can I define a named destination?

$destination = PDF::API2::NamedDestination->new($pdf, ...);

This seems to produce an unnamed (explicit) destination.

kg4zow commented 11 months ago

I'm running into the same problem - I can create a "destination", but I can't find any information about how to associate a NAME with it.

In my case, I need the name so that users can link to a specific page within the PDF, referencing it by the name. Pages correspond to dates, so what I'm thinking is something like https://hostname/filename.pdf#2023-09-30 rather than https://hostname/filename.pdf#page=47 (because the file itself will be updated on a semi-regular basis, and the page numbers for each date will change over time).

Actually ... am I even correct in assuming that this kind of "external linking" is what a "NamedDestination" is used for in the first place? The people who designed the PDF file format seem to have their own ideas about what words mean - for example, the area that you click/tap on to jump to something else is called an "annotation" rather than a "link". (This fact would be VERY helpful if it were present in the PDF::API2 documentation, hint hint...)