Paragraph - Scoped, Global
-
- UpdatedJan 30, 2025
- 5 minutes to read
- Yokohama
- API reference
Creates a Paragraph object representing a block of text 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.
Paragraph - Paragraph(String text)
Instantiates a new Paragraph object containing a string.
Name | Type | Description |
---|---|---|
text | String | Paragraph block of text. |
Example
The following example shows how to create a Paragraph object. For a document usage example, see Document API.
Paragraph – addNewLine()
Adds an empty line after a paragraph in a document.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
None |
Example
The following example shows how to add a new line after a paragraph in a document. For a document usage example, see Document API.
Paragraph – addParagraph(Paragraph paragraph)
Adds a paragraph. You can use this method to create a block of paragraphs with automatic line breaks.
Name | Type | Description |
---|---|---|
paragraph | Paragraph | Paragraph object. |
Type | Description |
---|---|
None |
Example
The following example shows how to add a section of paragraphs to a document. For a document usage example, see Document API.
Paragraph – addString(String content)
Adds a string of text to a paragraph. This method does not automatically insert a space preceding the content.
Name | Type | Description |
---|---|---|
content | String | Information to include in a paragraph. |
Type | Description |
---|---|
None |
Example
The following example shows how to add a new sentence to a paragraph. For a document usage example, see Document API.
Paragraph – addStyle(Style style)
Paragraph – setFixedPosition(Number left, Number bottom, Number width)
Sets a paragraph element to a fixed position on the page.
Name | Type | Description |
---|---|---|
left | Number | Indentation from the left side of the PDF page in points. |
bottom | Number | Position from the bottom of the PDF page in points. |
width | Number | Width of the paragraph element in points. This value determines the length at which the line breaks. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a fixed position on a page. For a document usage example, see Document API.
Paragraph – setMargin(Number margin)
Sets each paragraph margin.
To set all four margins with one or more unique values, use setMargins().
Name | Type | Description |
---|---|---|
margin | Number | Value of the top, right, bottom, and left margins in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set the all margins of the paragraph to 48 points.
Paragraph – setMarginBottom(Number margin)
Sets the bottom margin of a paragraph.
Name | Type | Description |
---|---|---|
margin | Number | Height of the bottom margin in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set the bottom margin of a paragraph to one point.
Paragraph – setMarginLeft(Number margin)
Sets the left margin of a paragraph.
Name | Type | Description |
---|---|---|
leftMargin | Number | Width of the left margin in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set the left margin of a paragraph to one point.
Paragraph – setMarginRight(Number margin)
Sets the right margin of a paragraph.
Name | Type | Description |
---|---|---|
margin | Number | Width of the right margin in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set the right margin of a paragraph to one point.
Paragraph – setMargins(Number marginTop, Number marginRight, Number marginBottom, Number marginLeft)
Sets a size for each paragraph margin.
To set each margin to the same value, use setMargin().
Type | Description |
---|---|
None |
Example
The following example shows how to set paragraph margins.For a document usage example, see Document API.
Paragraph – setMarginTop(Number margin)
Sets the top margin of a paragraph.
Name | Type | Description |
---|---|---|
margin | Number | Height of the top margin in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set the top margin of a paragraph to one point.
Paragraph – setTextAlignment(String alignment)
Sets the text alignment of this paragraph.
Name | Type | Description |
---|---|---|
alignment | String | Text alignment position. Valid values:
|
Type | Description |
---|---|
None |
Example
The following example shows how to set the paragraph text to left alignment.
On this page
- Paragraph - Paragraph(String text)
- Paragraph – addNewLine()
- Paragraph – addParagraph(Paragraph paragraph)
- Paragraph – addString(String content)
- Paragraph – addStyle(Style style)
- Paragraph – setFixedPosition(Number left, Number bottom, Number width)
- Paragraph – setMargin(Number margin)
- Paragraph – setMarginBottom(Number margin)
- Paragraph – setMarginLeft(Number margin)
- Paragraph – setMarginRight(Number margin)
- Paragraph – setMargins(Number marginTop, Number marginRight, Number marginBottom, Number
marginLeft)
- Paragraph – setMarginTop(Number margin)
- Paragraph – setTextAlignment(String alignment)