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
Export as svg / pdf? #176
Comments
I've had success saving files as .pdf |
@tinaramsey87 Can you give me a example for saving as pdf please ? |
Sorry it has taken me so long to reply! var base64toBlob = function(b64Data, contentType, sliceSize) {
contentType = contentType || '';
sliceSize = sliceSize || 512;
var byteCharacters = atob(b64Data);
var byteArrays = [];
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
var slice = byteCharacters.slice(offset, offset + sliceSize);
var byteNumbers = new Array(slice.length);
for (var i=0; i<slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
var blob = new Blob(byteArrays, {type: contentType});
return blob;
} fileData will be the base64 string (but you might already be working with a blob, so you may not need that step). contentType must be 'application/pdf' to save as a pdf. Here's my code to save: |
Many thank's for reply. I will check that rapidly |
OK let me know if that works for you! |
Hi @tinaramsey87 @skyhirider @jmcollin78 please i'm using FileSaver but it works for me just with .txt can u provide me your solution that works even for pfd or jpg ... |
@migorman the code I posted should work. If you have code that you're trying to use post it and I can maybe help... |
Finally I gave up without success. I finally use the old good method: generate pdf server side and download it. |
Oh, @migorman , you need to declare contentType as 'application/pdf'. I don't see where you've declared it so make sure you're doing that somewhere. You can just do: |
@tinaramsey87 yeah sure contentType was a variable in my case and it toooks 'application/pdf and diffrent other values,i have found a solution thanks for your help :) |
I am glad it worked for you :) |
Bottom line is FileSaver don't have something called "Save as" it only has "Save blob" Think we can close this. |
Can FileSaver save as .svg and .pdf ?
There isn't a svg example on the demo page but there are topics about svg here so I am unsure.
The text was updated successfully, but these errors were encountered: