I have an app where i store multiple PDFs as Data URIs ( data:application/pdf;base64,JVBERi0LjMKjf//// .... ==). I'm a bit puzzled about what's the right API to write those PDFs into a zip file. any pointers are appreciated.
If you have these PDFs in a binary form (Blob, Uint8Array, ArrayBuffer, etc) that would save a base64 decode operation. If not, you need to keep only the base64 part:
var uri = "data:application/pdf;base64,JVBERi0LjMKjf//// .... ==";
var idx = uri.indexOf('base64,') + 'base64,'.length; // or = 28 if you're sure about the prefix
var content = uri.substring(idx);
zip.file('a.pdf', content, {base64: true});
that was the solution. for now i'm using data uris but i might switch to store the base64. thank you.
Most helpful comment
If you have these PDFs in a binary form (Blob, Uint8Array, ArrayBuffer, etc) that would save a base64 decode operation. If not, you need to keep only the base64 part: