NetSuite Xml to pdf using N/render module

NetSuite Xml to pdf using N/render module

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

        }

    });

NetSuite Solution Provider

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 implementationnetsuite consultation , netsuite customizationnetsuite Supportnetsuite Training NetSuite Celigo Integration , Celigo ConsultantCeligo Integration Consultant.

contact us : [email protected]

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/