Skip to content

Upgrading from SVGLIB 0.8.1 to 0.9.2 Breaks - SVG Images Now Appear in Black and White #211

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

Closed
louis-gallo-cigna opened this issue Oct 8, 2019 · 4 comments
Labels

Comments

@louis-gallo-cigna
Copy link

(I first posted this issue last year, but decided not to upgrade until now.)

I have been using SVGLIB 0.8.1 for a few years now to incorporate existing color SVG chart images (created in R) into a PDF file. It has worked great.

When I try to upgrade to the latest SVGLIB 0.9.2, on a clean Windows machine with Python 3.6.1, my imported SVG images (which are fine themselves) now appear in black and white once imported in the PDF file.

I also get this error when executing SVGLIB commands:

Unable to find a suitable font for 'font-family:Nimbus Sans L'

I really would like to upgrade SVGLIB. What am I doing wrong here?

Simply upgrading to SVGLIB 0.9.2 causes the process of importing SVG images into PDFs to break. Downgrading back to 0.8.1 returns everything to normal.

from svglib.svglib import svg2rlg
my_canvas = canvas.Canvas(strLinuxMultiserverReportTemporaryFilename)
my_canvas.setPageSize((11.5*inch, 40*inch))
drawing = svg2rlg(image_path)
drawing.transform = (0.25,0,0,0.25,0,0)
intHeaderIndex = 2850
my_canvas.drawString(350, intHeaderIndex, 'System Performance Report')
renderPDF.draw(drawing, my_canvas, intCurrentColumnNumber, intCurrentRowNumber)
my_canvas.save()

I expect my nice color SVG files to be imported into the PDF file by SVGLIB and stay in color.

Any help is greatly appreciated.

Lou

@claudep
Copy link
Collaborator

claudep commented Oct 8, 2019

Without a sample SVG file, it is difficult to debug your issue. Could you please upload one?

@louis-gallo-cigna
Copy link
Author

louis-gallo-cigna commented Oct 8, 2019 via email

@louis-gallo-cigna
Copy link
Author

Sample SVG enclosed.
SVG-Generated-by-R-Version-3.4.4.zip

Thanks,

Lou

@claudep
Copy link
Collaborator

claudep commented Oct 8, 2019

Thanks, at least it allowed me to spot the issue. As CSS is now interpreted, it appears there is a precedence bug between the generic CSS in the defs part of the file and the styles included in the elements themselves.

@claudep claudep added the bug label Oct 8, 2019
claudep added a commit to claudep/svglib that referenced this issue Oct 8, 2019
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