Jump to content

Generate pdf from template


ylli

Recommended Posts

Hello,

 

I have created a new bulk actions for orders. What i want to do is generate a different kind of invoice for all the selected orders. I have created the action and i know how to get the order data i need but i am stuck in generating pdf. Is there any class or method that can generate pdf from an template (.tpl). Or any other way to generate the invoice using the template of course. the template does not have to be tpl it can be an word template or anything else.

 

Any help on this ?

 

Regards

Link to comment
Share on other sites

Prestashop uses TCPDF software to create PDF's from HTML templates

 

I suggest you review the following folders and dig in

 

/classes/pdf - this folder contains the code that generates the PDFs

 

/pdf - this folder contains the html template files

Link to comment
Share on other sites

 

Do something like:

$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
$content = $pdf->render(false);

I have seen these line a lot bu i can not make them work. let me tell you what i have done till now.

 

Well first i tried just two lines as you have shared, i created my .tpl file and added that file name as variable at pdf class. my .tpl template has just some text for the moment i have not aded any html using smarty. I have also created a file called HTMLTemplateInvoiceCustom.php at /classes/pdf but i can not connect these two together. can you guide me how the information flows starting ate my function that i have for the bulk action for the orders?

Link to comment
Share on other sites

  • 2 years later...

i acually manged to generate a bulk_action for invoice/Delivery slip with a solution like the one in an other topic

Now the problem what ever i click after the custom bulk_action, it happens again. Like when i printet the first 25 orders invoice list, and want to go to page 2. Then instead of showing page 2, it just download the same 25 orders incoive again.

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