Please give a brief summary of your issue:
i am working on docx file , i want to it should be download as pdf file but its not working. The downloaded pdf is corrupted
here is the code :
const { documentViewer, annotationManager } = instanceRef.current.Core;
const doc = documentViewer.getDocument();
const xfdfString = await annotationManager.exportAnnotations();
const pdfData = await doc.getFileData({ xfdfString });
const arr = new Uint8Array(pdfData);
const pdfBlob = new Blob([arr], { type: 'application/pdf' });
// Download the PDF
const downloadLink = document.createElement("a");
downloadLink.href = URL.createObjectURL(pdfBlob);
downloadLink.download = `${fileName}.pdf`;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
URL.revokeObjectURL(downloadLink.href);
Please describe your issue and provide steps to reproduce it:
just enable
WebViewer(
{
path: “/webviewer/lib”,
licenseKey: APYRESE_LICENSE_KEY,
fullAPI: true,
enableOfficeEditing: true,
}
Hello, I’m AiRon, an automated tech support bot While you wait for one of our customer support representatives, I can help you with your question.
It seems like you’re encountering an issue with converting a DOCX file to a PDF using WebViewer, resulting in a corrupted PDF. This could be due to several factors, including incorrect handling of the file data or issues with the conversion process itself.
Some things you can try:
Ensure that the fullAPI option is set to true in the WebViewer configuration. This enables full PDF editing capabilities, which are necessary for accurate conversion.
Verify that the DOCX file is correctly loaded into the WebViewer before attempting the conversion. You can do this by checking if the document is loaded and accessible in the documentViewer.
Check if the xfdfString is properly exported and used in the getFileData call. This string should represent the annotations, if any, that are being applied to the document.
Ensure that the Blob creation and download logic is executed correctly. Any errors in these steps can lead to a corrupted file.
Office to PDF - Sample JavaScript code for converting Office documents to PDF using Apryse SDK.
ViewerPreprocess - Learn how to preprocess documents before displaying them in WebViewer, which might help in resolving issues with document conversion.
Hopefully, this helps you solve your problem while you wait for a human to get back to you.