Looking at how to use N/file, when loading the xml...
# suitescript
s
Looking at how to use N/file, when loading the xml template, file.load seems to load the template from the File Cabinet. I cant seem to find any of the Advanced PDFs in the File Cabinet. Where are these templates located? Im using this example as a reference:
Copy code
/**
 * @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.
d
That example (
templateContent = 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)
s
Copy code
Templates/PDF Templates/invoicePDFTemplate.xml
this is the actual path you need to find the xml in the file cabnet
s
@Sciuridae54696d that folder is empty for me. Im on Admin as well
s
if this is production, the other place I'd first search is if your script is included in a bundle, therefore installed in a suitebundled folder
s
@David B ill look into those methods
ah i see
s
aka could be under
Copy code
Suitebundle XXXXXX/Templates/PDF Templates/invoicePDFTemplate.xml
instead of
Copy code
Suitescript/Templates/PDF Templates/invoicePDFTemplate.xml
or
Copy code
Templates/PDF Templates/invoicePDFTemplate.xml
s
i have some customized pdfs i created from a bundle template that are no longer part of the bundle. Cant find those so far. Will keep looking
d
yeah, if they were originally in the file cabinet, the methods I mentioned aren't going to be of use to you, sorry