简体   繁体   English

node.js PDFTron HTML 到 PDF 转换失败

[英]node.js PDFTron HTML to PDF conversion failed

I am trying to convert html to PDF file using PDFTron我正在尝试使用 PDFTron 将 html 转换为 PDF 文件

 const { PDFNet } = require('@pdftron/pdfnet-node'); async function main() { // Start with a PDFDoc (the conversion destination) const doc = await PDFNet.PDFDoc.create(); const converter = await PDFNet.HTML2PDF.create(); // add from HTML String data converter.insertFromHtmlString(htmlSource); // add from a web page location //converter.insertFromUrl(webPageLocation); // apply conversion const page = await converter.convert(doc); //doc.pagePushBack(page); doc.save('aaa.pdf',PDFNet.SDFDoc.SaveOptions.e_linearized); } PDFNet.runWithCleanup(main,licenseKey).catch(function(error) { console.log('Error: ' + JSON.stringify(error)); }).then(function(){ PDFNet.shutdown(); });

, and get the following error: ,并得到以下错误: 在此处输入图像描述

On the download site: " https://www.pdftron.com/download-center/windows/?language=All#modules-html2pdf-conversion-module%5Cn "在下载站点上:“ https://www.pdftron.com/download-center/windows/?language=All#modules-html2pdf-conversion-module%5Cn

I found no mention of html2PDF.我发现没有提到 html2PDF。

Does anyone know the problem有谁知道问题

You need to download the HTML2PDF module here: https://www.pdftron.com/download-center/windows/?language=All#modules_html2pdf-conversion-module您需要在此处下载 HTML2PDF 模块: https://www.pdftron.com/download-center/windows/?language=All#modules_html2pdf-conversion-module

And then use HTML2PDF.SetModulePath and pass in the path to the folder where you extracted HTML2PDF into.然后使用HTML2PDF.SetModulePath并将路径传递到您将HTML2PDF提取到的文件夹中。

See sample: https://www.pdftron.com/documentation/samples/node/js/HTML2PDFTest/参见示例: https://www.pdftron.com/documentation/samples/node/js/HTML2PDFTest/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM