---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Line - Scoped, Global

# Line - Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

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](https://servicenow-prod.fluidtopics.net/oJ48cUW_0DIZl2sK2PI~9A#DocumentBothAPI "The Document API provides methods to initialize a PDF, add content, and close the PDF. After adding content, the document can be attached to a target record.") to generate a
PDF.

## Line - Line() {#ariaid-title2}

Instantiates a new Line object.
{#Line-Line__table_twm_hjk_34b__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#Line-Line__table_twm_hjk_34b}  
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) {#ariaid-title3}

Places a line on a document page.
{#Line-drawLine_O_N_N_N_N_N__table_vv5_52h_44b__entry__3}

| Name | Type | Description |
|-|-|-|
| Document | [Document](https://servicenow-prod.fluidtopics.net/oJ48cUW_0DIZl2sK2PI~9A#DocumentBothAPI "The Document API provides methods to initialize a PDF, add content, and close the PDF. After adding content, the document can be attached to a target record.") | Name of the document object. |
| pageNo | Number | Page number on which you want to place the line. |
| xPos | Number | X-coordinate area of the page on which to place the line. |
| yPos | Number | Y-coordinate area of the page on which to place the line. |
| width | Number | Width area of the page in which you want to draw the line. Values are in points. |
| lineWidth | Number | Optional. Value of line thickness in points. Default: 1 |
[Table 2. Parameters]

{#Line-drawLine_O_N_N_N_N_N__table_vv5_52h_44b} {#Line-drawLine_O_N_N_N_N_N__table_wv5_52h_44b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 3. Returns]

{#Line-drawLine_O_N_N_N_N_N__table_wv5_52h_44b}  
The following example shows how to create a line at the lower margin of a document page.
For a document usage example, see [Document](https://servicenow-prod.fluidtopics.net/oJ48cUW_0DIZl2sK2PI~9A#DocumentBothAPI "The Document API provides methods to initialize a PDF, add content, and close the PDF. After adding content, the document can be attached to a target record.") 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) {#ariaid-title4}

Sets the color of a line.
{#Line-setColor_O__table_vv5_52h_44b__entry__3}

| Name | Type | Description |
|-|-|-|
| color | [Color](https://servicenow-prod.fluidtopics.net/0EiXfws~5CY1d9dHdAL1UQ#ColorBothAPI "Creates a Color object used to define color attributes that you can apply to elements in a PDF; such as cells, tables, and lines.") | Line color. |
[Table 4. Parameters]

{#Line-setColor_O__table_vv5_52h_44b} {#Line-setColor_O__table_wv5_52h_44b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 5. Returns]

{#Line-setColor_O__table_wv5_52h_44b}  
The following example shows how to create a line and set its color in a document. For a document usage example, see [Document](https://servicenow-prod.fluidtopics.net/oJ48cUW_0DIZl2sK2PI~9A#DocumentBothAPI "The Document API provides methods to initialize a PDF, add content, and close the PDF. After adding content, the document can be attached to a target record.") 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");


