How to create a custom PDF of a record view data

Hello everyone,

I want to generate a custom PDF in record view. And want to add button for pdf in Edit button dropdown as par below image. 

Want to show record view data in PDF as table format.

Parents
  • PDF Manager handles adding the item in the menu when there is a published PDF for that module.

    As for adding data from related records you will need to do some customizations.

    See 's post
    sugarclub.sugarcrm.com/.../how-to-customize-the-sugar-pdf-manager

  • Hello ,

    I have tried it but getting the error:

    TCPDF ERROR: The class SugarpdfSmarty has to be extended and you have to set a location for the Smarty template.

    My code is:

    <?php

    require_once 'include/Sugarpdf/sugarpdf/sugarpdf.pdfmanager.php';

    class PO_Purchase_OrderSugarpdfPdfmanager extends SugarpdfPdfmanager

    {

    public function preDisplay()

    {

    $GLOBALS['log']->fatal("pdf bean->name ".$this->bean->name);
    parent::preDisplay();

    $previewMode = false;

    if (!empty($_REQUEST['pdf_preview']) && $_REQUEST['pdf_preview'] == 1) {

    $previewMode = true;

    }

    if ($previewMode === false) {

    // Select links to add

    $linksToLoad = array('po_purchase_order_ori_order_request_item_1', 'po_purchase_order_poi_purchase_order_item_1');

    foreach ($linksToLoad as $linkName) {

    // @var PO_Purchase_Order $this->bean

    $this->bean->load_relationship($linkName);

    $linkedBeans = $this->bean->$linkName->getBeans();

    // Prepare data

    $linkedData = array();

    foreach ($linkedBeans as $linkedBean) {

    $linkedData[] = PdfManagerHelper::parseBeanFields($linkedBean, true);

    }

    // Assign data to template

    $this->ss->assign($linkName, $linkedData);

    }

    }

    }

    }

    laxmichand

Reply
  • Hello ,

    I have tried it but getting the error:

    TCPDF ERROR: The class SugarpdfSmarty has to be extended and you have to set a location for the Smarty template.

    My code is:

    <?php

    require_once 'include/Sugarpdf/sugarpdf/sugarpdf.pdfmanager.php';

    class PO_Purchase_OrderSugarpdfPdfmanager extends SugarpdfPdfmanager

    {

    public function preDisplay()

    {

    $GLOBALS['log']->fatal("pdf bean->name ".$this->bean->name);
    parent::preDisplay();

    $previewMode = false;

    if (!empty($_REQUEST['pdf_preview']) && $_REQUEST['pdf_preview'] == 1) {

    $previewMode = true;

    }

    if ($previewMode === false) {

    // Select links to add

    $linksToLoad = array('po_purchase_order_ori_order_request_item_1', 'po_purchase_order_poi_purchase_order_item_1');

    foreach ($linksToLoad as $linkName) {

    // @var PO_Purchase_Order $this->bean

    $this->bean->load_relationship($linkName);

    $linkedBeans = $this->bean->$linkName->getBeans();

    // Prepare data

    $linkedData = array();

    foreach ($linkedBeans as $linkedBean) {

    $linkedData[] = PdfManagerHelper::parseBeanFields($linkedBean, true);

    }

    // Assign data to template

    $this->ss->assign($linkName, $linkedData);

    }

    }

    }

    }

    laxmichand

Children
No Data