ServerResponse.renderPdf(options)
Method Description |
Generates and renders a PDF directly to the response. |
Returns |
void |
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
10 units |
Module |
|
Parent Object |
|
Sibling Object Members |
|
Since |
2015.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string |
required |
Content of the PDF |
2015.2 |
Errors
Error Code |
Message |
Thrown If |
---|---|---|
|
Missing a required argument: {param name} |
The |
Syntax
The following code shows the syntax for this member. It is not a functional example. For a complete script example, see N/http Module Script Samples.
The following sample shows how to render a PDF.
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);
}
}
});