AnsweredAssumed Answered

My custom pdf not working in sugarcrm 8

Question asked by karl el escobar on Feb 20, 2019
Latest reply on Feb 21, 2019 by karl el escobar

Ive been trying to generate an example pdf file in sugarcrm using the example code in the documentation in this link

and tried accessing it through this url:

 

http://sugarpro8.local.com/index.php?module=Meetings&action=sugarpdf&sugarpdf=clientpdf

here is the source code:

 

<?php

require_once('include/Sugarpdf/Sugarpdf.php');

class clientpdf extends Sugarpdf
{
    /**
     * Override
     */
    function process(){
        $this->preDisplay();
        $this->display();
        $this->buildFileName();
    }

    /**
     * Custom header
     */
    public function Header()
{
    $this->SetFont(PDF_FONT_NAME_MAIN, 'B', 16);
    $this->MultiCell(0, 0, 'TCPDF Header',0,'C');
    $this->drawLine();
}

    /**
     * Custom header
     */
    public function Footer()
{
    $this->SetFont(PDF_FONT_NAME_MAIN, '', 8);
    $this->MultiCell(0,0,'TCPDF Footer', 0, 'C');
}

    /**
     * Predisplay content
     */
    function preDisplay()
    {
        //Adds a predisplay page
        $this->AddPage();
        $this->SetFont(PDF_FONT_NAME_MAIN,'',PDF_FONT_SIZE_MAIN);
        $this->Ln();
        $this->MultiCell(0,0,'Predisplay Content',0,'C');
    }

    /**
     * Main content
     */
    function display()
    {
        //add a display page
        $this->AddPage();
        $this->SetFont(PDF_FONT_NAME_MAIN,'',PDF_FONT_SIZE_MAIN);
        $this->Ln();
        $this->MultiCell(0,0,'Display Content',0,'C');
    }

    /**
     * Build filename
     */
    function buildFileName()
    {
        $this->fileName = 'example.pdf';
    }

    /**
     * This method draw an horizontal line with a specific style.
     */
    protected function drawLine()
{
    $this->SetLineStyle(array('width' => 0.85 / $this->getScaleFactor(), 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(220, 220, 220)));
    $this->MultiCell(0, 0, '', 'T', 0, 'C');
}
}

 

here's an screenshot of the error message:

 

 

also my custom pdf file is in the path of /custom/modules/Meetings/sugarpdf/sugarpdf.pdfview.php

 

what did i do wrong here ?

Outcomes