[NTG-context] broken links in PDF included via \copypages (PoC fix attached)

Tomas Janousek tomi at nomi.cz
Fri Mar 22 15:35:24 CET 2019


Hello,

I happen to need to include a PDF which uses unusual link annotations. Instead
of something like:

    << /A << /D (aff1a) /S /GoTo >> /Border [ 0 0 0 ] /C [ 1 0 0 ] /F 4 /H /I /Rect [ 104.214 577.913 110.231 586.941 ] /Subtype /Link /Type /Annot >>

there's

    << /Border [ 0 0 0 ] /C [ 1 0 0 ] /Dest (aff0001) /H /I /Rect [ 109.005 570.781 115.335 584.308 ] /Subtype /Link /Type /Annot >>

The error I'm getting is:

    backend         > link > missing link annotation

This appears to be okay according to PDF reference [PDFref, pages 492 and
501], and it's also supported in poppler [poppler-link]. But it's not
supported in lpdf-epd.lua.

[PDFref]: https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf
[popplet-link]: https://github.com/danigm/poppler/blob/0011805e22193b690b99a53dcb9986ce04eb3eb4/poppler/Link.cc#L914-L924

I applied this workaround and it fixed the issue for me:

--- /usr/share/texmf/tex/context/base/mkiv/lpdf-epa.lua 2018-03-20 23:10:59.000000000 +0100
+++ lpdf-epa-fixed.lua  2019-03-22 15:11:49.078873530 +0100
@@ -230,6 +230,12 @@
                 local w         = xscale * (a_urx - a_llx)
                 local h         = yscale * (a_ury - a_lly)
                 if subtype == "Link" then
+                    if not annotation.A and annotation.Dest then
+                        annotation.A = {}
+                        annotation.A.S = "GoTo"
+                        annotation.A.D = annotation.Dest
+                    end
+
                     local a = annotation.A
                     if not a then
                         report_link("missing link annotation")

Please consider applying a similar fix to the ConTeXt source code. Thanks!

I'm not sure I can attach the actual PDF as it's a recent Elsevier pub, but I
managed to manually craft one from the ConTeXt hello world using qpdf
--stream-data=uncompress --object-streams=disable and vim, and I'm attaching
that. The equation references work in PDF readers but stop working after
passing through \copypages[Hello-world-weird.pdf][][interaction=yes].

-- 
Tomáš Janoušek, a.k.a. Pivník, a.k.a. Liskni_si, http://work.lisk.in/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Hello-world-weird.pdf
Type: application/pdf
Size: 71105 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20190322/9416ac7a/attachment-0001.pdf>


More information about the ntg-context mailing list