Edited Office file save to pdf

How are you.
I am gonna save edited docx file to pdf.
how to do this?
const doc = docViewer.getDocument();
const xfdfString = await annotManager.exportAnnotations();
const data = await doc.getFileData({
// saves the document with annotations in it
const arr = new Uint8Array(data);
const type = ‘application/pdf’
const blob = new Blob([arr], { type });
const file = new File([blob], new Date().getTime().toString() + “.pdf”, { type, lastModified: new Date().getTime() });
const urls = await uploadFiles([file], “documents”);

this is my current code.
but when I use this for pdf file, all’re working fine.
but for docx file, after save it and opens again, shows error.
“not found pdf header”
so I think I should convert edited buffer and save to pdf.
how could I handle this?


Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


Hi Lyu
Thanks for contacting us for support. Can I know what version are you using? Maybe you can set loadAsPDF: true when you load docx file.
Let me know if this works for you.


hi @jhou
works like a charm.
thanks a lot,
isn’t there any other option?

Hi Lyu
It should be the simplest option to implement. Or you can check this https://www.pdftron.com/documentation/windows/guides/features/office/convert-office/ to do the conversion?