From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: pdf images in html export Date: Wed, 12 Nov 2014 15:04:36 -0600 Message-ID: References: <84tx24x1r6.fsf@tm6592.fritz.box> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b3a8c804a29f00507afbe3f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xof5k-0002Dh-Vm for emacs-orgmode@gnu.org; Wed, 12 Nov 2014 16:04:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xof5j-00059x-8n for emacs-orgmode@gnu.org; Wed, 12 Nov 2014 16:04:40 -0500 Received: from mail-la0-x236.google.com ([2a00:1450:4010:c03::236]:57991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xof5i-00059q-L0 for emacs-orgmode@gnu.org; Wed, 12 Nov 2014 16:04:39 -0500 Received: by mail-la0-f54.google.com with SMTP id gf13so129771lab.41 for ; Wed, 12 Nov 2014 13:04:36 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Andreas Leha Cc: emacs-orgmode --047d7b3a8c804a29f00507afbe3f Content-Type: text/plain; charset=UTF-8 On Nov 12, 2014 7:36 AM, "Andreas Leha" wrote: > > Hi Rainer, > > Rainer M Krug writes: > > Andreas Leha writes: > > > >> Hi Marco, > >> > >> Marco Wahl writes: > >>> Andreas Leha 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 > > --047d7b3a8c804a29f00507afbe3f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


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 <mar= cowahlsoft@gmail.com> writes:
> >>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> >>>
> >>>> how would I export an org file containing
> >>>>
> >>>>=C2=A0 =C2=A0[[file:./myimage.pdf]]
> >>>>
> >>>> to html so that a say png version myimage.pdf is inli= ned in the html
> >>>> which links to the pdf?
> >>>>
> >>>> I guess it should be possible to run imagemagick on a= ll pdf links during
> >>>> export somehow.
> >>>
> >>> You could introduce a relation of the pdf-filenames to th= e respective
> >>> thumb-filenames e.g. by using the suffix '_thumb'= .=C2=A0 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&= quot;)?
> >>>
> >>> Untested.=C2=A0 I just accidentially browsed that info pa= ge yesterday.
> >>>
> >>>
> >>
> >> Thanks for your thoughts.=C2=A0 I would like to automate all = of that.=C2=A0 So, I
> >> guess the first question is where to put code that would trig= ger the
> >> conversion and how to best detect links to pdfs.
> >
> > Well - this is coming again and again - but no solution out of th= e
> > 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 co= uld
> > be done by using ~(by-backend (html "graph.png") (latex= "graph.pdf") (t "graph.pdf"))~
> >
> > See [[http://orgmode.org/worg/org-contrib/ba= bel/languages/ob-doc-LaTeX.html#sec-4-3][work section ob-doc-LaTeX]] fo= r details.
> >
> > #+begin_src emacs-lisp
> >=C2=A0 =C2=A0(setq org-babel-latex-htlatex "htlatex") > >=C2=A0 =C2=A0(defmacro rmk-by-backend (&rest body)
> >=C2=A0 =C2=A0 =C2=A0`(case (if (boundp 'backend) (org-export-b= ackend-name backend) nil) ,@body))
> > #+end_src
> >
> > 2) To use svg image format, which is supported by both (although = has
> >=C2=A0 =C2=A0 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.=C2=A0 I am aware of how to *produce* graphics in diff= erent
> formats for different export backends.=C2=A0 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 produce= d
> but merely included via [[file:./some.pdf]].
>

If the names are always the same, could you just sed or repl= ace-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 thes= e into html (and
> odt) export without any user interaction.=C2=A0 So, I
> - do not want to write a source block just to produce the by-backend i= mage
> - 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
>
>

--047d7b3a8c804a29f00507afbe3f--