ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* issue with interaction=all and \insertpages
@ 2020-09-20 16:29 Pablo Rodriguez
  2020-09-23  9:59 ` Taco Hoekwater
  0 siblings, 1 reply; 4+ messages in thread
From: Pablo Rodriguez @ 2020-09-20 16:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
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] 4+ messages in thread

* Re: issue with interaction=all and \insertpages
  2020-09-20 16:29 issue with interaction=all and \insertpages Pablo Rodriguez
@ 2020-09-23  9:59 ` Taco Hoekwater
  2020-09-23 15:06   ` Pablo Rodriguez
  0 siblings, 1 reply; 4+ messages in thread
From: Taco Hoekwater @ 2020-09-23  9:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Pablo,

> On 20 Sep 2020, at 18:29, Pablo Rodriguez <oinos@gmx.es> 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




___________________________________________________________________________________
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] 4+ messages in thread

* Re: issue with interaction=all and \insertpages
  2020-09-23  9:59 ` Taco Hoekwater
@ 2020-09-23 15:06   ` Pablo Rodriguez
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Rodriguez @ 2020-09-23 15:06 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________
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] 4+ messages in thread

* Re: issue with interaction=all and \insertpages
       [not found] <mailman.1.1600682401.26760.ntg-context@ntg.nl>
@ 2020-09-23  4:34 ` Andres Conrado Montoya Acosta
  0 siblings, 0 replies; 4+ messages in thread
From: Andres Conrado Montoya Acosta @ 2020-09-23  4:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1761 bytes --]

I am also following this question and some related ones by Pablo with great
interest, and it seems to me that it's falling through the cracks... so, I
am asking again: is it possible to preserve links correctly when imposing /
inserting pdf pages in ConTeXt?

El lun., 21 sept. 2020 a las 5:00, <ntg-context-request@ntg.nl> escribió:

>    3. issue with interaction=all and \insertpages (Pablo Rodriguez)
>
> 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
>

Thanks for your attention.
-- 
Andrés Conrado Montoya
http://chiquitico.org

[-- Attachment #1.2: Type: text/html, Size: 2799 bytes --]

[-- Attachment #2: 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] 4+ messages in thread

end of thread, other threads:[~2020-09-23 15:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20 16:29 issue with interaction=all and \insertpages Pablo Rodriguez
2020-09-23  9:59 ` Taco Hoekwater
2020-09-23 15:06   ` Pablo Rodriguez
     [not found] <mailman.1.1600682401.26760.ntg-context@ntg.nl>
2020-09-23  4:34 ` Andres Conrado Montoya Acosta

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).