I want to convert DWG format to PDF format in angular 4 / nodeJS and trying to implement it using PDFTRON CAD Modules but every time i'm getting error like InvalidPDF : This document has no pages. even if DWG have multiple pages.
I have tried following code :-
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'});
});
Can anyone please tell me what's wrong in my code. Thank You in advance :)