" This document has no pages " PDFTRON中的错误



我想将 DWG 格式转换为角度 4/nodeJS 的 PDF 格式,并尝试使用 PDFTRON CAD 模块实现它,但每次我都遇到像InvalidPDF : This document has no pages.这样的错误,即使 DWG 有多个页面。 我尝试了以下代码:-

await PDFNet.initialize();
const pdfDoc = await PDFNet.PDFDoc.create();
PDFNet.addResourceSearchPath('src/client/lib/lib/Lib/');
PDFNet.Convert.fromCAD(pdfDoc, 'src/files/example.dwg', new PDFNet.Obj);
pdfDoc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_remove_unused).then(value => {
// const arr = new Uint8Array(value);
const blob = new Blob([value], {type: 'application/pdf'});
instance.docViewer.getDocument().mergeDocument(blob, instance.docViewer.getPageCount() + 1);

// const doc = instance.CoreControls.createDocument(blob, {filename: 'src/client/files/demo.pdf'});
// instance.loadDocument(blob, { filename: 'src/client/files/newPDF.pdf'});
}); 

任何人都可以告诉我我的代码出了什么问题。提前谢谢你:)

谢谢@Ryan .问题是,CAD 模块文件未正确提取到我当前的 SDK 中。因此,我再次将CAD模块提取到另一个新文件夹中,并将所有文件夹的内容粘贴到SDK文件夹中。就是这样。

最新更新