Render a PDF
The following sample shows how to render a PDF.
Note:
This script sample uses the define
function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require
function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects.
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
*/
define(['N/xml'], function(xml) {
return {
onRequest: function(context) {
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\">\n" +
"<pdf lang=\"ru-RU\" xml:lang=\"ru-RU\">\n" +
"<head>\n" +
"<link name=\"russianfont\" type=\"font\" subtype=\"opentype\" " +
"src=\"NetSuiteFonts/verdana.ttf\" " +
"src-bold=\"NetSuiteFonts/verdanab.ttf\" " +
"src-italic=\"NetSuiteFonts/verdanai.ttf\" " +
"src-bolditalic=\"NetSuiteFonts/verdanabi.ttf\" " +
"bytes=\"2\"/>\n" +
"</head>\n" +
"<body font-family=\"russianfont\" font-size=\"18\">\nРусский текст</body>\n" +
"</pdf>";
context.response.renderPdf(xml);
}
}
});