HTML2PDF Conversion failed

Product: HTML2PDF

Product Version:

  • @pdftron/pdfnet-node@9.4.2
  • The latest available HTML2PDF on Mac M1
    MD5 (html2pdf_chromium.dylib) = 3b807f61e9bbf398be298a029ed9eca3

Please give a brief summary of your issue:
convert() is returning false, but logging no errors.

Please describe your issue and provide steps to reproduce it:

The following test program prints “Conversion failed. HTTP Code: 0”.

const { PDFNet } = require("@pdftron/pdfnet-node");
const path = require("path");

(async function run() {
  try {
    await PDFNet.initialize(process.env.PDFTRON_LICENSE_KEY);
    await PDFNet.HTML2PDF.setModulePath(path.dirname(require.resolve("@pdftron/pdfnet-node")));

    const html2pdf = await PDFNet.HTML2PDF.create();
    const doc = await PDFNet.PDFDoc.create();
    const html = '<html><body><h1>Heading</h1><p>Paragraph.</p></body></html>';
    const outputPath = './test-html2pdf.pdf';

    await html2pdf.insertFromHtmlString(html);

    if (!(await html2pdf.convert(doc))) {
      console.log('Conversion failed. HTTP Code: ' + await html2pdf.getHttpErrorCode());
      console.log(await html2pdf.getLog());
    } else {
      console.log('conversion succeeded, attempting to save')
      await, PDFNet.SDFDoc.SaveOptions.e_linearized);
  } catch (e) {

  console.log('Test Complete!');

html2pdf_chromium.dylib module is definitely executable.

Thank you for contacting us about this. Macs have additional security measures that might prevent you from running the module properly. Please make sure to allow the module under the “Privacy & Security” section in Settings.

On my side, I was able to run the HTML2PDF module after allowing from the Settings App.

Plese let me know if this works for you.

Thanks for the reply. I have had that problem before, and solved it by using spctl to add the file to allow it to execute. If I don’t do that, I get visible errors.

So, the problem here is something else.

What is the output you are seeing when you excecute the ./html2pdf_chromium.dylib directly using the Terminal?

You should see something like the following:

[0223/] No command line arguments detected, exiting.

Yes indeed,

[0223/] No command line arguments detected, exiting.

Are you able to execute the test code I provided?

I was able to run the code you provided on my end, and I can see that the conversion works as expected:

conversion succeeded, attempting to save
{ name: 'PDFDoc', id: '60000022cbd0' }
Test Complete!

We recently released a new version of the SDK. Could you please try upgrading to the latest version to see if that resolves the issue for you?

Thanks, but we found a workaround by replacing our HTML2PDF dependency with puppeteer.
Best regards.