Cell - Scoped, Global
-
- UpdatedJan 30, 2025
- 9 minutes to read
- Yokohama
- API reference
Creates a Cell object as a cell in a table. You can use this API to format the cell and include additional blocks, such as paragraphs and images.
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.
Cell - Cell(Number rowspan, Number colspan)
Instantiates a new Cell object. Creates a cell which takes a custom amount of cell spaces in the table.
Name | Type | Description |
---|---|---|
rowspan | Number | Number of rows this cell is to occupy. Default: 0 |
colspan | Number | Number of columns this cell is to occupy. Default: 0 |
Example
The following example shows how to create a Cell object spanning a single row and single column.
Cell – addImage(Image image)
Adds an image to a table cell.
Name | Type | Description |
---|---|---|
image | Image | Image to add to a table cell. |
Type | Description |
---|---|
None |
Example
The following example shows how to instantiate an existing image attachment and add it to a cell in a table. For a document usage example, see Document API.
Cell – addParagraph(Paragraph paragraph)
Adds text to a table cell.
Name | Type | Description |
---|---|---|
paragraph | Paragraph | Text to add to a table cell. |
Type | Description |
---|---|
None |
Example
The following example shows how to instantiate paragraph objects and add the content cells in a table. For a document usage example, see Document API.
Cell – addStyle(Style style)
Cell – addTable(Table table)
Cell – getColumn()
Gets the number of the column in which the cell is located.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | Number of the column position for a cell. |
Example
The following example shows how to get the number of a column position for a cell.
Output:
Cell – getRow()
Gets the number of rows in which the cell is located.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | Number of the row position for a cell. |
Example
The following example shows how to get the number of a row position for a cell.
Output:
Cell – setBackGroundColor(Color color)
Cell – setBorder(Number width)
Sets a border for all four edges of a cell.
Name | Type | Description |
---|---|---|
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a cell border of one point to all four edges of a cell. For a document usage example, see Document API.
Cell – setBorderBottom(Number width)
Sets a border for the lower limit of a cell.
Name | Type | Description |
---|---|---|
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a cell border. For a document usage example, see Document API.
Cell – setBorderLeft(Number width)
Sets a border for the left limit of a cell.
Name | Type | Description |
---|---|---|
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how set a left-side cell border. For a document usage example, see Document API.
Cell – setBorderRight(Number width)
Sets a border for the right limit of a cell.
Name | Type | Description |
---|---|---|
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a right-side cell border. For a document usage example, see Document API.
Cell – setBorderTop(Number width)
Sets a border for the upper limit of a cell.
Name | Type | Description |
---|---|---|
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a top cell border. For a document usage example, see Document API.
Cell – setColoredBorder(Color color, Number width)
Sets a colored border for all four edges of a cell.
Name | Type | Description |
---|---|---|
color | Color | Cell border color. |
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a colored cell border. For a document usage example, see Document API.
Cell – setColoredBorderBottom(Color color, Number width)
Sets a colored border for the lower limit of a cell.
Name | Type | Description |
---|---|---|
color | Color | Cell border color. |
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a colored lower cell border. For a document usage example, see Document API.
Cell – setColoredBorderLeft(Color color, Number width)
Sets a colored border for the left limit of a cell.
Name | Type | Description |
---|---|---|
color | Color | Cell border color. |
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a colored left cell border. For a document usage example, see Document API.
Cell – setColoredBorderRight(Color color, Number width)
Sets a colored border for the right limit of a cell.
Name | Type | Description |
---|---|---|
color | Color | Cell border color. |
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a colored right cell border. For a document usage example, see Document API.
Cell – setColoredBorderTop(Color color, Number width)
Sets a colored border for the upper limit of a cell.
Name | Type | Description |
---|---|---|
color | Color | Cell border color. |
width | Number | Cell border width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how to set a colored top cell border. For a document usage example, see Document API.
Cell – setHeight(Number height)
Sets the height of a cell.
Name | Type | Description |
---|---|---|
value | Number | Cell height in points. |
Type | Description |
---|---|
None |
Example
The following example shows how set a cell height of 10 points. For a document usage example, see Document API.
Cell – setHorizontalAlignment(String alignment)
Sets the horizontal alignment for this cell.
Name | Type | Description |
---|---|---|
alignment | String | Horizontal alignment setting. Valid
values:
|
Type | Description |
---|---|
None |
Example
The following example shows how to set horizontal alignment on a cell. For a document usage example, see Document API.
Cell – setMaxHeight(Number value)
Sets the maximum height of a cell.
Name | Type | Description |
---|---|---|
value | Number | Maximum cell height in points. |
Type | Description |
---|---|
None |
Example
The following example shows how set a maximum cell height of 409 points. For a document usage example, see Document API.
Cell – setMaxWidth(float value)
Sets the maximum width of a cell.
Name | Type | Description |
---|---|---|
value | Number | Maximum cell width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how set a maximum cell width of 1530 points. For a document usage example, see Document API.
Cell – setMinHeight(Number value)
Sets the minimum height of a cell.
Name | Type | Description |
---|---|---|
value | Number | Minimum cell height in points. |
Type | Description |
---|---|
None |
Example
The following example shows how set a minimum cell height of 12.75 points. For a document usage example, see Document API.
Cell – setMinWidth(Number value)
Sets the minimum width of a cell.
Name | Type | Description |
---|---|---|
value | Number | Minimum cell width in points. |
Type | Description |
---|---|
None |
Example
The following example shows how set a minimum cell width of 50.58 points. For a document usage example, see Document API.
Cell – setOpacity(Number opacity)
Sets the opacity of cell content, borders, and background.
Name | Type | Description |
---|---|---|
opacity | Number | Float decimal value from 0 through 1, in which 0 is transparent and 1 is fully
opaque. Default: 0 |
Type | Description |
---|---|
None |
Example
The following example shows how to set the opacity of a cell.
Cell – setPadding(Number padding)
Sets the padding of all four sides of a cell 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 the bottom cell to one point. For a document usage example, see Document API.
Cell – setPaddingBottom(Number padding)
Sets the value of the bottom padding width of a cell.
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 cell padding to one point. For a document usage example, see Document API.
Cell – setPaddingLeft(Number padding)
Sets the value of the left padding width of a cell.
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 cell padding to one point. For a document usage example, see Document API.
Cell – setPaddingRight(Number padding)
Sets the value of the right padding width of a cell.
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 cell padding to one point. For a document usage example, see Document API.
Cell – setPaddingTop(Number padding)
Sets the value of the top padding width of a cell.
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 cell padding to one point. For a document usage example, see Document API.
Cell – setTextAlignment(String alignment)
Sets the text alignment of this cell.
Name | Type | Description |
---|---|---|
alignment | String | Text alignment position. Valid values:
|
Type | Description |
---|---|
None |
Example
The following example shows how to set the cell text to left alignment.
Cell – setVerticalAlignment(String alignment)
Sets the vertical alignment for this cell.
Name | Type | Description |
---|---|---|
alignment | String | Vertical alignment setting. Valid values:
|
Type | Description |
---|---|
None |
Example
The following example shows how to set vertical alignment on a cell. For a document usage example, see Document API.
On this page
- Cell - Cell(Number rowspan, Number colspan)
- Cell – addImage(Image image)
- Cell – addParagraph(Paragraph paragraph)
- Cell – addStyle(Style style)
- Cell – addTable(Table table)
- Cell – getColumn()
- Cell – getRow()
- Cell – setBackGroundColor(Color color)
- Cell – setBorder(Number width)
- Cell – setBorderBottom(Number width)
- Cell – setBorderLeft(Number width)
- Cell – setBorderRight(Number width)
- Cell – setBorderTop(Number width)
- Cell – setColoredBorder(Color color, Number width)
- Cell – setColoredBorderBottom(Color color, Number width)
- Cell – setColoredBorderLeft(Color color, Number width)
- Cell – setColoredBorderRight(Color color, Number width)
- Cell – setColoredBorderTop(Color color, Number width)
- Cell – setHeight(Number height)
- Cell – setHorizontalAlignment(String alignment)
- Cell – setMaxHeight(Number value)
- Cell – setMaxWidth(float value)
- Cell – setMinHeight(Number value)
- Cell – setMinWidth(Number value)
- Cell – setOpacity(Number opacity)
- Cell – setPadding(Number padding)
- Cell – setPaddingBottom(Number padding)
- Cell – setPaddingLeft(Number padding)
- Cell – setPaddingRight(Number padding)
- Cell – setPaddingTop(Number padding)
- Cell – setTextAlignment(String alignment)
- Cell – setVerticalAlignment(String alignment)