* pdf images in html export
@ 2014-11-12 0:48 Andreas Leha
2014-11-12 8:27 ` Marco Wahl
0 siblings, 1 reply; 14+ messages in thread
From: Andreas Leha @ 2014-11-12 0:48 UTC (permalink / raw)
To: emacs-orgmode
Hi all,
how would I export an org file containing
[[file:./myimage.pdf]]
to html so that a say png version myimage.pdf is inlined in the html
which links to the pdf?
I guess it should be possible to run imagemagick on all pdf links during
export somehow.
Any help highly appreciated.
Many thanks,
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 0:48 pdf images in html export Andreas Leha
@ 2014-11-12 8:27 ` Marco Wahl
2014-11-12 9:30 ` Andreas Leha
0 siblings, 1 reply; 14+ messages in thread
From: Marco Wahl @ 2014-11-12 8:27 UTC (permalink / raw)
To: emacs-orgmode
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> how would I export an org file containing
>
> [[file:./myimage.pdf]]
>
> to html so that a say png version myimage.pdf is inlined in the html
> which links to the pdf?
>
> I guess it should be possible to run imagemagick on all pdf links during
> export somehow.
You could introduce a relation of the pdf-filenames to the respective
thumb-filenames e.g. by using the suffix '_thumb'. Before the export
the conversion tool would create the thumbs.
The org-file could reference the data as
[[file:./myimage.pdf][file:myimage_thumb.png]]
See the info page (info "(org)Images in HTML export")?
Untested. I just accidentially browsed that info page yesterday.
HTH, Marco
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 8:27 ` Marco Wahl
@ 2014-11-12 9:30 ` Andreas Leha
2014-11-12 13:09 ` Rainer M Krug
0 siblings, 1 reply; 14+ messages in thread
From: Andreas Leha @ 2014-11-12 9:30 UTC (permalink / raw)
To: emacs-orgmode
Hi Marco,
Marco Wahl <marcowahlsoft@gmail.com> writes:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> how would I export an org file containing
>>
>> [[file:./myimage.pdf]]
>>
>> to html so that a say png version myimage.pdf is inlined in the html
>> which links to the pdf?
>>
>> I guess it should be possible to run imagemagick on all pdf links during
>> export somehow.
>
> You could introduce a relation of the pdf-filenames to the respective
> thumb-filenames e.g. by using the suffix '_thumb'. Before the export
> the conversion tool would create the thumbs.
>
> The org-file could reference the data as
>
> [[file:./myimage.pdf][file:myimage_thumb.png]]
>
> See the info page (info "(org)Images in HTML export")?
>
> Untested. I just accidentially browsed that info page yesterday.
>
>
Thanks for your thoughts. I would like to automate all of that. So, I
guess the first question is where to put code that would trigger the
conversion and how to best detect links to pdfs.
Thanks,
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 9:30 ` Andreas Leha
@ 2014-11-12 13:09 ` Rainer M Krug
2014-11-12 13:36 ` Andreas Leha
0 siblings, 1 reply; 14+ messages in thread
From: Rainer M Krug @ 2014-11-12 13:09 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2216 bytes --]
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> Hi Marco,
>
> Marco Wahl <marcowahlsoft@gmail.com> writes:
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> how would I export an org file containing
>>>
>>> [[file:./myimage.pdf]]
>>>
>>> to html so that a say png version myimage.pdf is inlined in the html
>>> which links to the pdf?
>>>
>>> I guess it should be possible to run imagemagick on all pdf links during
>>> export somehow.
>>
>> You could introduce a relation of the pdf-filenames to the respective
>> thumb-filenames e.g. by using the suffix '_thumb'. Before the export
>> the conversion tool would create the thumbs.
>>
>> The org-file could reference the data as
>>
>> [[file:./myimage.pdf][file:myimage_thumb.png]]
>>
>> See the info page (info "(org)Images in HTML export")?
>>
>> Untested. I just accidentially browsed that info page yesterday.
>>
>>
>
> Thanks for your thoughts. I would like to automate all of that. So, I
> guess the first question is where to put code that would trigger the
> conversion and how to best detect links to pdfs.
Well - this is coming again and again - but no solution out of the
box. There are effectively two approaches:
1) Macro to change properties according to backend used.
One usage is changing the file name extension according to the
backend. This is implemented as a simplified macro below. This could
be done by using ~(by-backend (html "graph.png") (latex "graph.pdf") (t "graph.pdf"))~
See [[http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec-4-3][work section ob-doc-LaTeX]] for details.
#+begin_src emacs-lisp
(setq org-babel-latex-htlatex "htlatex")
(defmacro rmk-by-backend (&rest body)
`(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
#+end_src
2) To use svg image format, which is supported by both (although has
it's drawbacks: slow rendering of the html, need to run external programs upon compilation)
So the first might be the modst feasible option.
Rainer
>
> Thanks,
> Andreas
>
>
>
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 13:09 ` Rainer M Krug
@ 2014-11-12 13:36 ` Andreas Leha
2014-11-12 14:13 ` Rainer M Krug
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Andreas Leha @ 2014-11-12 13:36 UTC (permalink / raw)
To: emacs-orgmode
Hi Rainer,
Rainer M Krug <Rainer@krugs.de> writes:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Marco,
>>
>> Marco Wahl <marcowahlsoft@gmail.com> writes:
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> how would I export an org file containing
>>>>
>>>> [[file:./myimage.pdf]]
>>>>
>>>> to html so that a say png version myimage.pdf is inlined in the html
>>>> which links to the pdf?
>>>>
>>>> I guess it should be possible to run imagemagick on all pdf links during
>>>> export somehow.
>>>
>>> You could introduce a relation of the pdf-filenames to the respective
>>> thumb-filenames e.g. by using the suffix '_thumb'. Before the export
>>> the conversion tool would create the thumbs.
>>>
>>> The org-file could reference the data as
>>>
>>> [[file:./myimage.pdf][file:myimage_thumb.png]]
>>>
>>> See the info page (info "(org)Images in HTML export")?
>>>
>>> Untested. I just accidentially browsed that info page yesterday.
>>>
>>>
>>
>> Thanks for your thoughts. I would like to automate all of that. So, I
>> guess the first question is where to put code that would trigger the
>> conversion and how to best detect links to pdfs.
>
> Well - this is coming again and again - but no solution out of the
> box. There are effectively two approaches:
>
> 1) Macro to change properties according to backend used.
>
> One usage is changing the file name extension according to the
> backend. This is implemented as a simplified macro below. This could
> be done by using ~(by-backend (html "graph.png") (latex "graph.pdf") (t "graph.pdf"))~
>
> See [[http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec-4-3][work section ob-doc-LaTeX]] for details.
>
> #+begin_src emacs-lisp
> (setq org-babel-latex-htlatex "htlatex")
> (defmacro rmk-by-backend (&rest body)
> `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
> #+end_src
>
> 2) To use svg image format, which is supported by both (although has
> it's drawbacks: slow rendering of the html, need to run external programs upon compilation)
>
> So the first might be the modst feasible option.
>
Thanks for this. I am aware of how to *produce* graphics in different
formats for different export backends. I use your first approach,
which I think is the better solution.
Here, I am after a solution, that works on images that are not produced
but merely included via [[file:./some.pdf]].
I think there should be the possibility to include these into html (and
odt) export without any user interaction. So, I
- do not want to write a source block just to produce the by-backend image
- do not want to change the link manually
- do not want to run the converter manually
I am pretty sure this should be achievable with standard orgmode tools
(like filters, export hooks, or anything).
Since 'this is coming again and again' it seems a non-esoteric task.
And as there is 'no solution out of the box', I assume(d) that somebody has
written these filters already.
Regards,
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 13:36 ` Andreas Leha
@ 2014-11-12 14:13 ` Rainer M Krug
2014-11-13 12:21 ` Instructor account
2014-11-12 19:03 ` Charles C. Berry
2014-11-12 21:04 ` John Hendy
2 siblings, 1 reply; 14+ messages in thread
From: Rainer M Krug @ 2014-11-12 14:13 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3687 bytes --]
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> Hi Rainer,
>
> Rainer M Krug <Rainer@krugs.de> writes:
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Hi Marco,
>>>
>>> Marco Wahl <marcowahlsoft@gmail.com> writes:
>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>
>>>>> how would I export an org file containing
>>>>>
>>>>> [[file:./myimage.pdf]]
>>>>>
>>>>> to html so that a say png version myimage.pdf is inlined in the html
>>>>> which links to the pdf?
>>>>>
>>>>> I guess it should be possible to run imagemagick on all pdf links during
>>>>> export somehow.
>>>>
>>>> You could introduce a relation of the pdf-filenames to the respective
>>>> thumb-filenames e.g. by using the suffix '_thumb'. Before the export
>>>> the conversion tool would create the thumbs.
>>>>
>>>> The org-file could reference the data as
>>>>
>>>> [[file:./myimage.pdf][file:myimage_thumb.png]]
>>>>
>>>> See the info page (info "(org)Images in HTML export")?
>>>>
>>>> Untested. I just accidentially browsed that info page yesterday.
>>>>
>>>>
>>>
>>> Thanks for your thoughts. I would like to automate all of that. So, I
>>> guess the first question is where to put code that would trigger the
>>> conversion and how to best detect links to pdfs.
>>
>> Well - this is coming again and again - but no solution out of the
>> box. There are effectively two approaches:
>>
>> 1) Macro to change properties according to backend used.
>>
>> One usage is changing the file name extension according to the
>> backend. This is implemented as a simplified macro below. This could
>> be done by using ~(by-backend (html "graph.png") (latex "graph.pdf") (t "graph.pdf"))~
>>
>> See [[http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec-4-3][work section ob-doc-LaTeX]] for details.
>>
>> #+begin_src emacs-lisp
>> (setq org-babel-latex-htlatex "htlatex")
>> (defmacro rmk-by-backend (&rest body)
>> `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
>> #+end_src
>>
>> 2) To use svg image format, which is supported by both (although has
>> it's drawbacks: slow rendering of the html, need to run external programs upon compilation)
>>
>> So the first might be the modst feasible option.
>>
>
> Thanks for this. I am aware of how to *produce* graphics in different
> formats for different export backends. I use your first approach,
> which I think is the better solution.
I agree with you.
>
> Here, I am after a solution, that works on images that are not produced
> but merely included via [[file:./some.pdf]].
OK - understood.
>
> I think there should be the possibility to include these into html (and
> odt) export without any user interaction. So, I
> - do not want to write a source block just to produce the by-backend image
> - do not want to change the link manually
> - do not want to run the converter manually
I agree with you - this *should* be possible, and I assume not to
difficult to implement. In my opinion, this should also work out of the
box when enabling it e.g. via a property.
>
> I am pretty sure this should be achievable with standard orgmode tools
> (like filters, export hooks, or anything).
Yes - it should be.
>
> Since 'this is coming again and again' it seems a non-esoteric task.
> And as there is 'no solution out of the box', I assume(d) that somebody has
> written these filters already.
Unfortunately not...
Cheers,
Rainer
>
> Regards,
> Andreas
>
>
>
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 13:36 ` Andreas Leha
2014-11-12 14:13 ` Rainer M Krug
@ 2014-11-12 19:03 ` Charles C. Berry
2014-11-12 20:50 ` Andreas Leha
2014-11-12 21:04 ` John Hendy
2 siblings, 1 reply; 14+ messages in thread
From: Charles C. Berry @ 2014-11-12 19:03 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
On Wed, 12 Nov 2014, Andreas Leha wrote:
> Hi Rainer,
>
> Rainer M Krug <Rainer@krugs.de> writes:
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Hi Marco,
>>>
>>> Marco Wahl <marcowahlsoft@gmail.com> writes:
>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>
>>>>> how would I export an org file containing
>>>>>
>>>>> [[file:./myimage.pdf]]
>>>>>
>>>>> to html so that a say png version myimage.pdf is inlined in the html
>>>>> which links to the pdf?
>>>>>
[deleted]
Andreas replying:
>
> Thanks for this. I am aware of how to *produce* graphics in different
> formats for different export backends. I use your first approach,
> which I think is the better solution.
>
> Here, I am after a solution, that works on images that are not produced
> but merely included via [[file:./some.pdf]].
>
> I think there should be the possibility to include these into html (and
> odt) export without any user interaction. So, I
> - do not want to write a source block just to produce the by-backend image
> - do not want to change the link manually
> - do not want to run the converter manually
>
> I am pretty sure this should be achievable with standard orgmode tools
> (like filters, export hooks, or anything).
>
> Since 'this is coming again and again' it seems a non-esoteric task.
> And as there is 'no solution out of the box', I assume(d) that somebody has
> written these filters already.
>
What you want is a custom `hyperlink type'.
I don't know if anyone has written this, but the machinery is in
`org-add-link-type'. You user would enter (say)
[[pdf:./some.pdf]]
and clicking on it would open the file (assuming a proper FOLLOW argument)
and exporting would handle all the behind the scenes tinkering to
create png's or whatever is needed for the backend in question (assuming
a suitable EXPORT argument).
The docstring for `org-add-link-type' has details. Also there is a worked
example and more instructions at
(info "(org) Adding hyperlink types")
HTH,
Chuck
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 19:03 ` Charles C. Berry
@ 2014-11-12 20:50 ` Andreas Leha
0 siblings, 0 replies; 14+ messages in thread
From: Andreas Leha @ 2014-11-12 20:50 UTC (permalink / raw)
To: emacs-orgmode
Hi Chuck,
"Charles C. Berry" <ccberry@ucsd.edu> writes:
> On Wed, 12 Nov 2014, Andreas Leha wrote:
>
>> Hi Rainer,
>>
>> Rainer M Krug <Rainer@krugs.de> writes:
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> Hi Marco,
>>>>
>>>> Marco Wahl <marcowahlsoft@gmail.com> writes:
>>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>>
>>>>>> how would I export an org file containing
>>>>>>
>>>>>> [[file:./myimage.pdf]]
>>>>>>
>>>>>> to html so that a say png version myimage.pdf is inlined in the html
>>>>>> which links to the pdf?
>>>>>>
>
> [deleted]
>
> Andreas replying:
>
>>
>> Thanks for this. I am aware of how to *produce* graphics in different
>> formats for different export backends. I use your first approach,
>> which I think is the better solution.
>>
>> Here, I am after a solution, that works on images that are not produced
>> but merely included via [[file:./some.pdf]].
>>
>> I think there should be the possibility to include these into html (and
>> odt) export without any user interaction. So, I
>> - do not want to write a source block just to produce the by-backend image
>> - do not want to change the link manually
>> - do not want to run the converter manually
>>
>> I am pretty sure this should be achievable with standard orgmode tools
>> (like filters, export hooks, or anything).
>>
>> Since 'this is coming again and again' it seems a non-esoteric task.
>> And as there is 'no solution out of the box', I assume(d) that somebody has
>> written these filters already.
>>
>
> What you want is a custom `hyperlink type'.
>
> I don't know if anyone has written this, but the machinery is in
> `org-add-link-type'. You user would enter (say)
>
> [[pdf:./some.pdf]]
>
> and clicking on it would open the file (assuming a proper FOLLOW
> argument) and exporting would handle all the behind the scenes
> tinkering to create png's or whatever is needed for the backend in
> question (assuming a suitable EXPORT argument).
>
> The docstring for `org-add-link-type' has details. Also there is a
> worked example and more instructions at
>
> (info "(org) Adding hyperlink types")
>
> HTH,
It does. Thanks for this hint. This comes close to what I am after.
But -- at the risk of being persistent -- this still requires me to
change the orgmode document, if only to change [[file:...]] to
[[pdf:...]].
I still think that this use case is so common, that it would be nice
for org support of the original document.
Maybe that even deserves first class support in org. One could imagine
some customizeable variable org-transcode-images-on-export, that would
know a list of supported image formats for each export backend and try
to run imagemagick on the others to transcode them into exportable
images linking to the original.
Given that this does not exist (and given that it won't be me
implementing that) I was hoping for a custom (hacky?) solution just for
pdfs.
Given that this appears not to exist either, I will probably follow your
suggestion of adding a custom link type.
Thanks,
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 13:36 ` Andreas Leha
2014-11-12 14:13 ` Rainer M Krug
2014-11-12 19:03 ` Charles C. Berry
@ 2014-11-12 21:04 ` John Hendy
2014-11-12 21:32 ` Andreas Leha
2 siblings, 1 reply; 14+ messages in thread
From: John Hendy @ 2014-11-12 21:04 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3473 bytes --]
On Nov 12, 2014 7:36 AM, "Andreas Leha" <andreas.leha@med.uni-goettingen.de>
wrote:
>
> Hi Rainer,
>
> Rainer M Krug <Rainer@krugs.de> writes:
> > Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> >
> >> Hi Marco,
> >>
> >> Marco Wahl <marcowahlsoft@gmail.com> writes:
> >>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> >>>
> >>>> how would I export an org file containing
> >>>>
> >>>> [[file:./myimage.pdf]]
> >>>>
> >>>> to html so that a say png version myimage.pdf is inlined in the html
> >>>> which links to the pdf?
> >>>>
> >>>> I guess it should be possible to run imagemagick on all pdf links
during
> >>>> export somehow.
> >>>
> >>> You could introduce a relation of the pdf-filenames to the respective
> >>> thumb-filenames e.g. by using the suffix '_thumb'. Before the export
> >>> the conversion tool would create the thumbs.
> >>>
> >>> The org-file could reference the data as
> >>>
> >>> [[file:./myimage.pdf][file:myimage_thumb.png]]
> >>>
> >>> See the info page (info "(org)Images in HTML export")?
> >>>
> >>> Untested. I just accidentially browsed that info page yesterday.
> >>>
> >>>
> >>
> >> Thanks for your thoughts. I would like to automate all of that. So, I
> >> guess the first question is where to put code that would trigger the
> >> conversion and how to best detect links to pdfs.
> >
> > Well - this is coming again and again - but no solution out of the
> > box. There are effectively two approaches:
> >
> > 1) Macro to change properties according to backend used.
> >
> > One usage is changing the file name extension according to the
> > backend. This is implemented as a simplified macro below. This could
> > be done by using ~(by-backend (html "graph.png") (latex "graph.pdf") (t
"graph.pdf"))~
> >
> > See [[
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec-4-3][work
section ob-doc-LaTeX]] for details.
> >
> > #+begin_src emacs-lisp
> > (setq org-babel-latex-htlatex "htlatex")
> > (defmacro rmk-by-backend (&rest body)
> > `(case (if (boundp 'backend) (org-export-backend-name backend) nil)
,@body))
> > #+end_src
> >
> > 2) To use svg image format, which is supported by both (although has
> > it's drawbacks: slow rendering of the html, need to run external
programs upon compilation)
> >
> > So the first might be the modst feasible option.
> >
>
> Thanks for this. I am aware of how to *produce* graphics in different
> formats for different export backends. I use your first approach,
> which I think is the better solution.
>
> Here, I am after a solution, that works on images that are not produced
> but merely included via [[file:./some.pdf]].
>
If the names are always the same, could you just sed or replace-regexp all
*.pdf for *.png?
Not elegant, but works easily/now, and takes less time than this thread :)
John
> I think there should be the possibility to include these into html (and
> odt) export without any user interaction. So, I
> - do not want to write a source block just to produce the by-backend image
> - do not want to change the link manually
> - do not want to run the converter manually
>
> I am pretty sure this should be achievable with standard orgmode tools
> (like filters, export hooks, or anything).
>
> Since 'this is coming again and again' it seems a non-esoteric task.
> And as there is 'no solution out of the box', I assume(d) that somebody
has
> written these filters already.
>
> Regards,
> Andreas
>
>
[-- Attachment #2: Type: text/html, Size: 5125 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 21:04 ` John Hendy
@ 2014-11-12 21:32 ` Andreas Leha
2014-11-12 22:59 ` John Hendy
2014-11-13 9:11 ` Eric S Fraga
0 siblings, 2 replies; 14+ messages in thread
From: Andreas Leha @ 2014-11-12 21:32 UTC (permalink / raw)
To: emacs-orgmode
Hi John,
John Hendy <jw.hendy@gmail.com> writes:
> On Nov 12, 2014 7:36 AM, "Andreas Leha"
> <andreas.leha@med.uni-goettingen.de> wrote:
>>
>> Hi Rainer,
>>
>> Rainer M Krug <Rainer@krugs.de> writes:
>> > Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>> >
>> >> Hi Marco,
>> >>
>> >> Marco Wahl <marcowahlsoft@gmail.com> writes:
>> >>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>> >>>
>> >>>> how would I export an org file containing
>> >>>>
>> >>>> [[file:./myimage.pdf]]
>> >>>>
>> >>>> to html so that a say png version myimage.pdf is inlined in the
> html
>> >>>> which links to the pdf?
>> >>>>
>> >>>> I guess it should be possible to run imagemagick on all pdf
> links during
>> >>>> export somehow.
>> >>>
>> >>> You could introduce a relation of the pdf-filenames to the
> respective
>> >>> thumb-filenames e.g. by using the suffix '_thumb'. Before the
> export
>> >>> the conversion tool would create the thumbs.
>> >>>
>> >>> The org-file could reference the data as
>> >>>
>> >>> [[file:./myimage.pdf][file:myimage_thumb.png]]
>> >>>
>> >>> See the info page (info "(org)Images in HTML export")?
>> >>>
>> >>> Untested. I just accidentially browsed that info page yesterday.
>> >>>
>> >>>
>> >>
>> >> Thanks for your thoughts. I would like to automate all of that.
> So, I
>> >> guess the first question is where to put code that would trigger
> the
>> >> conversion and how to best detect links to pdfs.
>> >
>> > Well - this is coming again and again - but no solution out of the
>> > box. There are effectively two approaches:
>> >
>> > 1) Macro to change properties according to backend used.
>> >
>> > One usage is changing the file name extension according to the
>> > backend. This is implemented as a simplified macro below. This
> could
>> > be done by using ~(by-backend (html "graph.png") (latex
> "graph.pdf") (t "graph.pdf"))~
>> >
>> > See
> [
> [http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec-4-3][work section
> ob-doc-LaTeX]] for details.
>> >
>> > #+begin_src emacs-lisp
>> > (setq org-babel-latex-htlatex "htlatex")
>> > (defmacro rmk-by-backend (&rest body)
>> > `(case (if (boundp 'backend) (org-export-backend-name backend)
> nil) ,@body))
>> > #+end_src
>> >
>> > 2) To use svg image format, which is supported by both (although
> has
>> > it's drawbacks: slow rendering of the html, need to run external
> programs upon compilation)
>> >
>> > So the first might be the modst feasible option.
>> >
>>
>> Thanks for this. I am aware of how to *produce* graphics in
> different
>> formats for different export backends. I use your first approach,
>> which I think is the better solution.
>>
>> Here, I am after a solution, that works on images that are not
> produced
>> but merely included via [[file:./some.pdf]].
>>
>
> If the names are always the same, could you just sed or replace-regexp
> all *.pdf for *.png?
>
I could. And I would need to do the conversion manually as well.
But I still want the pdfs to go into the LaTeX export.
> Not elegant, but works easily/now, and takes less time than this
> thread :)
Hint taken. Such feature is apparently not too important for most.
[...]
Thanks,
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 21:32 ` Andreas Leha
@ 2014-11-12 22:59 ` John Hendy
2014-11-13 9:11 ` Eric S Fraga
1 sibling, 0 replies; 14+ messages in thread
From: John Hendy @ 2014-11-12 22:59 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
On Wed, Nov 12, 2014 at 3:32 PM, Andreas Leha
<andreas.leha@med.uni-goettingen.de> wrote:
> Hi John,
>
> John Hendy <jw.hendy@gmail.com> writes:
>> On Nov 12, 2014 7:36 AM, "Andreas Leha"
>> <andreas.leha@med.uni-goettingen.de> wrote:
>>>
>>> Hi Rainer,
>>>
>>> Rainer M Krug <Rainer@krugs.de> writes:
>>> > Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
[snip]
>>> Here, I am after a solution, that works on images that are not
>> produced
>>> but merely included via [[file:./some.pdf]].
>>>
>>
>> If the names are always the same, could you just sed or replace-regexp
>> all *.pdf for *.png?
>>
>
> I could. And I would need to do the conversion manually as well.
Agreed, and sounds like you're already considering ImageMagick for
this. I've used it similarly with more or less good results. I always
have to look up the right options, play with one file a bunch to get a
nice blend of size/quality, and also have learned to use whatever
option (either convert or mogrify) saves a *new* version, as I didn't
get at first that one of those edits the file in-place!
> But I still want the pdfs to go into the LaTeX export.
>
>> Not elegant, but works easily/now, and takes less time than this
>> thread :)
>
> Hint taken. Such feature is apparently not too important for most.
>
Yeah, that was mostly tongue in cheek... I'd be doing the exact same
thing (looking for a better way to automate/process, even though
technically it's simply changing the the contents of
\includegraphics{something} or <img src = "something" />. Thus, to the
last point, I'd generate .pdfs, leave the LaTeX version alone, convert
some other image format for html, and then sed/replace-regexp on the
html to change all image.pdf -> image.png.
John
> [...]
>
> Thanks,
> Andreas
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 21:32 ` Andreas Leha
2014-11-12 22:59 ` John Hendy
@ 2014-11-13 9:11 ` Eric S Fraga
1 sibling, 0 replies; 14+ messages in thread
From: Eric S Fraga @ 2014-11-13 9:11 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
On Wednesday, 12 Nov 2014 at 21:32, Andreas Leha wrote:
> Hi John,
>
> John Hendy <jw.hendy@gmail.com> writes:
[...]
>> If the names are always the same, could you just sed or replace-regexp
>> all *.pdf for *.png?
>
> I could. And I would need to do the conversion manually as well.
>
> But I still want the pdfs to go into the LaTeX export.
If the conversions have been done, a simple function that changes all
occurrences of [[file:xxx.pdf] to [[file:xxx.png] on export can be
written and added to org-export-before-processing-hook. This function
could also, if you're adventurous, do the conversion if the png isn't
there already...
That hook passes the export backend so that you will know if you are
exporting to LaTeX or HTML.
--
: Eric S Fraga (0xFFFCF67D), Emacs 24.4.1, Org release_8.3beta-558-g83d8a2
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-12 14:13 ` Rainer M Krug
@ 2014-11-13 12:21 ` Instructor account
2014-11-13 19:10 ` Andreas Leha
0 siblings, 1 reply; 14+ messages in thread
From: Instructor account @ 2014-11-13 12:21 UTC (permalink / raw)
To: Rainer M Krug; +Cc: Andreas Leha, emacs-orgmode
I think the best thing to do here is create a derived backend. Filters
could work to, but you will have to parse the img link, get the pdf
file, convert it and replace the path in the link.
with a derived backend you can get that a little more directly like
this. This code block works on a minimal example for me. I guess you
could make a little function to do the last line, and put this all in
your init files and it would work. This is a very unsophisticated format
function that does not check for attributes like width or height or link
descriptions... but, I get a png image in the html export of an org file
with a pdf image ;)
#+BEGIN_SRC emacs-lisp
(defun my-link-format (link contents info)
(let ((type (org-element-property :type link))
(path (org-element-property :path link)))
(cond
((and
(string= type "file")
(string-match "\.pdf" path))
(shell-command
(format
"convert %s %s"
path
(replace-regexp-in-string "\.pdf" ".png" path)))
(format "<img src=\"%s\">" (replace-regexp-in-string "\.pdf" ".png" path)))
;; anything else, we just do the regular thing
(t
(org-html-link link contents info)))))
(org-export-define-derived-backend 'my-html 'html
:translate-alist '((link . my-link-format)))
(browse-url (org-export-to-file 'my-html "custom-link.html"))
#+END_SRC
Rainer M Krug <Rainer@krugs.de> writes:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Rainer,
>>
>> Rainer M Krug <Rainer@krugs.de> writes:
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> Hi Marco,
>>>>
>>>> Marco Wahl <marcowahlsoft@gmail.com> writes:
>>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>>
>>>>>> how would I export an org file containing
>>>>>>
>>>>>> [[file:./myimage.pdf]]
>>>>>>
>>>>>> to html so that a say png version myimage.pdf is inlined in the html
>>>>>> which links to the pdf?
>>>>>>
>>>>>> I guess it should be possible to run imagemagick on all pdf links during
>>>>>> export somehow.
>>>>>
>>>>> You could introduce a relation of the pdf-filenames to the respective
>>>>> thumb-filenames e.g. by using the suffix '_thumb'. Before the export
>>>>> the conversion tool would create the thumbs.
>>>>>
>>>>> The org-file could reference the data as
>>>>>
>>>>> [[file:./myimage.pdf][file:myimage_thumb.png]]
>>>>>
>>>>> See the info page (info "(org)Images in HTML export")?
>>>>>
>>>>> Untested. I just accidentially browsed that info page yesterday.
>>>>>
>>>>>
>>>>
>>>> Thanks for your thoughts. I would like to automate all of that. So, I
>>>> guess the first question is where to put code that would trigger the
>>>> conversion and how to best detect links to pdfs.
>>>
>>> Well - this is coming again and again - but no solution out of the
>>> box. There are effectively two approaches:
>>>
>>> 1) Macro to change properties according to backend used.
>>>
>>> One usage is changing the file name extension according to the
>>> backend. This is implemented as a simplified macro below. This could
>>> be done by using ~(by-backend (html "graph.png") (latex "graph.pdf") (t "graph.pdf"))~
>>>
>>> See [[http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec-4-3][work section ob-doc-LaTeX]] for details.
>>>
>>> #+begin_src emacs-lisp
>>> (setq org-babel-latex-htlatex "htlatex")
>>> (defmacro rmk-by-backend (&rest body)
>>> `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
>>> #+end_src
>>>
>>> 2) To use svg image format, which is supported by both (although has
>>> it's drawbacks: slow rendering of the html, need to run external programs upon compilation)
>>>
>>> So the first might be the modst feasible option.
>>>
>>
>> Thanks for this. I am aware of how to *produce* graphics in different
>> formats for different export backends. I use your first approach,
>> which I think is the better solution.
>
> I agree with you.
>
>>
>> Here, I am after a solution, that works on images that are not produced
>> but merely included via [[file:./some.pdf]].
>
> OK - understood.
>
>>
>> I think there should be the possibility to include these into html (and
>> odt) export without any user interaction. So, I
>> - do not want to write a source block just to produce the by-backend image
>> - do not want to change the link manually
>> - do not want to run the converter manually
>
> I agree with you - this *should* be possible, and I assume not to
> difficult to implement. In my opinion, this should also work out of the
> box when enabling it e.g. via a property.
>
>>
>> I am pretty sure this should be achievable with standard orgmode tools
>> (like filters, export hooks, or anything).
>
> Yes - it should be.
>
>>
>> Since 'this is coming again and again' it seems a non-esoteric task.
>> And as there is 'no solution out of the box', I assume(d) that somebody has
>> written these filters already.
>
> Unfortunately not...
>
> Cheers,
>
> Rainer
>
>>
>> Regards,
>> Andreas
>>
>>
>>
--
-----------------------------------
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pdf images in html export
2014-11-13 12:21 ` Instructor account
@ 2014-11-13 19:10 ` Andreas Leha
0 siblings, 0 replies; 14+ messages in thread
From: Andreas Leha @ 2014-11-13 19:10 UTC (permalink / raw)
To: emacs-orgmode
Hi John,
Instructor account <instructor@andrew.cmu.edu> writes:
> I think the best thing to do here is create a derived backend. Filters
> could work to, but you will have to parse the img link, get the pdf
> file, convert it and replace the path in the link.
>
> with a derived backend you can get that a little more directly like
> this. This code block works on a minimal example for me. I guess you
> could make a little function to do the last line, and put this all in
> your init files and it would work. This is a very unsophisticated format
> function that does not check for attributes like width or height or link
> descriptions... but, I get a png image in the html export of an org file
> with a pdf image ;)
>
> #+BEGIN_SRC emacs-lisp
> (defun my-link-format (link contents info)
> (let ((type (org-element-property :type link))
> (path (org-element-property :path link)))
> (cond
> ((and
> (string= type "file")
> (string-match "\.pdf" path))
> (shell-command
> (format
> "convert %s %s"
> path
> (replace-regexp-in-string "\.pdf" ".png" path)))
> (format "<img src=\"%s\">" (replace-regexp-in-string "\.pdf" ".png" path)))
> ;; anything else, we just do the regular thing
> (t
> (org-html-link link contents info)))))
>
> (org-export-define-derived-backend 'my-html 'html
> :translate-alist '((link . my-link-format)))
>
>
> (browse-url (org-export-to-file 'my-html "custom-link.html"))
> #+END_SRC
That is really nice. From all solutions so far this seems to be the one
to pursue. I will look into that.
[...]
Thanks,
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-11-13 19:15 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-12 0:48 pdf images in html export Andreas Leha
2014-11-12 8:27 ` Marco Wahl
2014-11-12 9:30 ` Andreas Leha
2014-11-12 13:09 ` Rainer M Krug
2014-11-12 13:36 ` Andreas Leha
2014-11-12 14:13 ` Rainer M Krug
2014-11-13 12:21 ` Instructor account
2014-11-13 19:10 ` Andreas Leha
2014-11-12 19:03 ` Charles C. Berry
2014-11-12 20:50 ` Andreas Leha
2014-11-12 21:04 ` John Hendy
2014-11-12 21:32 ` Andreas Leha
2014-11-12 22:59 ` John Hendy
2014-11-13 9:11 ` Eric S Fraga
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).