svg2pdf incorrect width and height output -

Open
#415 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Reproduce the issue with the provided SVG dimensions and the svg2pdf call, then inspect svg2pdf's dpi handling and the UNITS['pt'] conversion mentioned in the report. Compare the generated PDF dimensions with the source dimensions and determine the expected unit behavior; done when the behavior is corrected or clearly documented with a regression check.

Written by the indexing model from the issue text.

Description

I have an svg file with attributes
width="1929" height="2572"
which I created as a bytestring or as a file

cairosvg.svg2pdf(svgstr, write_to="svg_0.pdf")
svg_0.pdf comes out with 'width': 1446.75, 'height': 1929

I looked thru the code and I noticed that the svg2pdf(dpi=96) default, cairosvg UNITS['pt'] will scale to 72dpi.
If my svg has no mention of dpi, or units, why should it be assumed that one wishes to scale ?

fix to the unit assumption is to just pass dpi=72

Dominant language
Python
Stars
959
Forks
172
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Kozea/CairoSVG

All issues in Kozea/CairoSVG

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.