emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andreas Leha <andreas.leha@med.uni-goettingen.de>
To: emacs-orgmode@gnu.org
Subject: Re: pdf images in html export
Date: Thu, 13 Nov 2014 19:10:31 +0000	[thread overview]
Message-ID: <oluegt6dihk.fsf@med.uni-goettingen.de> (raw)
In-Reply-To: m2tx2347fd.fsf@andrew.cmu.edu

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

  reply	other threads:[~2014-11-13 19:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=oluegt6dihk.fsf@med.uni-goettingen.de \
    --to=andreas.leha@med.uni-goettingen.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).