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

Viewbox min-y attribute has non-zero value #223

Closed povpie closed 1 year ago

povpie commented 1 year ago

Problem:10px are being added to the height of the svg

Here is a simple example (the problem is happening in all my conversions pdf to svg). The problem seems to arise because of the viewbox attribute for min-y is not zero (in the screenshot below it has value of =7.920007pt, but should be zero) command I'm using:dvisvgm --pdf -Oall -fwoff2

Additional question: (2) Is there an options to have the resulting svg with px dimensions instead of pt? I use the svg for display and not for printing. (3) I noted that the height attribute and the viewbox(height) usually gets converted to a strange approximation of the rounded/correct number. In the exemple below it get the value of 809.999993pt instead of 810pt, but the width is the correct 810pt

image

(svg with an overflown shape at the bottom but the same non-zero min-y problem)

canvapdfjustbg1

mgieseki commented 1 year ago

Problem:10px are being added to the height of the svg

Please upload a simple PDF file I can use to reproduce the problem.

Is there an options to have the resulting svg with px dimensions instead of pt?

No, but you can use option --zoom=-1 to remove the width and height attributes which results in an SVG that automatically adapts its size to the available space.

I noted that the height attribute and the viewbox(height) usually gets converted to a strange approximation of the rounded/correct number. In the exemple below it get the value of 809.999993pt instead of 810pt, but the width is the correct 810pt

Just use option --precision to reduce the number of decimal places, e.g. --precision=2 (or shorter: -d2).

povpie commented 1 year ago

justbgcolor.pdf

mgieseki commented 1 year ago

The computation of the PDF mediabox was buggy. I've fixed it with the upcoming patch.