NetSuite merge PDF in SuiteScript 2.0 [in-progress]
An example below shows the how PDF files are being merged using <pdfset> tag. For compiled PDF files to be merged, use the src property of pdf.
var xmlF = ‘<?xml version=”1.0″?>
<!DOCTYPE pdf PUBLIC “-//big.faceless.org//report” “report-1.1.dtd”>’;
xmlF += ‘<pdfset>’;
<pdf src="https://system.netsuite.com/core/media/media.nl?id=1"/>
<pdf src="https://system.netsuite.com/core/media/media.nl?id=2"/>
xmlF += '</pdfset>';
xmlF = xmlF.replace(/&(?!amp;)/g, ‘&’);
var file = render.xmlToPdf({ xmlString: xmlF });
file.save();
Sample2:
var arrayWithUrls = ["/core/media/media.nl?id=theid&c=myaccoutn&h=1122&_xt=.pdf", "/core/media/media.nl?id=theid&c=myaccount&h=2233&_xt=.pdf"] var xml = "<?xml version=\"1.0\"?>\n<!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\">\n" xml += "<pdfset>" xml += "<pdf>\n<body font-size=\"12\">\n<h2>Merged PDF</h2>\n" xml += "<p></p>" xml += "Document body" xml += "</body>\n</pdf>" arrayWithUrls.map(function (x) { var cleanPdfURL = mxml.escape({ xmlText: x }); xml += '<pdf src="https://system.netsuite.com' + cleanPdfURL + '"></pdf>' }) xml += "</pdfset>"
https://medium.com/@morrisdev/append-multiple-pdf-documents-in-netsuite-suitescripts-6542396a2343
浙公网安备 33010602011771号