Navigation Menu

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

useCSS option failing #47

Closed
josecolella opened this issue Aug 1, 2017 · 4 comments
Closed

useCSS option failing #47

josecolella opened this issue Aug 1, 2017 · 4 comments

Comments

@josecolella
Copy link

Hello,
First of all I wanted to thank you for this. Makes using pdfkit much easier. I am receiving the following message when trying to convert an svg with styles to a pdf document:

SVGtoPDF: useCSS option can only be used for SVG elements in compatible browsers

I have tried to use your demo site and it works perfectly with the useCSS option.

Here is a link to the gist. https://gist.github.com/josecolella/adc2e835a84a148b441b37453b54f064

@jokester
Copy link

jokester commented Sep 13, 2017

Experienced a similar problem. It turns out that in Chrome, someEmbedElement.getSVGDocument().firstElementChild may be a object that don't instanceof SVGElement (yet still supports getComputedStyle). So useCSS is forced to be false on such elements. See this for a minimal example.

This only happens in Chrome (at least not in Firefox). It looks more likely a browser bug to me though.

jokester added a commit to jokester/SVG-to-PDFKit that referenced this issue Sep 14, 2017
When using this fix, the call site must ensure availability of
getComputedStyle, and pass in a compatible SVGElement instance.

for background, see:
alafr#47 (comment)
@jokester
Copy link

Found a workaroud for previous comment: we can fix its prototype manually

Object.setPrototype(SVGSVGElement.prototype, theAlienObject);
SVGtoPDF(doc, theAlienObject, 0, 0, { useCSS: true });

@josecolella
Copy link
Author

Thanks @jokester. Works now

@dingchao-95
Copy link

Hi i was wondering if anyone could help with my issue, i'm facing the same thing as @josecolella , here is my issue with documented details : #97
@jokester @alafr

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

No branches or pull requests

4 participants