ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* broken links in PDF included via \copypages (PoC fix attached)
@ 2019-03-22 14:35 Tomas Janousek
  2019-03-22 17:07 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Tomas Janousek @ 2019-03-22 14:35 UTC (permalink / raw)
  To: ntg-context

[-- Attachment #1: Type: text/plain, Size: 2190 bytes --]

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/

[-- Attachment #2: Hello-world-weird.pdf --]
[-- Type: application/pdf, Size: 71105 bytes --]

[-- Attachment #3: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: broken links in PDF included via \copypages (PoC fix attached)
  2019-03-22 14:35 broken links in PDF included via \copypages (PoC fix attached) Tomas Janousek
@ 2019-03-22 17:07 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2019-03-22 17:07 UTC (permalink / raw)
  To: Tomas Janousek, ntg-context

On 3/22/2019 3:35 PM, Tomas Janousek wrote:
> 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!

sure, it's a harmless patch and if it works ok ...

> 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].
> 
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-22 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 14:35 broken links in PDF included via \copypages (PoC fix attached) Tomas Janousek
2019-03-22 17:07 ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).