[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] pdf images in html export
From: |
Andreas Leha |
Subject: |
Re: [O] pdf images in html export |
Date: |
Thu, 13 Nov 2014 19:10:31 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (darwin) |
Hi John,
Instructor account <address@hidden> 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
- [O] pdf images in html export, Andreas Leha, 2014/11/11
- Re: [O] pdf images in html export, John Hendy, 2014/11/12
- Re: [O] pdf images in html export, Andreas Leha, 2014/11/12
- Re: [O] pdf images in html export, John Hendy, 2014/11/12
- Re: [O] pdf images in html export, Eric S Fraga, 2014/11/13