sampumon / svg.todataurl Goto Github PK
View Code? Open in Web Editor NEWGives your SVG elements the missing toDataURL function (same as Canvas has)
Gives your SVG elements the missing toDataURL function (same as Canvas has)
The resulting image from this is tiny-- is there any way to control what the png size is? The SVG I'm starting with is fairly large.
With the current approach, SVG content that exceeds the browsers size limitations for data: URIs will not be rendered to the internal canvas. In such cases, always using canvg would have to be enforced.
This has been working great in Chrome for me, but not in Firefox-- the exported image size is 0,0. Has anyone else had any issues with this?
While testing the demo on IE 11.0.9 I got security Error.
SVG.toDataURL does not work for imported fonts. Even though the actual <svg>
tag next to the image, displays the font perfectly fine.
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
export as a plain funciton and not a method
This works wonderfully with smaller svg images, but I'm using this to export an svg and share on facebook. My SVG file is 614,588 characters long. When I try to export this, I get the error message "Can't export! Maybe your browser doesn't support SVG in img element...."
However, when I try it with a smaller SVG image, it does work. Is there a limit to the svg size for this??
Special character like öäüß in SVG-text-nodes will cause a XML error 5617 when using window.btoa for base64 encoding.
console:
SVG.toDataURL: using native renderer for png export. THIS MIGHT FAIL.
SVG.toDataURL: using standard XMLSerializer.serializeToString
SVG.toDataURL: using window.btoa for base64 encoding
XML5617: Ungültiges XML-Zeichen. Zeile: 9, Spalte 163
Forcing a custom encoding using the base64.js will work in actual FF, Chrome & Opera, but throws a SecurityError in IE in line 95 of svg_todataurl.js.
console:
SVG.toDataURL: using native renderer for png export. THIS MIGHT FAIL.
SVG.toDataURL: using standard XMLSerializer.serializeToString
SVG.toDataURL: using custom base64 encoder
SVG.toDataURL: exported image size: 0,0
SCRIPT5022: SecurityError Datei: svg_todataurl.js, Zeile: 95, Spalte: 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.