UNPKG

asposepdfnodejs

Version:

Aspose.PDF for Node.js via C++

29 lines (20 loc) 1.19 kB
const AsposePdf = require('asposepdfnodejs'); const fs = require("fs"); const os = require("os"); const resultdir = !!process.platform.match(/^win/) ? '' : fs.realpathSync(os.tmpdir()) + '/'; const pdf_file = resultdir + "eula.pdf"; console.log('Aspose.PDF for Node.js via C++ example'); AsposePdf().then(AsposePdfModule => { var json; //AsposePdfAbout - Get info about Product json = AsposePdfModule.AsposePdfAbout(); console.log("AsposePdfAbout => %O", json.errorCode == 0 ? JSON.parse(JSON.stringify(json).replace('"errorCode":0,"errorText":"",','')) : json.errorText); //AsposePdfFromTxt - Convert a TXT-file to PDF json = AsposePdfModule.AsposePdfFromTxt('./license/eula.txt', pdf_file); console.log("AsposePdfFromTxt => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText); //AsposePdfGetInfo - Get info (metadata) from a PDF-file json = AsposePdfModule.AsposePdfGetInfo(pdf_file); console.log("AsposePdfGetInfo => %O", json.errorCode == 0 ? JSON.parse(JSON.stringify(json).replace('"errorCode":0,"errorText":"",','')) : json.errorText); }, reason => {console.log(`The unknown error has occurred: ${reason}`);} );