mgieseki / dvisvgm

A fast DVI, EPS, and PDF to SVG converter
https://dvisvgm.de
GNU General Public License v3.0
295 stars 28 forks source link

PDF to SVG doesn's work when opacity used in PDF file #194

Closed zousiyu1995 closed 1 year ago

zousiyu1995 commented 1 year ago

For example, I used the tikz package to generate a PDF file, and the fill opacity was used in the tikz. Then, the command dvisvgm.exe --pdf -n main.pdf was used to convert the PDF file to an SVG file. I found the SVG file is empty. There is nothing!

The minimum working example of tikz code is shown as,

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}
        \fill [fill opacity=0.2, color=red] (0, 0) rectangle (1, 1);
    \end{tikzpicture}
\end{document}

The generated PDF file is shown as, image

But, I can use inkscape to convert this PDF file to an SVG file successfully. The inscape command is inkscape.exe main.pdf --pdf-poppler -o main.svg. The generated SVG is shown as, image

Why dvisvgm can't convert a PDF file with an opacity value?

mgieseki commented 1 year ago

What version of dvisvgm and Ghostscript do you use (see output of dvisvgm -V1)? In order to convert opacity values correctly, you need at least Ghostscript 9.52. Earlier versions don't provide PS operators to retrieve these values from PS/PDF files.

If you use GS 9.56.1, have a look at the FAQ to get information on how to handle the latest changes to its PDF interpreter.