asposepdfnodejs
Version:
Aspose.PDF for Node.js via C++
24 lines (17 loc) • 1.05 kB
JavaScript
import AsposePdf from 'asposepdfnodejs';
import fs from 'fs';
import os from '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');
const AsposePdfModule = await AsposePdf();
let 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);