(feature proposal) link to attachments: /GoToE
Hi Hans, having attachments in PDF is very useful, but the vast majority of people don’t know how to handle them (even with the attachment pane displayed when Acrobat opens the document, or with file annotation). It would be really useful to have a link with destination that it would open the embedded document (when clicked). Since in its basic functionality, this is very similar to links to external documents (GoToR), I wonder whether it would be possible to implement links to embedded documents (GoToE, https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008....). At least to begin with, only links to embedded children documents would be required. If this GoToR is generated by ConTeXt from "\goto{whatever}[destination-doc::page(15)]": 17 0 obj << /D [ 14 /Fit ] /F (destination-doc.pdf) /NewWindow true /S /GoToR
endobj
A GoToE destination for "\attachment[file=destination-doc.pdf, method=hidden]" would read: 1 0 obj << /S /GoToE /D [ 14 /Fit ] /NewWindow true /T << /R /C /N (destination-doc.pdf) >>
endobj
With EmbeddedFiles, the F entry from GoToR is a target dictionary (T key) in GoToE. The T dictionary contains the relation (R key) to the destination file (only C, child, needed) and the name (N) from EmbeddedFiles/Names for the attachment. This is the most basic implementation that allows to link to an attachment. What the spec describes as “a complete facility for linking between a file in a hierarchy of nested embedded files and another file in the same or different hierarchy” is probably unnecesarily complex (even to use). With file annotations, instead of the name from EmbeddedFiles/Names in the target dictionary, it requires the keys P and A (as numbers or strings). P gives the page number which contains the file annotation: zero-based as number, or named destination as string. A gives the annotation: zero-based index of the annotation in the Annots array, or NM entry value from the annotation object. As for the interface, it would be great that GoToR links could be converted automatically in "\goto{some text}[file::page(number)]" for attached files. This basic implementation of GoToE links would be extremely helpful to access embedded documents (believe it or not, this is something I explain almost every week at work). I would be happy to provide the code to implement this, but I’m afraid this is way beyond my knowledge. Many thanks for your help, Pablo
On 9/3/2023 12:17 PM, Pablo Rodriguez wrote:
Hi Hans,
having attachments in PDF is very useful, but the vast majority of people don’t know how to handle them (even with the attachment pane displayed when Acrobat opens the document, or with file annotation).
It would be really useful to have a link with destination that it would open the embedded document (when clicked).
Since in its basic functionality, this is very similar to links to external documents (GoToR), I wonder whether it would be possible to implement links to embedded documents (GoToE, https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008....).
At least to begin with, only links to embedded children documents would be required.
If this GoToR is generated by ConTeXt from "\goto{whatever}[destination-doc::page(15)]":
17 0 obj << /D [ 14 /Fit ] /F (destination-doc.pdf) /NewWindow true /S /GoToR
endobj
A GoToE destination for "\attachment[file=destination-doc.pdf, method=hidden]" would read:
1 0 obj << /S /GoToE /D [ 14 /Fit ] /NewWindow true /T << /R /C /N (destination-doc.pdf) >> >> endobj
With EmbeddedFiles, the F entry from GoToR is a target dictionary (T key) in GoToE.
The T dictionary contains the relation (R key) to the destination file (only C, child, needed) and the name (N) from EmbeddedFiles/Names for the attachment.
This is the most basic implementation that allows to link to an attachment.
What the spec describes as “a complete facility for linking between a file in a hierarchy of nested embedded files and another file in the same or different hierarchy” is probably unnecesarily complex (even to use).
With file annotations, instead of the name from EmbeddedFiles/Names in the target dictionary, it requires the keys P and A (as numbers or strings).
P gives the page number which contains the file annotation: zero-based as number, or named destination as string.
A gives the annotation: zero-based index of the annotation in the Annots array, or NM entry value from the annotation object.
As for the interface, it would be great that GoToR links could be converted automatically in "\goto{some text}[file::page(number)]" for attached files.
This basic implementation of GoToE links would be extremely helpful to access embedded documents (believe it or not, this is something I explain almost every week at work).
I would be happy to provide the code to implement this, but I’m afraid this is way beyond my knowledge. remind me in a month or so ... i'm not going to touch that part of the code now (some other priorities)
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 9/3/23 12:46, Hans Hagen wrote:
On 9/3/2023 12:17 PM, Pablo Rodriguez wrote:
[...] This basic implementation of GoToE links would be extremely helpful to access embedded documents (believe it or not, this is something I explain almost every week at work).
I would be happy to provide the code to implement this, but I’m afraid this is way beyond my knowledge. remind me in a month or so ... i'm not going to touch that part of the code now (some other priorities)
Perfectly fine for me, Hans. Pablo
Am 03.09.23 um 13:03 schrieb Pablo Rodriguez:
On 9/3/23 12:46, Hans Hagen wrote:
On 9/3/2023 12:17 PM, Pablo Rodriguez wrote:
[...] This basic implementation of GoToE links would be extremely helpful to access embedded documents (believe it or not, this is something I explain almost every week at work).
I would be happy to provide the code to implement this, but I’m afraid this is way beyond my knowledge. remind me in a month or so ... i'm not going to touch that part of the code now (some other priorities)
Perfectly fine for me, Hans.
While I don’t know what’s missing under the hood, I think there’s just a “reference” key missing in \attachment or \setupattachment: \setupinteraction[state=start] \starttext \samplefile{lorem} \attachment[ file={hacker.jpg}, title={Hacker}, symbol=Paperclip, author=Hans, location=inmargin, reference=foobar, ] As you can see in \in{attachment}[foobar], we’re hacking away … \stoptext Hraban
On 9/3/23 16:02, Henning Hraban Ramm wrote:
Am 03.09.23 um 13:03 schrieb Pablo Rodriguez: [...] While I don’t know what’s missing under the hood, I think there’s just a “reference” key missing in \attachment or \setupattachment:
Many thanks for your reply, Hraban. I’m afraid that \in{attachment}[foobar] doesn‘t generate a link in your sample. Or do you get a link border from the following source? \setupinteraction[state=start] \enabledirectives[references.border=green] \starttext \startTEXpage[offset=1em] \attachment[ file={hacker.jpg}, method=hidden, reference=foobar, ] \goto{Link to attachment}[foobar] \stopTEXpage \stoptext Many thanks for your help, Pablo
participants (3)
-
Hans Hagen
-
Henning Hraban Ramm
-
Pablo Rodriguez