I am using the docx library to generate a Word document (.docx) on the client side (Angular 9). I also want to be able to save the file as a pdf. I can get a base64 string/uint8array/blob, but I believe this is different for different types of documents. Because when I save the file as a pdf it is corrupted. Is there a way to convert the base64 string of a word doc to base64 string of pdf in JavaScript?
Packer.toBase64String(doc).then((string) => {
// Convert this bas64 encoded word string to base64 encoded pdf string
});
Alternatively, if we can convert the blob too, that is fine.
Packer.toBlob(doc).then((blob) => {
//convert word blob to pdf blob
saveAs(blob, 'example.pdf');
});