ServerResponse.renderPdf(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

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

N/http Module

Parent Object

http.ServerResponse

Sibling Object Members

ServerResponse Object Members

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.xmlString

string

required

Content of the PDF

2015.2

Errors

Error Code

Message

Thrown If

SSS_MISSING_REQD_ARGUMENT

Missing a required argument: {param name}

The options.xmlString parameter is not specified.

Syntax
Important:

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.

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);
        }
    }
}); 

        

Related Topics

http.ServerResponse
N/http Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices