I am creating a Snap.svg app where users can basically add blocks and manipulate them then save it to a png. The blocks are all drawn in inches. I have code that calculates the device PPI and that is used to draw the blocks, it gets calculated to 96 PPI. This all works fine except that when I save the SVG to a PNG it is saved with 72 PPI so then the save PNG is larger than what it should be.
I am using this JavaScript Library to save the SVG as a PNG.
So my question is how do I get around this issue?
I am using this library: https://github.com/sampumon/SVG.toDataURL it works really well.
This is the code I ended up with that works for me.
// Get the SVG element
var svg = document.getElementById("design-1");
svg.toDataURL("image/png", {
callback : function(data) {
// Convert image to 'octet-stream' (Just a download, really)
var image = data.replace("image/png", "image/octet-stream");
window.location.href = image;
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.