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

convert to pdf and png files is incorrect #360

Closed
alan0526 opened this issue Nov 12, 2022 · 5 comments
Closed

convert to pdf and png files is incorrect #360

alan0526 opened this issue Nov 12, 2022 · 5 comments

Comments

@alan0526
Copy link

alan0526 commented Nov 12, 2022

svglib==1.4.1 installed via pip.
Python 3.9.2

I use svglib and reportlab to convert svg to pdf and png

Files
SVG bmw logo
PDF bmw logo.pdf
PNG bmw logo

Code
from svglib.svglib import svg2rlg
from reportlab.graphics import renderPDF, renderPM

def svg2pdf(svg_path, path):
drawing = svg2rlg(svg_path)
renderPDF.drawToFile(drawing, path)

def svg2fmt(svg_path, path, fmt="PNG", dpi=75):
drawing = svg2rlg(svg_path)
renderPM.drawToFile(drawing, path, fmt=fmt, dpi=dpi)

the converted pdf and png is not correct, both of them are look different.

@github-actions
Copy link

Thank you for raising your first issue! Your help to improve svglib is much appreciated!

@claudep
Copy link
Collaborator

claudep commented Nov 12, 2022

The PNG renderer is known to be limited, see also #299.

Could you tell us what make you think the PDF is not correct?
By the way, the method used to draw the logo is not optimal (circle with big stroke and dasharray), SVG has arcs that would be more appropriate and probably more precise.

@alan0526
Copy link
Author

I want to create a rotated bmw logo with svg, convert it to pdf, and send it to our chart supplier. it is used for camera quality test, so the accuracy is very import.
But after I convert this svg to pdf, the pattern looks different.
Thanks for you advice, I will try to use arcs to draw this pattern.

@alan0526
Copy link
Author

alan0526 commented Nov 14, 2022

here are files base on svg arcs(path)
PNG:
chart
SVG: chart
PDF: chart.pdf

svg and pdf seems correct, but the png arcs are not very smooth, is there any setting for png generator?
png dpi is set to 300

@claudep
Copy link
Collaborator

claudep commented Nov 14, 2022

You may try the alternate PNG renderer as in #299 (comment). Anyway, there is nothing svglib can do to fix that, therefore closing.

@claudep claudep closed this as completed Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants