Customizing the Generate PDF Wizard
Last updated
Last updated
The Generate PDF wizard is designed to be copied & placed wherever it is needed to support your unique use-case. In order to copy the Generate PDF UI Action:
Copy the wizard formatter
Visit System UI -> Formatters in the left nav. Open the formatter titled 'PDF Generator'.
Change the Table to match the table where you wish to place the button that will open the wizard. Insert-and-Stay a new copy of the formatter.
Visit the table where you placed the formatter.
Right-click the form header and select Configure -> Form Layout. Add the 'PDF Generator' formatter to the form (it is not visible, so you can add it anywhere you like)
Copy the wizard button
Visit Yansa PDF Generator -> General Settings in the left nav.
Right-click the form header and select Configure -> UI Actions.
Select & open the UI Action titled 'Generate PDF (Sample).
Update the Name and Table fields to match the table where you wish to place the button that will open the wizard. Following the instructions in the commented code, update code values to accommodate your needs (see below for details on available customizations). Insert and Stay to create a new copy of the UI Action.
Visit the form view for a record on the specified table. Click the button to open the Generate PDF wizard.
By default, the Generate PDF UI Action will have script similar to below:
There are a number of methods on the YansaPDFUI object (in this example, 'pdfModal') that you may use to customize the behavior of the wizard.
Customize the Select Template step:
pdfModal.setSelectStepDisplay(flag: boolean): Show/hide the first 'Select template' step. Otherwise, template must be pre-set [default: true]
pdfModal.setPDFTemplate(sysId: string): Preset the selected template
pdfModal.setPDFTemplateReadOnly(flag: boolean): Display the 'Select template' step, but enable/disable it as read-only [default: false]
pdfModal.setPDFTemplateDisplay(flag: boolean): Display the 'Select template' step, but show/hide the select box [default: true]
Customize the Merge Data step:
pdfModal.setMergeStepDisplay(flag: boolean): Show/hide the second 'Merge data into PDF' step. Otherwise, data source/record must be pre-set [default: true]
pdfModal.setSourceTable(tableName: string, includeExtensions: boolean): Set the source table for merge data
pdfModal.setSourceRecord(tableName: string, sysId: string): Set the source table & record for merge data
pdfModal.setMergeReadOnly(flag: boolean): Enable/disable the 'Merge data into PDF' step as read-only [default: false]
Customize the Edit PDF step:
An optional 'Edit' step can be enabled wherein the content of the merged PDF document can be changed prior to the save/download step. This can be useful for situations where customization of the merged template is needed prior to finalization.
pdfModal.enableEdit(): Enable editing the merged PDF document prior to save/download [default: false]
pdfModal.disableEdit(): Disable editing the merged PDF document prior to save/download [default: true]
Customize the Save PDF step:
pdfModal.setPDFDataSource(sysId: string): Set data source for merge data. (Note: Only applies to label printing)
pdfModal.setSaveStepDisplay(flag: boolean): Show/hide the third 'Save PDF' step [default: true]
pdfModal.enableDownload(): Enable the 'Download' option [default: true]
pdfModal.disableDownload(): Disable the 'Download' option [default: false]
pdfModal.enableSaveToCurrent(tableName?: string, sysId?: string): Enable the 'Attach to current' option. If you provide a table/sysId, it will save to that target record. Otherwise, it saves to current record [default: false]
pdfModal.disableSaveToCurrent(): Disable the 'Attach to current' option [default: true]
To reload form on-close of the wizard (to display new attachments, for example), include the following at the bottom of your UI Action script: