Scruffy
08/11/2021, 9:10 PM/**
* @NApiVersion 2.x
*/
// This sample shows how to render an invoice into a PDF file using an XML template in the file cabinet.
// Note that this example requires the Advanced PDF/HTML Templates feature.
require(['N/render', 'N/file', 'N/record'],
function(render, file, record) {
function renderRecordToPdfWithTemplate() {
var xmlTemplateFile = file.load('Templates/PDF Templates/invoicePDFTemplate.xml');
var renderer = render.create();
renderer.templateContent = xmlTemplateFile.getContents();
renderer.addRecord('grecord', record.load({
type: record.Type.INVOICE,
id: 37
}));
var invoicePdf = renderer.renderAsPdf();
}
renderRecordToPdfWithTemplate();
});
I have Advanced PDF enabled.David B
08/11/2021, 9:16 PMtemplateContent = xmlFile.getContents()
) allows you to load an xml template from the file cabinet.
To instead load an Advanced PDF template, use either .setTemplateById(options) or .setTemplateByScriptId(options)Sciuridae54696d
08/11/2021, 9:19 PMTemplates/PDF Templates/invoicePDFTemplate.xml
this is the actual path you need to find the xml in the file cabnetScruffy
08/11/2021, 9:20 PMSciuridae54696d
08/11/2021, 9:22 PMScruffy
08/11/2021, 9:22 PMScruffy
08/11/2021, 9:22 PMSciuridae54696d
08/11/2021, 9:23 PMSuitebundle XXXXXX/Templates/PDF Templates/invoicePDFTemplate.xml
Sciuridae54696d
08/11/2021, 9:23 PMSuitescript/Templates/PDF Templates/invoicePDFTemplate.xml
or
Templates/PDF Templates/invoicePDFTemplate.xml
Scruffy
08/11/2021, 9:25 PMDavid B
08/11/2021, 9:26 PM