PDF Settings

Overview

An overview of how to manage PDF settings.

PDF Setting Framework

This section will outline how to configure the general PDF settings. There are the settings that determine widths, heights, images and pdf metadata as well as the UI configurations found in:
Admin > PDF Manager > Edit Report PDF Template 

Settings

The default PDF settings for TCPDF can be found in ./include/Sugarpdf/sugarpdf_default.php. You can add additional custom settings by creating the following file:
./custom/include/Sugarpdf/sugarpdf_default.php
<?php
    $sugarpdf_default["PDF_NEW_SETTING"] = "Value";
You should note that values specified here will be the default values. Once edited, the updated values are stored in the database config table under the category “sugarpdf” and a name matching the setting name.
category: sugarpdf
name: pdf_new_setting
value: Value

Displaying and Editing Settings

A select set of settings can be edited within the Sugar UI by navigating to:
Admin > PDF Manager > Edit Report PDF Template
The settings here are managed in the file ./modules/Configurator/metadata/SugarpdfSettingsdefs.php. A brief description of the settings parameters are listed below:
  • label : This is the display label for the setting.
  • info_label : Hover info text for the display label.
  • value : The PDF Setting.
  • class : Determines which panel the setting resides in. Possible values are ‘basic’ and ‘logo’. ‘advanced’ is not currently an available value.
  • type : Determines the settings display widget. Possible values are: ‘image’, ‘text’, ‘percent’, ‘multiselect’, ‘bool’, ‘password’, and ‘file’.
Custom settings can be added to this page by creating ./custom/modules/Configurator/metadata/SugarpdfSettingsdefs.php and specifying a new setting index. An example is below:
./custom/modules/Configurator/metadata/SugarpdfSettingsdefs.php
<?php
    //Retrieve setting info from db
    defineFromConfig("PDF_NEW_SETTING", $sugarpdf_default["PDF_NEW_SETTING"]);
    //Add setting display
    $SugarpdfSettings['sugarpdf_pdf_new_setting'] = array(
        "label" => $mod_strings["LBL_PDF_NEW_SETTING_TITLE"],
        "info_label" => $mod_strings["LBL_PDF_NEW_SETTING_INFO"],
        "value" => PDF_NEW_SETTING,
        "class" => "basic",
        "type" => "text",
    );
You should note that the $SugarpdfSettings index should following the format sugarpdf_pdf_<setting name>. If your setting does not follow this format, it will not be saved or retrieved from the database correctly.
Once the setting is defined, you will need to define the display text for the UI setting.
./custom/modules/Configurator/language/en_us.lang.php
<?php
    $mod_strings['LBL_PDF_NEW_SETTING_TITLE'] = 'PDF New Setting';
    $mod_strings['LBL_PDF_NEW_SETTING_INFO'] = 'Display info for the new PDF setting';
Once finished, navigate to Admin > Repair > Quick Repair and Rebuild. This will rebuild the language files for your display text.