>> David Masterson <[email protected]> writes:
>>
>>> Org Need: A new hyperlink that will be treated as HTTP in most export
>>> cases except when exporting to Latex/PDF. In that case, it would do the
>>> following:
>>> + create a temporary directory (if doesn't already exist)
>>> + wget (or...) the file to the temporary directory
>>> + change the link to a file: link in the export process
>>> + remove the temporary directory when done exporting
IIUC, you just need linked image files and pdfs on a remote system to be
downloaded and inlined as figures in LaTeX/PDF export?
Org can already do this for remote image files with normal https links.
By default, however, it only inlines local PDFs linked by =file:= links.
But this behavior can be changed by customizing
`org-latex-inline-image-rules' to include PDFs in the "https" group.
#+begin_elisp
(custom-set-variables
'(org-latex-inline-image-rules
'(("file"
.
"\\.\\(?:eps\\|jp\\(?:e?g\\)\\|p\\(?:df\\|gf\\|ng\\|s\\)\\|svg\\|tikz\\)\\'")
("https"
.
"\\.\\(?:eps\\|jp\\(?:e?g\\)\\|p\\(?:df\\|gf\\|ng\\|s\\)\\|svg\\|tikz\\)\\'"))))
;; Add PDFs here: ^^^^^
#+end_elisp
With this enabled, I can export a PDF with another PDF inlined as a
figure simply by adding a normal https link, just as for image files,
e.g.:
#+name: fig:understanding-slr
#+caption: Understanding sea-level change (source: Met Office)
https://www.metoffice.gov.uk/binaries/content/assets/metofficegovuk/pdf/research/climate-science/ukcp/profsea/sea-level-infographic-1.pdf
That raises the question if you even need a special link type or other
custom code at all...?
Of course, with this customization, if you want to give actual links to
PDFs /without/ inlining them, as one often does, you cannot use the raw
URL as it will result in an image; you need to add a description to the
link. So a custom link type makes sense if you want to mix links to PDFs
and inlined figures of PDFs in the same document.
It seems like it should be easy to make a custom link by using the
existing functionality of `org-latex--inline-image',
`org-export-link-localise' and `org-export-link--remote-local-copy', but
I haven't actually found out how to make it work. The
`org-export-link--remote-local-copy' includes the comment: "TODO work
this into ol.el as a link parameter, say :download." That might be
helpful in the future.
Regards,
Christian
PS. I guess `org-export-link-localise' will need to be renamed with
"-ize" after the policy clarification on American English.