# PDF Wizard (List View)

<div><figure><img src="https://2707432902-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGZA5kgM4oTQMrpISbVT3%2Fuploads%2F4puasoktY0pl6q6l3sDZ%2F215.jpg?alt=media&#x26;token=2d8d4c2e-2a1b-4a8e-889e-30f038b1f2fb" alt=""><figcaption><p>PDF Wizard</p></figcaption></figure> <figure><img src="https://2707432902-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGZA5kgM4oTQMrpISbVT3%2Fuploads%2FGjHSjW0XS7X7CWyQeioS%2F216.jpg?alt=media&#x26;token=d1085331-73d7-4d14-9753-175fce0edb4c" alt=""><figcaption><p>Select Items from List</p></figcaption></figure></div>

In order to copy the **Generate PDF** UI Action to selectively print labels from list view:

1. Copy the UI Action
   1. Visit **Yansa PDF Generator -> Label Templates** in the left nav.
   2. Right-click the form header and select **Configure -> UI Actions**.
   3. Select & open the UI Action titled 'Generate Labels from Selection (Sample).
   4. Update the **Name** and **Table** fields to match the table where you wish to place the list choice 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.
2. Visit the standard list view for the specified table. Select some items and click the list item to open the **Generate Labels from Selection** wizard.

{% hint style="info" %}
Generating PDF labels from list view is not available in UI Builder/Workspace lists.
{% endhint %}

### Customization Options

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

```javascript
var modalOptions = {};
modalOptions.merge_read_only = true;
modalOptions.merge_step_display = false;
modalOptions.source_table = g_list.getTableName();
modalOptions.pdf_template = 'db61bb64c3612a500be07fedd40131b2';

var selectedRecords = g_list.getChecked();
if (selectedRecords.length > 0) {
    var ga = new GlideAjax('PDFGeneratorAjax');
    ga.addParam('sysparm_name', 'createDataSource');
    ga.addParam('sysparm_table', g_list.getTableName());
    ga.addParam('sysparm_ids', selectedRecords);
    ga.getXMLAnswer(renderModalCallback);
}

function renderModalCallback(answer) {
    modalOptions.pdf_data_source = answer;
    var pdfModal = new GlideModal("x_yala_pdf_pdf_generator_list", false, "modal-lg");
    pdfModal.setTitle("Generate PDF");
    for (var key in modalOptions){
        pdfModal.setPreference(key, modalOptions[key].toString());
    }
    pdfModal.render();
    pdfModal.on('beforeclose', function() {
        var ga = new GlideAjax('PDFGeneratorAjax');
        ga.addParam('sysparm_name', 'deleteDataSource');
        ga.addParam('sysparm_id', modalOptions.pdf_data_source);
        ga.getXMLAnswer(function() {
            console.log('Data source removed.');
        });
    });
}
```

To customize the behavior of the wizard, you can set any option below on the **modalOptions** object.

Customize the **Select Template** step:

* **modalOptions.select\_step\_display: \[boolean]:** Show/hide the first 'Select template' step. Otherwise, template must be pre-set *\[default: true]*
* **modalOptions.pdf\_template: \[sys\_id of template]**: Preset the selected template
* **modalOptions.pdf\_template\_read\_only: \[boolean]:** Display the 'Select template' step, but enable/disable it as read-only *\[default: false]*
* **modalOptions.pdf\_template\_display: \[boolean]:** Display the 'Select template' step, but show/hide the select box *\[default: true]*

Customize the **Merge Data** step:

* **modalOptions.merge\_step\_display: \[boolean]:** Show/hide the second 'Merge data into PDF' step. Otherwise, data source/record must be pre-set *\[default: true]*
* **modalOptions.source\_table: \[tableName]:** Set the source table for merge data
* **modalOptions.source\_table\_include\_extensions: \[boolean]:** Include extended tables from source table
* **modalOptions.source\_record\_table: \[tableName]:** Set the source table for merge data
* **modalOptions.source\_record\_id: \[sys\_id of record]:** Set the source record for merge data
* **modalOptions.merge\_read\_only: \[boolean]:** Enable/disable the 'Merge data into PDF' step as read-only *\[default: false]*
* **modalOptions.pdf\_data\_source: \[sys\_id of data source]:** Set data source for merge data. *(Note: Only applies to label printing)*

Customize the **Edit PDF** step:

{% hint style="info" %}
The 'Edit' step is not currently available in list views.
{% endhint %}

Customize the **Save PDF** step:

* **modalOptions.save\_step\_display: \[boolean]:** Show/hide the third 'Save PDF' step *\[default: true]*
* **modalOptions.enable\_download: \[boolean]:** Enable the 'Download' option *\[default: true]*
* **modalOptions.enable\_save\_to\_current\_table: \[tableName]:** Enable the 'Attach to current' option. *\[default: false]*
* **modalOptions.enable\_save\_to\_current\_id: \[sys\_id of record]:** Enable the 'Attach to current' option. *\[default: false]*
