shg / org-inline-pdf.el

Inline PDF previewing for Org
GNU General Public License v3.0
48 stars 8 forks source link

White rectangle instead of image when #+attr_org or #+attr_html is used #3

Closed mattiasdrp closed 2 years ago

mattiasdrp commented 2 years ago

I generated a pdf file with LaTeX:

    \documentclass{standalone}
    \usepackage{tikz}
    \usetikzlibrary{positioning}

    \begin{document}

      \begin{tikzpicture}
        \node(a) {A};
        \node[right=of a] (b) {B};
      \end{tikzpicture}
    \end{document}

The PDF file is ok, I can convert it to SVG with pdf2svg but in org it just appears as a big white rectangle (whereas another pdf file like the github logo is fine):

#+CAPTION: Test
#+NAME:   Test
[[./img/ab.pdf]]
[[./img/github.pdf]]

image

But

#+CAPTION: Test
#+NAME:   Test
#+ATTR_HTML: :width 100px
#+ATTR_ORG: :width 100px
[[./img/ab.pdf]]
[[./img/github.pdf]]

image

shg commented 2 years ago

Sorry for not responding earlier. In my environment, both #+ATTR_HTML and #+ATTR_ORG work as expected. Based on the fact that the logo PDF is properly shown, I suspect the PDF you have generated with LaTex might be the cause. Could you post ab.pdf here?

mattiasdrp commented 2 years ago

Sure, here it is (you can generate it with the LaTeX code I provided above)

ab.pdf

shg commented 2 years ago

I don't see any issue with the PDF. It is shown properly here, with or without the width attribute setting. What happens if you place the the svg file mannually converted from the PDF instead?

mattiasdrp commented 2 years ago

I have the same error when importing the svg

Org version : Org mode version 9.4.6 (9.4.6-798-g738759.dirty-elpaplus @ /home/mattias/.emacs.d/elpa/org-plus-contrib-20210929/)

shg commented 2 years ago

Ok, so the SVG converted from the PDF made with LaTeX does not work but the SVG converted from the logo PDF works, correct? Could you check whether the two SVG files are shown inline without loading org-inline-pdf? Inline displaying of SVG is done by Emacs itself.

mattiasdrp commented 2 years ago

The SVG from the logo is displayed whereas ab.svg is displayed as a white rectangle.

shg commented 2 years ago

So the issue is outside of org-inline-mode software. You need to figure out why your Emacs is not displaying the SVG converted from the LaTeX file. Once you fix it, org-inline-pdf will work as well.

One thing you may want check is whether your Emacs shows SVG converted using pdftocairo instead of pdf2svg. You can install the command by installing poppler-utils (Debian/Ubuntu) or poppler (homebrew).