# PDF Wizard (Standard Forms)

<div><figure><img src="/files/ryXmhLMYm6MHDHibuu3b" alt=""><figcaption><p>PDF Wizard (w/o Edit Step)</p></figcaption></figure> <figure><img src="/files/R5XLIMYdaCSJMclvT60R" alt=""><figcaption><p>PDF Wizard (w/ Edit Step)</p></figcaption></figure></div>

In order to copy the **Generate PDF** UI Action for standard forms:

1. Copy the wizard formatter
   1. Visit **System UI -> Formatters** in the left nav. Open the formatter titled 'PDF Generator'.
   2. 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.
   3. Visit the table where you placed the formatter.
   4. 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)
2. Copy the wizard button
   1. Visit **Yansa PDF Generator -> General Settings** in the left nav.
   2. Right-click the form header and select **Configure -> UI Actions**.
   3. Select & open the UI Action titled 'Generate PDF (Sample).
   4. 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 **Script** field, 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.
3. Visit the standard form view for a record on the specified table. Click the button to open the **Generate PDF** wizard.

### Customization Options

By default, the **Generate PDF** UI Action will have a **Script** similar to below:

```javascript
function renderModal() {
    var pdfModal = new YansaPDFUI();
    pdfModal.setSourceTable('sys_user');
    pdfModal.render();
}
```

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]*
* **pdfModal.setPDFDataSource(sysId: string):** Set data source for merge data. *(Note: Only applies to label printing)*

Customize the **Edit PDF** step:

{% hint style="info" %}
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.
{% endhint %}

* **pdfModal.enableEdit():** Enable editing the merged PDF document prior to save/download *\[default: false]*

Customize the **Save PDF** step:

* **pdfModal.setSaveStepDisplay(flag: boolean):** Show/hide the third 'Save PDF' step *\[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]*

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:


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yansalabs.com/pdf-generator/technical-docs/the-generate-pdf-wizard/pdf-wizard-standard-forms.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
