0
votes

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 :)

1
Does this issue happen with any DWG file? What happens when you run the CAD2PDFTest sample project that comes with SDK download? - Ryan
Will let you know once CAD2PDFTest sample project run !! - vivek

1 Answers

1
votes

Thanks @Ryan .The issue was, CAD module file's are not properly extracted into my current SDK. So i extracted CAD Modules again into another new folder and pasted all folder's content into the SDK folder. That's it.