I have user event script which loads button on invoice which calls clients script and direct it to suitelet. I am able to print the PDF using advance PDF template but I am missing Logo and 2 other fields.
Suitelet:
define(['N/render', 'N/record', 'N/xml'], function(render, record, xml) {
function onRequest(context) {
var response = context.response;
if (context.request.method == 'GET'){
var ifid = context.request.parameters.custparam_ifid;
var pdfFileName = "Invoice";
var renderer = render.create(ifid);
renderer.setTemplateByScriptId("CUSTTMPL_129_423403_SB5_175");
renderer.addRecord( 'record' , record.load({
type: record.Type.INVOICE,
id: ifid
})
);
//context.response.setHeader({
// name: 'content-disposition',
// value: 'inline; filename="' + pdfFileName + '_' + ifid + '.pdf"'
//});
//context.response.writeFile(renderer.renderAsPdf());
}
//Obj.save()
// renderer.renderPdfToResponse();
var newfile=renderer.renderAsPdf();
context.response.writeFile(newfile, true);
}
return {
onRequest: onRequest
};
});