issue with interaction=all and \insertpages
![](https://secure.gravatar.com/avatar/5955e8e90611e77ccbfc7721b6112027.jpg?s=120&d=mm&r=g)
Dear list, I have the following sample: \setuplayout[page] \setupinteraction [state=start, color=, contrastcolor=, focus=standard] \enabledirectives[references.border=red] \setupexternalfigures[interaction=all, method=pdf] \setupinteractionscreen[option={portrait, paper}] \starttext %~ \insertpages[http://gaceta.rsme.es/abrir.php?id=1495][width=0pt] \insertpages[GacRSocMatEsp.pdf][width=0pt] \stoptext I have some issues with it. 1. For some strange reason, the first \insertpages command with a remote file cannot deal with the interaction from the file (no internal or external links). 2. The local file includes internal destinations to page parts. After imposition, destinations to page for internal links cannot reach the page parts as links in original document do. 3. Even external links are converted. On last page, https://www.cs.umb.edu/~offner/files/pi.pdf is rewritten as https://www.cs.umb.edu/õffner/files/pi.pdf. Besides the rewritten link, would it be possible that links are added so they reach the same destinations as their source PDF document? Many thanks for your help, Pablo -- http://www.ousia.tk
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Hi Pablo,
On 20 Sep 2020, at 18:29, Pablo Rodriguez
wrote: Dear list,
I have the following sample:
\setuplayout[page] \setupinteraction [state=start, color=, contrastcolor=, focus=standard] \enabledirectives[references.border=red] \setupexternalfigures[interaction=all, method=pdf] \setupinteractionscreen[option={portrait, paper}] \starttext %~ \insertpages[http://gaceta.rsme.es/abrir.php?id=1495][width=0pt] \insertpages[GacRSocMatEsp.pdf][width=0pt] \stoptext
I have some issues with it.
Yes, various issues indeed.
1. For some strange reason, the first \insertpages command with a remote file cannot deal with the interaction from the file (no internal or external links).
The problem with that one is that the url does not end in .pdf, which means context is too late in discovering that it really is a pdf. The \setupexternalfigures[interaction=all, method=pdf] doesn’t help enough, it seems. I could get it to ‘work’ with \insertpages[http://gaceta.rsme.es/abrir.php?id=1495&=f.pdf][width=0pt] but I assume that is a bug, and that ConTeXt should have listened to the method=pdf.
2. The local file includes internal destinations to page parts. After imposition, destinations to page for internal links cannot reach the page parts as links in original document do.
Interaction=all actually converts the internal links in the pdf into a normal ConTeXt layer. In that process, the target is lost, and all the links are converted to page number references. That is a limitation of the current (MkIV) implementation. In lmtx it should be possible to be smarter about this, but it needs an extension to ConTeXt.
3. Even external links are converted. On last page, https://www.cs.umb.edu/~offner/files/pi.pdf is rewritten as https://www.cs.umb.edu/õffner/files/pi.pdf.
This is a bug for sure. In the process of converting the link to the ConTeXt layer (it actually becomes a \button) it is necessary to convert some of the characters in the PDF link into ’TeX’ by escaping some special characters like \ and #, or the \button would fail. ConTeXt does the TeX escaping by prepending a backslash. While that works fine for most of the special characters, it fails for a few others. It fails for ~ and ^ because \~ and \^ are accent commands, not character escapes. The replacer should be using \texttilde and \textcircumflex for those. It also fails for \, but that character is rejected in URIs anyway. === However, in fact, most of the special characters don't need escaping for inclusion at all any more (at least not with the standard catcodes). The only ones that do need escaping to please ConTeXt are: # % \ { } (of those, only # and % can actually happen in a wellformed URI) The other ‘old’ special characters: ~ $ ^ & _ | do not need to be escaped by ConTeXt at all any more, \button handles them just fine. (also, bare ^ and | are disallowed in a wellformed URI) Summarized: In link_uri() in lpdf-epa.lua, the line url = escapetex(url) can be replaced with url = string.gsub(url,"#", "\\#") url = string.gsub(url,"%%", "\\%%") if only correct URIs need to be considered. Otherwise (if bad URIs should be processed correctly), then a special escapeurl() is needed in char-tex.lua to make sure that besides the prefixed backslashes for the list of escaped characters, there is this override: ^ => “\textcircumflex " ~ => “\texttitlde " \ => “\textbackslash “ In that case, the \ handling needs fixing as well, because ConTeXt currently rejects URIs with backslashes in them. This latter option may be wise, because I know from experience that there are many bad URIs in external PDFs. Best wishes, Taco
![](https://secure.gravatar.com/avatar/5955e8e90611e77ccbfc7721b6112027.jpg?s=120&d=mm&r=g)
On 9/23/20 11:59 AM, Taco Hoekwater wrote:
Hi Pablo,
Hi Taco, many thanks for your extensive reply explaining the three issues reported. [...]
2. The local file includes internal destinations to page parts. After imposition, destinations to page for internal links cannot reach the page parts as links in original document do.
Interaction=all actually converts the internal links in the pdf into a normal ConTeXt layer. In that process, the target is lost, and all the links are converted to page number references. That is a limitation of the current (MkIV) implementation. In lmtx it should be possible to be smarter about this, but it needs an extension to ConTeXt.
If this is possible with LMTX, it would be a great feature to have. Many thanks for your help, Pablo -- http://www.ousia.tk
participants (2)
-
Pablo Rodriguez
-
Taco Hoekwater