ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Link from a PDF to a  reference of an embedded PDF
@ 2023-07-20 14:25 Gerion Entrup
  2023-07-22  8:29 ` [NTG-context] " Pablo Rodriguez
  0 siblings, 1 reply; 7+ messages in thread
From: Gerion Entrup @ 2023-07-20 14:25 UTC (permalink / raw)
  To: ntg-context


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

Hi,

I found the "interaction" parameter in the documentation for
setupexternalfigure/externalfigure [1]. I, however do not quite
understand it. When embedding another PDF with this command, it seems to
be possible to include the references of the underlying PDF. It is
possible to link to them within the main context document? In [2], I
found something maybe related but it requires a tuc file.

Example:

inner.tex:
```
\starttext
\startsection[title=References, reference=sec:ref]
Some text
\placeformula[eq:foo]
\startformula
	1 + 2 = 3
\stopformula
or:
\startitemize[n]
	\item[item:bla] bla
	\item[item:blub] blub
\stopitemize

Find all references \in[sec:ref], \in[eq:foo], \in[item:bla], \in[item:blub].
\stoptext
```

outer.tex:
```
\starttext
\externalfigure[inner.pdf][width=10cm, interactive=reference]

Find all references \in[sec:ref], \in[eq:foo], \in[item:bla], \in[item:blub].
\stoptext
```

Can I somehow access the references of inner.tex from outer.tex?
For me, it is not that relevant, that the correct number is set, but the
interaction within the outer PDF should work, so clicking on the
reference should scroll to the correct content.

Background of my question: I normally do graphics in a separate PDFs.
Some graphics consists of source code together with a graphical
representation and I want to be able to link to single source code lines.


Gerion


[1] https://wiki.contextgarden.net/Command/setupexternalfigure
[2] https://wiki.contextgarden.net/References#References_to_an_external_file

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 495 bytes --]

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

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

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

* [NTG-context] Re: Link from a PDF to a reference of an embedded PDF
  2023-07-20 14:25 [NTG-context] Link from a PDF to a reference of an embedded PDF Gerion Entrup
@ 2023-07-22  8:29 ` Pablo Rodriguez
  2023-07-24 16:04   ` Gerion Entrup
  0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2023-07-22  8:29 UTC (permalink / raw)
  To: ntg-context

On 7/20/23 16:25, Gerion Entrup wrote:
> [...]
> Can I somehow access the references of inner.tex from outer.tex?
> For me, it is not that relevant, that the correct number is set, but the
> interaction within the outer PDF should work, so clicking on the
> reference should scroll to the correct content.

Hi Gerion,

not sure I’m getting your point right.

As such, one of the features of PDF are named destinations, such as in:

  https://www.pragma-ade.com/general/manuals/luametatex.pdf#%2381

I consider them as identifiers:

  https://wiki.contextgarden.net/Installation#Unix

If that could be what you might need, here is a sample.

First you have the destination file:

  \setupinteraction[state=start,
    focus=standard,
    prefix=n_,]
  \starttext
  \dorecurse{50}
    {a\footnote{b} }
  \startluacode
  luatex.wrapup(
    function()
      os.rename(tex.jobname .. ".pdf", "ba.pdf")
    end
  )
  \stopluacode
  \stoptext

Then you have calling file (with file:///):

  \setupinteraction[state=start,
    focus=standard]
  \def\MyURL#1{\goto{\tt#1}[url(#1)]}
  \starttext
  Link to other document: \MyURL{file:///path/ba.pdf\letterhash n_73}

  Link to the web:
 \MyURL{https://www.pragma-ade.com/general/manuals/luametatex.pdf#%2381}
  \stoptext

file:/// requires an absolute path. It might be handled right or not,
depending on your PDF viewer.

On Linux, Evince cannot open a file with named destination specified as
doc.pdf#destination (or doc.pdf#nameddest=destination). But it
understands file:///.

MuPDF-GL seems also not to handle named destinations, but it understands
file:/// too.

PDF.js (the default PDF viewer that comes with Firefox) handles named
destinations, but doesn‘t seem to understand file:/// as a link.

> Background of my question: I normally do graphics in a separate PDFs.
> Some graphics consists of source code together with a graphical
> representation and I want to be able to link to single source code lines.

I think it may be possible, but I don’t know how to generate named
destinations for source code lines.

Just in case it may help,

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

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

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

* [NTG-context] Re: Link from a PDF to a reference of an embedded PDF
  2023-07-22  8:29 ` [NTG-context] " Pablo Rodriguez
