How to Append Two Or More PDF Documents In NetSuite
While working on NetSuite implementations you may have come across situations where you had to generate a PDF report from a particular record by appending two or more PDF documents together. We recently encountered this requirement while working on an ERP implementation for one of our NetSuite clients.
The client wanted us to provide a button on the Estimate record that would enable them to generate a record specific PDF. The catch here was that in order to generate this PDF report, we had to append two existing PDF documents with our newly generated PDF via SuiteScript. To solve this problem, we used the PDFSET tag provided by BFO for appending PDFs (as shown below).
Document body here
<pdf src=”resource/pdf1.pdf” />
<pdf src=”resource/pdf2.pdf” />
Here’s the code snippet we used in NetSuite.
var xml = “<?xml version=\”1.0\”?>\n<!DOCTYPE pdf PUBLIC \”-//big.faceless.org//report\” \”report-1.1.dtd\”>\n”;
xml += “<pdfset>\n”;
xml += “<pdf>\n<body font-size=\”12\”>\n<h3>Genereated PDft</h3>\n”;
xml += “<p></p>”;
xml += “Document body here”;
xml += “</body>\n</pdf>”;
xml += “<pdf src=”resource/pdf1.pdf” />”;
xml += “<pdf src=”resource/pdf2.pdf” />”;
xml += “</pdfset>”;
var file = nlapiXMLToPDF( xml );