[Nodejs] Some text broke about convert office to pdf

Product: @pdftron/pdfnet-node

Product Version: 10.6.0-4

I have a functionality to convert Office documents to PDF that needs to be implemented. However, I have encountered an issue where, after conversion, some text becomes larger and overlaps.

The original document opens normally, with consistent font sizes throughout.
I am using the font resource package(font.json) attached to the document and have not made any changes to the settings.

Sample Code

 const convertPDF = async () => {
      const inputPath = '<inputPath>';
      const outputPath = '<outputPath>';

      const pdfdoc = await PDFNet.PDFDoc.create();
      await pdfdoc.initSecurityHandler();

      await PDFNet.WebFontDownloader.setCustomWebFontURL(
        'file:///<path>'
      );
      await PDFNet.WebFontDownloader.enableDownloads();

      await PDFNet.Convert.toPdf(pdfdoc, inputPath);
      pdfdoc.save(outputPath, PDFNet.SDFDoc.SaveOptions.e_linearized);
    };

Orignal:
image

Converted:

Thank you for posting the incident to our forum. We will provide you with an update as soon as possible.

Hi JunHong,

Can you please provide the input file you are using and the output file you are generating so we can reproduce the issue on our end and investigate further?

Sure, Thanks for your support. Looking forward to hearing news well.

Input File:
doc_1.docx (31.8 KB)

Output File:
doc_1-convert-none.pdf (165.6 KB)

best regards,

Hi JunHong,

Apologies for the delay in response, converting with the latest 10.10 version on Windows, was able to generate a PDF that was close to the original input.

The main issue primarily appears to be the font. The best way to make sure the fonts are accurate is to embed the fonts in the docx file itself.
You can find info on how to do that here: