- Create an xml file of the printing template.Store it in file cabinet
/**
* @description function for rendering pdf file
* @param {filePath} specify the file path for the xml file for pdf template(/suitescript/template/.../name.xml)
* @param {recType} specify the record type (salesorder/estimate/invoice....)
* @param {Id} internal Id of the record to be printed.
*/
function renderPdfFile(filePath,recType,Id){
var renderer = render.create();
var xmlTemplateFile = file.load(filePath);
var renderer = render.create();
renderer.templateContent = xmlTemplateFile.getContents();
renderer.addRecord({
templateName: 'record',
record: record.load({
type: recType,
id: Id
})
});
var rendererFile = renderer.renderAsPdf();
return rendererFile;
}