Jordan Patterson
01/29/2025, 5:33 PMCeligo AI
01/29/2025, 5:33 PMAI generated answer (using internal Slack threads):In an Advanced PDF template, it is possible to load file contents from the file cabinet and include them as part of the template. This can be done using the
N/file
module in SuiteScript, which provides methods for loading and manipulating files in the file cabinet.
Here is an example of how you can load an XML template from the file cabinet:
javascript
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();
});
In this example, the file.load
method is used to load the XML template from the file cabinet. The getContents
method is then used to get the contents of the file, which are set as the template content for the renderer.
If you want to load an Advanced PDF template, you can use the .setTemplateById(options)
or .setTemplateByScriptId(options)
methods.
You can also add custom fonts to your Advanced PDF template by adding the font files to the file cabinet and loading them in your template via the file URL.
However, if you want to modify a PDF template every time it's printed, you might encounter concurrency issues if two people try to print at the same time.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
01/29/2025, 5:33 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854966462
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836895168
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829780459
Celigo AI
01/29/2025, 5:33 PM