[Prestashop development] Edit, Modify a PDF file in Prestashop?

Step 1: find a Entry PHP Class file that executed to generate your PDF file.

  • invoice** tpl: Entry PHP class is PRETSASHOP_ROOT\override\classes\pdf\HTMLTemplateInvoice.php or PRETSASHOP_ROOT\classes\pdf\HTMLTemplateInvoice.php
  • delivery-slip** tpl: Entry PHP class is PRETSASHOP_ROOT\override\classes\pdf\HTMLTemplateDeliverySlip.php or PRETSASHOP_ROOT\classes\pdf\HTMLTemplateDeliverySlip.php
  • order-slip** tpl: Entry PHP class is PRETSASHOP_ROOT\override\classes\pdf\HTMLTemplateOrderSlip.php or PRETSASHOP_ROOT\classes\pdf\HTMLTemplateOrderSlip.php
  • order-return** tpl: Entry PHP class is PRETSASHOP_ROOT\override\classes\pdf\HTMLTemplateOrderReturn.php or PRETSASHOP_ROOT\classes\pdf\HTMLTemplateOrderReturn.php
  • supply-order*** tpl: Entry PHP class is PRETSASHOP_ROOT\override\classes\pdf\HTMLTemplateSupplyOrderForm.php or PRETSASHOP_ROOT\classes\pdf\HTMLTemplateSupplyOrderForm.php

Step 2: Open a Entry PHP Class, for an example we open file HTMLTemplateInvoice.phpeach Entry PHP class extends from HTMLTemplate.php and it always have 3 main functions

  • getHeader(): Assign data and execute to get the header of PDF file
  • getFooter(): Assign data and execute to get the header of PDF file
  • getContent(): Assign data and execute to get the header of PDF file

if you want assign new values from PHP to *.tpl PDF template file, you can use this function of Smarty

$this->smarty->assign(‘new_variable’, ‘new value’);

Example my image

edit-pdf-file-16

Step 3: Open a *.tpl PDF file in PRESTASHOP_ROOT/pdf, print new value with statement:

{$new_variable1}

Our sample source code:

edit-pdf-file-17

Use an External Prestashop invoice module

You can try to use our Prestashop Invoice & Delivery Slips, Credit Slips Template Builder with Custom Number Pro module at here: https://buy-addons.com/store/prestashop/module/prestashop-invoice-template-builder-module.html

This module can help you modify invoice, delivery, credit slips, supply order PDF file from Prestashop backoffice. Also it have 18 professional PDF template as well !!!

Other important post: How to change, modify Invoice, Delivery, Credit Slip, Supply Order, Return PDF files in Prestashop website?

Related Articles

Leave a reply

You must be logged in to post a comment.