I’m trying to convert an HTML file to PDF using PdfTron and lambda I created on AWS,
I installed PDF TRON and HTML2PDF libraries in layers and I get an error message: Failed to search html2pdf.so
My code looks like this:
function async convertHtmlToPdf(htmlString) {
await PDFNet.initialize(trialkey);
await PDFNet.HTML2PDF.setModulePath(‘/opt/nodejs/node_modules/@pdftron/pdfnet-node/lib/html2pdf/’);
if (!(wait PDFNet.HTML2PDF.isModuleAvailable())) {
throw new Error(‘HTML2PDF module is not available.’);
}
Hello! Thank you so much for reaching out. Are you able to grab the full error that is being logged? This should include the version number and some other relevant diagnostic information.
A couple other things:
- Are you able to double check that the appropriate dependencies are installed by following this page: Linux.dependencies | Apryse Documentation
- I noticed a small typo in your isModuleAvailable check, there should be an 'a" in front of the ‘wait’ keyword.
If this doesn’t solve the error, are you able to confirm which architecture and version for the SDK that is in use? Such as ARM, or x64 and 10.12, or 10.11 etc.
Thank you for your patience.
Hi , my code is written in nodejs:18 in AWS Lambda, Compatible architectures x86_64
PDF TRON Installed in layers version 10.12.0
the full error is:
2024-09-17T07:20:59.794Z 6c650f24-ee39-48f8-b9d1-1dafd757b9ca ERROR An error occurred: Error: HTML2PDF module is not available.
at convertHtmlToPdf (/var/task/index.js:80:19)
at async exports.handler (/var/task/index.js:24:23)
The problem seems to be in the line of code: await PDFNet.HTML2PDF.setModulePath(‘/opt/nodejs/node_modules/@pdftron/pdfnet-node/lib/html2pdf/’);
The file html2pdf.so is in LAYERS under the nodejs/html2pdf folder
when i change to await PDFNet.HTML2PDF.setModulePath(‘@pdftron/nodejs/html2pdf/’); i get error:
2024-09-19T10:21:13.946Z undefined ERROR Uncaught Exception {
“errorType”: “Runtime.ImportModuleError”,
“errorMessage”: “Error: Cannot find module ‘@pdftron/pdfnet-node’\nRequire stack:\n- /var/task/index.js\n- /var/runtime/index.mjs”,
“stack”: [
“Runtime.ImportModuleError: Error: Cannot find module ‘@pdftron/pdfnet-node’”,
“Require stack:”,
“- /var/task/index.js”,
“- /var/runtime/index.mjs”,
" at _loadUserApp (file:///var/runtime/index.mjs:1087:17)“,
" at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)”,
" at async start (file:///var/runtime/index.mjs:1282:23)“,
" at async file:///var/runtime/index.mjs:1288:1”
]
}