Style - Scoped, Global
-
- UpdatedJan 30, 2025
- 6 minutes to read
- Yokohama
- API reference
Creates a style for defining properties such font size, border, and alignment. You can apply the same style to multiple objects simultaneously.
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.
Style - Style()
Style – setBackgroundColor(Color color)
Style – setBold()
Sets a style to bold font.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style to bold font.
Style – setBorder(Number width)
Sets the style border on all four sides of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border. For a document usage example, see Document API.
Style – setBorderBottom(Number width)
Sets the style border to the bottom of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border to the bottom of an element. For a document usage example, see Document API.
Style – setBorderLeft(Number width)
Sets the style border on the left side of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border on the left side of an element. For a document usage example, see Document API.
Style – setBorderRight(Number width)
Sets the style border on the right side of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border on the right side of an element. For a document usage example, see Document API.
Style – setBorderTop(Number width)
Sets the style border to the top of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border to the top of an element. For a document usage example, see Document API.
Style – setColoredBorder(Number width, Color color)
Sets style border with color on all four sides of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
color | Color | Style border color. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border with color. For a document usage example, see Document API.
Style – setColoredBorderBottom(Number width, Color color)
Sets style border with color to the bottom side of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
color | Color | Style border color. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border to the bottom of an element.For a document usage example, see Document API.
Style – setColoredBorderLeft(Number width, Color color)
Sets style border with color on the left side of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
color | Color | Style border color. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border. For a document usage example, see Document API.
Style – setColoredBorderRight(Number width, Color color)
Sets style border with color on the right side of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
color | Color | Style border color. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border with color. For a document usage example, see Document API.
Style – setColoredBorderTop(Number width, Color color)
Sets style border with color to the top side of an element.
Name | Type | Description |
---|---|---|
width | Number | Style border width in points. |
color | Color | Style border color. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a style border. For a document usage example, see Document API.
Style – setFontColor(Color color)
Style – setFontSize(Number fontSize)
Sets a style font size.
Name | Type | Description |
---|---|---|
fontSize | Number | Font size in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a font size.
Style – setHorizontalAlignment(String alignment)
Sets the horizontal alignment for a style.
Name | Type | Description |
---|---|---|
alignment | String | Horizontal alignment setting. Valid
values:
|
Type | Description |
---|---|
None |
Example
The following example shows how to set horizontal alignment on an element. For a document usage example, see Document API.
Style – setItalic()
Sets a style to italic font.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
None |
Example
The following example shows how to set an element style to an italic font.
Style – setPadding(Number padding)
Sets the padding of all four sides of an element to the same width.
Name | Type | Description |
---|---|---|
padding | Number | Padding width in points as a decimal value. |
Type | Description |
---|---|
None |
Example
The following example shows how to set bottom style to 2.5 points. For a document usage example, see Document API.
Style – setPaddingBottom(Number padding)
Sets the value of the bottom padding width of an element.
Name | Type | Description |
---|---|---|
padding | Number | Padding width in points as a decimal value. |
Type | Description |
---|---|
None |
Example
The following example shows how to set bottom element padding to 2.5 points. For a document usage example, see Document API.
Style – setPaddingLeft(Number padding)
Sets the value of the left padding width of an element.
Name | Type | Description |
---|---|---|
padding | Number | Padding width in points as a decimal value. |
Type | Description |
---|---|
None |
Example
The following example shows how to set left element padding to 2.5 points. For a document usage example, see Document API.
Style – setPaddingRight(Number padding)
Sets the value of the right padding width of a style.
Name | Type | Description |
---|---|---|
padding | Number | Padding width in points as a decimal value. |
Type | Description |
---|---|
None |
Example
The following example shows how to set right element padding to 2.5 points. For a document usage example, see Document API.
Style – setPaddingTop(Number padding)
Sets the value of the top padding width of an element.
Name | Type | Description |
---|---|---|
padding | Number | Padding width in points as a decimal value. |
Type | Description |
---|---|
None |
Example
The following example shows how to set top element padding to 2.5 points. For a document usage example, see Document API.
Style – setTextAlignment(String alignment)
Sets the text alignment for a style.
Name | Type | Description |
---|---|---|
alignment | String | Text alignment position. Valid values:
|
Type | Description |
---|---|
None |
Example
The following example shows how to set the element text to center alignment.
Style – setVerticalAlignment(String alignment)
Sets the vertical alignment for this element.
Name | Type | Description |
---|---|---|
alignment | String | Vertical alignment setting. Valid values:
|
Type | Description |
---|---|
None |
Example
The following example shows how to set vertical alignment on an element. For a document usage example, see Document API.
On this page
- Style - Style()
- Style – setBackgroundColor(Color color)
- Style – setBold()
- Style – setBorder(Number width)
- Style – setBorderBottom(Number width)
- Style – setBorderLeft(Number width)
- Style – setBorderRight(Number width)
- Style – setBorderTop(Number width)
- Style – setColoredBorder(Number width, Color color)
- Style – setColoredBorderBottom(Number width, Color color)
- Style – setColoredBorderLeft(Number width, Color color)
- Style – setColoredBorderRight(Number width, Color color)
- Style – setColoredBorderTop(Number width, Color color)
- Style – setFontColor(Color color)
- Style – setFontSize(Number fontSize)
- Style – setHorizontalAlignment(String alignment)
- Style – setItalic()
- Style – setPadding(Number padding)
- Style – setPaddingBottom(Number padding)
- Style – setPaddingLeft(Number padding)
- Style – setPaddingRight(Number padding)
- Style – setPaddingTop(Number padding)
- Style – setTextAlignment(String alignment)
- Style – setVerticalAlignment(String alignment)