@ 2023-07-24 16:04   ` Gerion Entrup
  2023-07-24 17:13     ` Aditya Mahajan
  2023-07-25 15:38     ` Pablo Rodriguez
  0 siblings, 2 replies; 7+ messages in thread
From: Gerion Entrup @ 2023-07-24 16:04 UTC (permalink / raw)
  To: ntg-context


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

Hi Pablo,

> not sure I’m getting your point right.

Thank you for the detailed answer.
But I fear, I have not expressed myself precise enough.
The solution that you described does not directly fit to my setting.
I'll try to rephrase. Maybe it gets more clear then. I think, named
destinations could be a important part in the solution.

I'm do not know the structure of PDFs exactly, therefore some of my
terms might be wrong. I'll name the two things from now on the following
way:
- a destination: This is a defined position within a PDF document; so
  some position that a PDF viewer is able to jump to. In ConTeXt, you
  can set such a position most of the time with the "reference" keyword.
  In LaTeX, you use \label.
- a reference: This is a link that you can click on and cause the
  PDF viewer to jump/scroll to the linked destination. In ConTeXt, you
  can use \in to create a reference. In LaTeX, you use \ref.

The situation is that I have a PDF-document (inner.pdf) that defines
several destinations and I want to embed that document with
\externalfigure into another PDF-document (outer.pdf). My question is:
Is it possible to create references within the source code of outer.pdf
that correctly set a link to a destination that is defined in inner.pdf?
Asked in another way: Is is possible that \externalfigure can extract
the (maybe named) destinations of inner.pdf and translate them in such a
way, that I can use \in within the outer document to link to them.


Gerion

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 495 bytes --]

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

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

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

* [NTG-context] Re: Link from a PDF to a reference of an embedded PDF
  2023-07-24 16:04   ` Gerion Entrup
@ 2023-07-24 17:13     ` Aditya Mahajan
  2023-07-25 15:38     ` Pablo Rodriguez
  1 sibling, 0 replies; 7+ messages in thread
From: Aditya Mahajan @ 2023-07-24 17:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

On Mon, 24 Jul 2023, Gerion Entrup wrote:

> Hi Pablo,
> 
> > not sure I’m getting your point right.
> 
> Thank you for the detailed answer.
> But I fear, I have not expressed myself precise enough.
> The solution that you described does not directly fit to my setting.
> I'll try to rephrase. Maybe it gets more clear then. I think, named
> destinations could be a important part in the solution.
> 
> I'm do not know the structure of PDFs exactly, therefore some of my
> terms might be wrong. I'll name the two things from now on the following
> way:
> - a destination: This is a defined position within a PDF document; so
>   some position that a PDF viewer is able to jump to. In ConTeXt, you
>   can set such a position most of the time with the "reference" keyword.
>   In LaTeX, you use \label.
> - a reference: This is a link that you can click on and cause the
>   PDF viewer to jump/scroll to the linked destination. In ConTeXt, you
>   can use \in to create a reference. In LaTeX, you use \ref.
> 
> The situation is that I have a PDF-document (inner.pdf) that defines
> several destinations and I want to embed that document with
> \externalfigure into another PDF-document (outer.pdf). My question is:
> Is it possible to create references within the source code of outer.pdf
> that correctly set a link to a destination that is defined in inner.pdf?
> Asked in another way: Is is possible that \externalfigure can extract
> the (maybe named) destinations of inner.pdf and translate them in such a
> way, that I can use \in within the outer document to link to them.

According to https://wiki.contextgarden.net/Command/setupexternalfigure

\externalfigure[....][interaction=reference]

should keep all the references (you can also try interaction=all). Not sure how the references get mapped internally, so that they may be linked. 

Aditya

