Lasciami finire questa domanda.
In primo luogo, la modalità Org non supporta alcuna funzione di visualizzazione inline pdf con se stessa. Tuttavia, è possibile modificare org-display-inline-images
per ottenere ciò che si desidera. Per prima cosa è necessario fare riferimento a questa risposta: Configuring emacs for showing fixed width inline images, che mi ha ispirato molto. Poi ho leggermente modificato la funzione, facendola supportare pdf, bmp display in org-mode. La mia funzione è in basso.
(setq image-file-name-extensions
(quote
("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm" "xpm" "pbm" "pgm" "ppm" "pnm" "svg" "pdf" "bmp")))
(setq org-image-actual-width 600)
(setq org-imagemagick-display-command "convert -density 600 \"%s\" -thumbnail \"%sx%s>\" \"%s\"")
(defun org-display-inline-images (&optional include-linked refresh beg end)
"Display inline images.
Normally only links without a description part are inlined, because this
is how it will work for export. When INCLUDE-LINKED is set, also links
with a description part will be inlined. This
can be nice for a quick
look at those images, but it does not reflect what exported files will look
like.
When REFRESH is set, refresh existing images between BEG and END.
This will create new image displays only if necessary.
BEG and END default to the buffer boundaries."
(interactive "P")
(unless refresh
(org-remove-inline-images)
(if (fboundp 'clear-image-cache) (clear-image-cache)))
(save-excursion
(save-restriction
(widen)
(setq beg (or beg (point-min)) end (or end (point-max)))
(goto-char beg)
(let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([^]\n]+?"
(substring (org-image-file-name-regexp) 0 -2)
"\\)\\]" (if include-linked "" "\\]")))
old file ov img)
(while (re-search-forward re end t)
(setq old (get-char-property-and-overlay (match-beginning 1)
'org-image-overlay)
file (expand-file-name
(concat (or (match-string 3) "") (match-string 4))))
(when (file-exists-p file)
(let ((file-thumb (format "%s%s_thumb.png" (file-name-directory file) (file-name-base file))))
(if (file-exists-p file-thumb)
(let ((thumb-time (nth 5 (file-attributes file-thumb 'string)))
(file-time (nth 5 (file-attributes file 'string))))
(if (time-less-p thumb-time file-time)
(shell-command (format org-imagemagick-display-command
file org-image-actual-width org-image-actual-width file-thumb) nil nil)))
(shell-command (format org-imagemagick-display-command
file org-image-actual-width org-image-actual-width file-thumb) nil nil))
(if (and (car-safe old) refresh)
(image-refresh (overlay-get (cdr old) 'display))
(setq img (save-match-data (create-image file-thumb)))
(when img
(setq ov (make-overlay (match-beginning 0) (match-end 0)))
(overlay-put ov 'display img)
(overlay-put ov 'face 'default)
(overlay-put ov 'org-image-overlay t)
(overlay-put ov 'modification-hooks
(list 'org-display-inline-remove-overlay))
(push ov org-inline-image-overlays))))))))))
La funzione utilizza convert file.pdf -thumbnail "400x400>" file_thumb.png
per generare una file_thumb nome miniatura nella cartella di sostituire sovrapposizione di PDF, e la forza org-mode per visualizzare pdf con file_thumb senza alcuna modifica al file org.
Inoltre, perché uso babel per generare immagini con python. Ho sempre bisogno che aggiorni il file _thumb, quindi aggiungo una condizione if per dire se questo file pollice esistesse o meno, e se il file pdf è cambiato ho bisogno di cambiare il file thumb allo stesso tempo ... e così via!
Spero che possa aiutarti.
fonte
2014-12-26 03:34:35
Correzione: Emacs non è in grado di eseguire il rendering di file PDF (credo che si possa scrivere una cosa simile in Elisp, ma sarebbe molto lavoro, per un risultato molto deludente poiché sarebbe lento). Può visualizzare file PDF utilizzando strumenti esterni, quindi, in effetti, dovrebbe essere possibile rendere Org in grado di visualizzare tali documenti collegati in linea. – Stefan
@Stefan Hai ragione. Uno strumento esterno esegue il rendering effettivo. Intendevo dire che visualizza i file PDF fuori dalla scatola (almeno su linux). – Malabarba