From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: pdf images in html export Date: Thu, 13 Nov 2014 19:10:31 +0000 Message-ID: References: <84tx24x1r6.fsf@tm6592.fritz.box> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XozrL-0003uB-VF for emacs-orgmode@gnu.org; Thu, 13 Nov 2014 14:15:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XozrF-0006yx-SD for emacs-orgmode@gnu.org; Thu, 13 Nov 2014 14:15:11 -0500 Received: from plane.gmane.org ([80.91.229.3]:35038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XozrF-0006v4-Kd for emacs-orgmode@gnu.org; Thu, 13 Nov 2014 14:15:05 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XozrD-0007Mi-Qp for emacs-orgmode@gnu.org; Thu, 13 Nov 2014 20:15:03 +0100 Received: from cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net ([81.102.136.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 13 Nov 2014 20:15:03 +0100 Received: from andreas.leha by cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 13 Nov 2014 20:15:03 +0100 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: emacs-orgmode@gnu.org Hi John, Instructor account 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 "" (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