Jump to content

Save PDF from my custom module to local files


Recommended Posts

I generate a custom pdf in my custom module in prestashop 1.7. I followed the official doc but I don't find how I can save my pdf in the files of my module. I just use this to display my pdf:

 

$pdf->render();

And I have a PDF class:

 

class HTMLTemplateDevisPdf extends HTMLTemplate
{
    public $param;

    public function __construct($param, $smarty)
    {
        $this->param = $param;
        // header informations
        $this->smarty = $smarty;
        $this->title = HTMLTemplateDevisPdf::l('devis');
    }

    /**
     * Returns the template's HTML content
     * @return string HTML content
     */
    public function getContent()
    {
        $this->smarty->assign(array(
            'test' => "ok",
        ));

        return $this->smarty->fetch(_PS_MODULE_DIR_ . 'hcr_devis/views/templates/pdf/devis.tpl');
    }

    public function getLogo()
    {
        $this->smarty->assign(array(
            'test' => "ok",
        ));

        return $this->smarty->fetch(_PS_MODULE_DIR_ . 'my_module/custom_template_logo.tpl');
    }

    public function getHeader()
    {
        $this->smarty->assign(array(
            'test' => "ok",
        ));

        return $this->smarty->fetch(_PS_MODULE_DIR_ . 'hcr_devis/views/templates/pdf/devis_header.tpl');
    }

    /**
     * Returns the template filename
     * @return string filename
     */
    public function getFooter()
    {
        return $this->smarty->fetch(_PS_MODULE_DIR_ . 'hcr_devis/views/templates/pdf/devis_footer.tpl');
    }

    /**
     * Returns the template filename
     * @return string filename
     */
    public function getFilename()
    {
        return 'devis.pdf';
    }

    /**
     * Returns the template filename when using bulk rendering
     * @return string filename
     */
    public function getBulkFilename()
    {
        return 'devis.pdf';
    }
}

I already tried $pdf->Output("name", "F") since prestashop uses tcpdf but it didn't work.

Does someone know how I can save my pdf to my files?

Link to comment
Share on other sites

  • 9 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...