Introduction
What if you have multiple advanced PDFs and need to combine them into one? You could just combine them into one advanced PDF to solve the problem. For one of my clients, this wasn’t going to work as they needed to be able to print specific PDFs based on specific criteria. For example, if the sales order included a specific item then a specific set of advanced PDFs should be printed. This article will detail how to merge multiple advanced PDFs into one document using a Suitelet.
My example will use the sales order record. I’ve created three different advanced PDFs for the sales order, as you can see below.

To see the internal IDs of these advanced PDFs, you can hover over the edit button, and then you will see the ID in the URL. You can also edit them and see the ID in the URL.

Modify the code below to use the internal IDs for the advanced PDFs you want to print.
/**
*@NApiVersion 2.1
*@NScriptType Suitelet
*/
define(['N/record','N/render'],
(record, render) => {
onRequest = (context) => {
// templates to render - Change these IDs to the IDs of the templates you want to render
const templates = [102, 107, 108];
const renderer = render.create();
// attach the sales order record
const salesOrderRecord = record.load({
type: record.Type.SALES_ORDER,
id: 22326
});
renderer.addRecord('record', salesOrderRecord);
// render each template and put in array
let salesOrderPDFArray = [];
for (let i = 0; i < templates.length; i++) {
renderer.setTemplateById(templates[i]);
var soasString = renderer.renderAsString();
// remove the first line
soasString = soasString.replace('<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">', '');
salesOrderPDFArray.push(soasString);
}
let finalXML = '<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">';
finalXML += '<pdfset>' + salesOrderPDFArray.join('') + '</pdfset>';
// render final xml
context.response.renderPdf(finalXML);
}
return {onRequest};
});
Add and deploy the script. If needed, reference my article, “Quick Guide to Adding and Deploying a Script in NetSuite”.
To use this Suitelet, you would create a user event script to show a button, “Print Sales Order”, on the sales order. Clicking the button would call the Suitelet, which would render the PDF.
Here are the three pages that were printed, forming the combined PDF.



Conclusion
Advanced PDFs are powerful but can be tricky. Do you need help with an Advanced PDF customization? If so, please contact Suite Tooth Consulting here to set up a free consultation.
If you liked this article, please sign up for my newsletter to get these delivered to your inbox here.