Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

Line - Scoped, Global

Creates a Line object using methods to draw a line in a PDF.

This API is part of the ServiceNow PDF Generation Utilities plugin (com.snc.apppdfgenerator) and is provided within the sn_pdfgeneratorutils namespace. The plugin is activated by default.

This API is a component used with the Document API to generate a PDF.

Parent Topic:Server API reference

Line - Line()

Instantiates a new Line object.

NameTypeDescription
None  

The following examples shows how to create a Line object.

var line = new sn_pdfgeneratorutils.Line();

Line – drawLine(Document document, Number pageNo, Number xPos, Number yPos, Number width, Number lineWidth)

Places a line on a document page.

NameTypeDescription
DocumentDocumentName of the document object.
pageNoNumberPage number on which you want to place the line.
xPosNumberX-coordinate area of the page on which to place the line.
yPosNumberY-coordinate area of the page on which to place the line.
widthNumberWidth area of the page in which you want to draw the line. Values are in points.
lineWidthNumberOptional. Value of line thickness in points.Default: 1
TypeDescription
None 

The following example shows how to create a line at the lower margin of a document page. For a document usage example, see Document API.

var pageSize = new sn_pdfgeneratorutils.PdfPage("LETTER");
var document = new sn_pdfgeneratorutils.Document.createDocument(pageSize);

var num = 1;
var xpos = 100;
var ypos = 100;
var width = 450;
var linewidth = 2.5;

document.addNewPage();

var line = new sn_pdfgeneratorutils.Line();

line.drawLine(document, num, xpos, ypos, width, linewidth);

document.saveAsAttachment("incident", "<sys_id>", "line.pdf");

Line – setColor(Color color)

Sets the color of a line.

NameTypeDescription
colorColorLine color.
TypeDescription
None 

The following example shows how to create a line and set its color in a document. For a document usage example, see Document API.

var pageSize = new sn_pdfgeneratorutils.PdfPage("LETTER");
var document = new sn_pdfgeneratorutils.Document.createDocument(pageSize);

var num = 1;
var xpos = 100;
var ypos = 100;
var width = 450;
var linewidth = 2.5;

var color = new sn_pdfgeneratorutils.Color([0.5,0.5,0.8]);   //given as array of RGB values;

document.addNewPage();

var line = new sn_pdfgeneratorutils.Line();

line.setColor(color);

line.drawLine(document, num, xpos, ypos, width, linewidth);

document.saveAsAttachment("incident", "<sys_id>", "lineWithColor.pdf");