Jump to content

Trying to generate a PDF file from custom module


mbwebmaster

Recommended Posts

Hey everyone

 

I'm trying to generate a PDF file with a custom module.

When i'm generating a PDF file it's outputting the file i'm attaching.

I want to display a PDF without the header, footer or any of those codes showing on the right side of the page.

 

This is what i have so far:

A class with the following code:

<?php
 
class HTMLTemplatePrintLabelPdf extends HTMLTemplate
{
    public $custom_model;
    
    public function __construct($custom_object, $smarty)
    {
        $this->custom_model = $custom_object;
        $this->smarty = $smarty;
        
      
    }
    
    /**
     * Returns the template's HTML content
     * @return string HTML content
     */
    public function getContent()
    {
        $this->smarty->assign(array(
            'custom_model' => $this->custom_model,
        ));
    
        return $this->smarty->fetch(_PS_MODULE_DIR_ . 'pancorderlabel/pdf/printlabel.tpl');
    }

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

 

And on my module main file at hookDisplayAdminOrdeMain submit button this

$pdf = new PDF($custom_object, 'PrintLabelPdf', Context::getContext()->smarty);
            $pdf->render(); 

 

 

Thank you in advance :)

1.PNG

Link to comment
Share on other sites

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...