[-- Attachment #2: Type: text/plain, Size: 495 bytes --]

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

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

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

* [NTG-context] Re: Link from a PDF to a reference of an embedded PDF
  2023-07-24 16:04   ` Gerion Entrup
  2023-07-24 17:13     ` Aditya Mahajan
@ 2023-07-25 15:38     ` Pablo Rodriguez
  2023-07-26 17:47       ` Pablo Rodriguez
  1 sibling, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2023-07-25 15:38 UTC (permalink / raw)
  To: ntg-context

On 7/24/23 18:04, Gerion Entrup wrote:
> […]
> I'm do not know the structure of PDFs exactly, therefore some of my
> terms might be wrong. […]

Hi Gerion,

now I realize that my explanation was unnecesarily technical or not
focused on your needs.

My point was that if PDF as such doesn’t offer the capability, there is
no way to include it in ConTeXt (with PDF documents as output files).

> The situation is that I have a PDF-document (inner.pdf) that defines
> several destinations and I want to embed that document with
> \externalfigure into another PDF-document (outer.pdf). My question is:
> Is it possible to create references within the source code of outer.pdf
> that correctly set a link to a destination that is defined in inner.pdf?
> Asked in another way: Is is possible that \externalfigure can extract
> the (maybe named) destinations of inner.pdf and translate them in such a
> way, that I can use \in within the outer document to link to them.

I’m in a hurry, excuse my rash reply.

As far as I know (although I never used them), you can use \in with
references to other documents (I guess this is why you need the .tuc
file of the other document [to resolve the reference]).

In that case, you will have the reference number solved in your
document. As far as I know, there is no link for that.

Importing the document (with \externalfigure) has issues to preserve
internal links.

I hope it helps,

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

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

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

* [NTG-context] Re: Link from a PDF to a reference of an embedded PDF
  2023-07-25 15:38     ` Pablo Rodriguez
@ 2023-07-26 17:47       ` Pablo Rodriguez
  2023-07-27 15:20         ` Pablo Rodriguez
  0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2023-07-26 17:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 7/25/23 17:38, Pablo Rodriguez wrote:
> On 7/24/23 18:04, Gerion Entrup wrote:
>> […]
>
> I’m in a hurry, excuse my rash reply.

Sorry, Gerion, my reply yesterday was rushed (no skin condition).

The solution is already there (in the test files).

You have the file with the reference (save it as main.tex):

  \starttext
  \dorecurse{15}
    {\chapter[chap\recurselevel]{Chapter}}
  \stoptext

You have the file that reads the references from main.tuc and generates
the inter-document links:

  \setupinteraction[state=start]
  \starttext
  Links to each chapter using \type{main.tuc}:

  \startitemize[n, packed]
  \dorecurse{15}
    {\item Reference to \in[main::chap\recurselevel].}
  \stopitemize
  \stoptext

The real issue is that I couldn’t make it work with any PDF viewer I
have on Linux.

Either the viewer doesn’t detect the link (such as PDF.js), or it cannot
solve the target file (such as MuPDF and MuPDF-GL), or it cannot reach
destinations (such as Xpdf, Evince/Okular or SumatraPDF).

I take for granted that Acrobat will deal fine with this, since
destinations in links (GoToR) seem to be fine.

Of course, to confirm this, it should be tested with Acrobat.

Just in case it helps,

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

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

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

* [NTG-context] Re: Link from a PDF to a reference of an embedded PDF
  2023-07-26 17:47       ` Pablo Rodriguez
@ 2023-07-27 15:20         ` Pablo Rodriguez
  0 siblings, 0 replies; 7+ messages in thread
From: Pablo Rodriguez @ 2023-07-27 15:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 7/26/23 19:47, Pablo Rodriguez wrote:
> [...]
> The real issue is that I couldn’t make it work with any PDF viewer I
> have on Linux.
> [...]
> I take for granted that Acrobat will deal fine with this, since
> destinations in links (GoToR) seem to be fine.
Gerion, I was wrong, since I forgot enabling interaction in the main PDF
document to generate the targets (or named destinations).

  \setupinteraction[state=start, focus=standard]
  \starttext
  \dorecurse{15}
    {\chapter[chap\recurselevel]{Chapter}}
  \stoptext

The first line was missing yesterday.

After that (and with the ouput from the second sample from my previous
message
[https://mailman.ntg.nl/archives/list/ntg-context@ntg.nl/message/IEEGSAL636X32C3WWMO2KWKXMTIARRGZ/]),
Xpdf/Evince/Okular solve remote links fine.

MuPDF-GL cannot solve the file (even when full path is provided) and
PDF.js doesn’t even seem to care there might be a link.

I’m totally ignorant about what Acrobat and Edge/Chrome might do.

I hope this helps,

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

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

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

end of thread, other threads:[~2023-07-27 15:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 14:25 [NTG-context] Link from a PDF to a reference of an embedded PDF Gerion Entrup
2023-07-22  8:29 ` [NTG-context] " Pablo Rodriguez
2023-07-24 16:04   ` Gerion Entrup
2023-07-24 17:13     ` Aditya Mahajan
2023-07-25 15:38     ` Pablo Rodriguez
2023-07-26 17:47       ` Pablo Rodriguez
2023-07-27 15:20         ` Pablo Rodriguez

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