NetSuite Xml to pdf using N/render module
Category : NetSuite suitescript SuiteScript 2.0 Uncategorized
In this blog of NetSuite solution provider we are show how to use render module to convert xml content into pdf. In this Netsuite customization tutorial we are creating pdf using render module. The render module encapsulates functionality for printing, PDF creation, form creation from templates, and email creation from templates.
/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
*/
define([‘N/render’, ‘N/record’],
function (render, record) {
function generatePdfFileFromRawXml() {
var xmlStr = “<?xml version=\”1.0\”?>\n” +
“<!DOCTYPE pdf PUBLIC \”-//big.faceless.org//reportLAP\” \”reportLAP-18.1.dtd\”>\n” +
“<pdf>\n<body font-size=\”18\”>\nHello World!\n</body>\n</pdf>”;
var pdfFile = render.xmlToPdf({
xmlString: xmlStr
});
log.debug({
title: “pdfFile”,
details: pdfFile
})
pdfFile.name = ‘Test123.pdf’;
pdfFile.folder = 30;
var fileId = pdfFile.save();
log.debug(‘Saved PDF to file ‘ + fileId);
}
return {
execute: generatePdfFileFromRawXml
}
});
In the below screen shot you can see the execution logs where the file id is mentioned and the contents of the file. In the Printed pdf we can see the contents, you can find the pdf in the folder provided id.
Here is a generated pdf file
Reference : netsuite.com, netsuite help and netsuite guide.
Feel free to reach out Netsuite Solution provider TheSmilingCoders for proper netsuite implementation, netsuite consultation , netsuite customization, netsuite Support, netsuite Training , NetSuite Celigo Integration , Celigo Consultant, Celigo Integration Consultant.
contact us : [email protected]
Linkedin : https://www.linkedin.com/company/netsuite-academy/