Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf Rendering of Elements depend on size specified by the svg-tag #160

Closed
dermoench42 opened this issue Oct 4, 2017 · 5 comments
Closed
Labels

Comments

@dermoench42
Copy link

I'm working with small graphics from traffic signs on maps. A perl script generates svg in paper format sizes which contains everything... When viewing svg everything looks as expected by the svg code. But trying cairosvg genPlan1.svg -o plan1.pdf (v 1.0.22) produces something else. The filled rectangles as background of the signs disappeared.
Then I figured out that if change the size of the svg by increasing width and height the missing backgrounds reappear in pdf. additionally decreasing the size makes more elements disappear.
What is going on?
But when I try the svg via inkscape, svg looks fine. exporting to pdf produces the same artefacts, missing backgrunds on signs. Inkscape saves pdf via cairo (1.14.8).

should look like:
plan1.pdf
but 10 times smaller:
plan1small.pdf
and 100 times smaller
plan1tiny.pdf
the svg
genPlan.zip

Is there something to adjust? the dpi option does't change anything. Is there a workaround?

ervin

@dermoench42
Copy link
Author

dermoench42 commented Oct 4, 2017

maybe this bug is related: https://bugs.freedesktop.org/show_bug.cgi?id=103071 BTW: why culling tiny Elements in Vektorgraphics ???

@dermoench42
Copy link
Author

Found a workaround:

  1. increase width and height in svg
  2. produce pdf via cairosvg in.svg -o out.pdf
  3. set papersize to width and height in pdf, e.g. via pdfjam --papersize '{width,height}' out.pdf

Ervin

@liZe liZe added the bug label Oct 5, 2017
@liZe
Copy link
Member

liZe commented Oct 5, 2017

Thank you for this very clear bug report.

As rendering seems to be good when generating PNGs and bad when generading PDFs, it's probably a bug in cairo. I'll try the patch included in bug 103071 and tell you if it helps.

@liZe
Copy link
Member

liZe commented Oct 5, 2017

I'll try the patch included in bug 103071 and tell you if it helps.

It fixes the problem! Wow. The patch is 2 days old, what an increadible timing.

BTW: why culling tiny Elements in Vektorgraphics ???

Cairo is full of optimizations you don't notice until (1) you hit a corner case when the optimization doesn't apply and have bad performance (2) you find a bug related to this optimization and fight against for days/months/years (see Kozea/WeasyPrint#278). 😄

@liZe liZe closed this as completed Oct 5, 2017
@dermoench42
Copy link
Author

Just to accomplish. This works with the current cairo snapshot 1.15.8 and the referenced patch, not with the widely used release versions 1.14.8-10.
For gentoo users I attached an ebuild and patch to be used in local overlay
cairo-1.15.8.ebuild.zip

Ervin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants