Document generation APIs and script includes

The following APIs and script includes are available for generating PDF documents.

The GeneralHRForm script include has the following APIs:
API Input Output Description
generate manual (Boolean) Generation status (Boolean) Generates a PDF document. When set to true, generates documents manually. For example, Generate action on Preview Document. This API returns a boolean value when a pdf is generated.
createPDF tableName (String), tableId (String) N/A The inactivateRelatedDrafts inactivates draft documents for the tableName and tableId input parameters. When the tableId is the sys_id of a case with child tasks, then draft_documents for the tasks are also inactivated.
hasDraftDocument tableName (String), tableId (String) Boolean Returns a boolean value when a draft document is attached. Input parameters are tableName (takes name of the table the draft document is attached), tableId (takes the sys_id of the table). The table can be the HR Task or HR Case when the sys_class_name within the api call.
getDraftDocument tableName (String), tableId (String) draft document Glide Record (GlideRecord) Takes tableName and tableId of the record that the draft document is attached to. It returns the draft document GlideRecord matching queried based on input values.
remove_all_variables parsedBody (String) parsedBody (String) The remove_all_variables method takes document body and removes tags (${dummy_tag_value}).
validateTemplate parsedBody (String), tableName (String) parsedBody (String) Validates tags in a document template body. The variables in the tags are matched against the fields/dot-walked fields of the tableName passed as an input argument.
The GeneralFormAPI script include has the following APIs:
API Input Output Description
setDocument headerImage (String), footerImage (String), footnote (String), headerPosition (String), footerPosition (String), pageSize (String) N/A Sets the building blocks/parameters of a document for PDF generation.
createPDF body (String), pages (number) N/A Takes body and number of pages and generates the PDF document. After the document is generated, it is attached to the table that the createPDF action is requested.
setDocTempleInfo headerImage (String), footerImage (String), footnote (String), headerPosition (String), footerPosition (String), pageSize (String) N/A A setter method for setting document template building blocks.
startHTMLParser N/A N/A Opens a write stream for htmlparser to enable document generation.
The GeneralPDF script include has the following APIs:
API Input Output Description
setDocument headerImage (String), footerImage (String), footnote (String), headerPosition (String), footerPosition (String), pageSize (String) N/A Sets document template building blocks.
startHTMLParser N/A N/A Opens a write stream for htmlparser to enable document generation.
stopHTMLParser N/A N/A Closes the write stream after document generation method is complete.
addHTML html (String) N/A Appends html snnipets to the document body.
addNewPage N/A N/A Moves the cursor to the next page.
addCells cells (Object), row_length (String) N/A Adds cells, relevant text, and properties to a table.
addSVG svg (String), position (Object) N/A Adds svg to a document template.
setPDFDoc pdfDoc (Object) N/A Sets pdfDoc objects.
setProperties properties (Object) N/A Sets document properties.
setHeader header (String) N/A Sets the header for a document template.
Note: Not used.
setFooter footer (String) N/A Sets the footer for a document template.
Note: Not used.
setWatermark watermark (String) N/A Sets watermarks on a generated PDF document.
get N/A ByteArrayInputStream Returns a document as a ByteArrayInputStream.