Magento 2 Extensions:PDF Customizer

From XTENTO Support Wiki
Jump to: navigation, search
This is a guide for Magento 2. This extension is a Magento 2 only extension, we don't offer a version for Magento 1 at this point.




Customizing all your order/invoice/shipment/credit memo as well as product PDFs has never been easier. Easily set up custom PDFs for packing slips or invoices. Export your product catalog into beautifully styled PDFs. Adjust invoices to your local regulations and make sure they match your corporate identity. All using the PDF Customizer extension by XTENTO.

Interested in this Magento 2 Extension?

Head over to our store to purchase this extension: PDF Customizer (Magento 2)

Got questions? Feel free to contact us! Contact Form

Setting up the extension

The extensions configuration section is located at System > XTENTO > PDF Customizer. After installing the extension, make sure to enable the module there.

At System > XTENTO > PDF Customizer you will also be able to enable/disable order/invoice/shipment/credit memo PDFs and specify whether they should be attached to emails sent to your customers.

Managing PDF Templates

To set up custom PDF Templates or set up one of our beautiful ready-to-use PDFs, please go to Stores > Manage PDF Templates.

You will have the ability to add new templates there for each of the following entities:

Once you click "Add New Template" you can select the entity (for example "Orders") to add a new PDF Template for.

You will then be presented with an onboarding screen that shows you our ready-to-use PDF Templates that can be loaded with the click of a button. We would suggest selecting one of the templates that looks good to you, load it, and if required, customize it, or use it as it is.

After clicking "Load Template" you will be see four tabs to configure the PDF Template, which are explained as following:

- Template Name: Specify the template name
- Enable / Disable Template
- Default Template: Whether this is the default template (for example for Orders - if "Default Template" is set to yes, then this means it's the template attached to order emails sent to the customer)
- Store View(s): Which store views should use this template? Set up different templates for different stores/countries

- PDF Filename: Specify the file name to use when this PDF is generated. You can use variables there such as {{var increment_id}} or any other variable you find in the "PDF Template" tab
- Paper Orientation / Format / Margins: Specify the general PDF layout. Most of the time you can use the default values that the "default template" specified there.
- Additional PDFs: Enter template IDs (comma-separated) of additional "attachment" PDFs (such as terms and conditions) you would like to generate and attach to emails when this PDF is triggered, for example on order placement.

Described below, this is the section of the template where you specify the exact PDF contents and layout.

This is a helpful utility - simply click the "Preview PDF" tab and you will instantly see a preview of the changes you've applied in the "PDF Template" tab.

Creating a custom PDF Template

Creating custom PDFs is super easy using the extension. The extension uses the popular "mPDF" library internally to generate PDFs. This is done by converting HTML/CSS into PDF.

You don't need to know HTML or CSS to use the extension. Simply use one of the ready-to-use & beautiful PDF Templates that comes with the extension out of the box.

To customize your PDF Templates you will only need to change text and HTML/CSS. Use one of our ready-to-use templates as the foundation.

mPDF supports many HTML tags:

CSS is supported as well:

The mPDF documentation can be very helpful sometimes if you hit a roadblock. Check out this topic on "images" for example:

Template Layout

Go to Stores > Manage PDF Templates and add or edit one of the existing templates. The actual PDF is generated via the HTML/CSS specified in the "PDF Template" tab when editing a PDF profile.

The general layout of a PDF Template is as following: ##header_start##
...header HTML here...
...body HTML here...
...footer HTML here...

There are three sections:

Theoretically you can leave the header and footer empty, however, the body should be there. Also, the template structure (##header_start##...##header_end##...##body_start##... etc.) must always be present.

Between each of the sections you can use almost any HTML Tag. Use that to build your PDF Template using divs/tables/etc., and be sure to use our sample templates as a foundation to see how to get started.

Outputting Items
Within the body, if you want to output order/invoice/... items, you will need to put the data that is output "for each item" in the following block: ##items_start##
...item data here, this data is output N times for each item in an order/invoice/...

Additional Item Filters
Within the items_start and items_end section, you can specify "item settings" to tell the module that only specific product types (just visible items, or just configurable items, or items without parent items) should be shown in the PDF: <!--item_configuration:mode=visible--> or <!--item_configuration:hidden_types=virtual,downloadable--> or <!--item_configuration:hide_parent_items=true--> or <!--item_configuration:hide_child_items=true--> or combine them <!--item_configuration:mode=visible;hidden_types=virtual,downloadable-->


Hundreds of different variables can be used to add dynamic content into your PDFs. In the "PDF Template" tab, simply click one of the variable buttons to see the available variables. By clicking on a variable, it will be inserted at the current cursor position.

Easily add variables such as order, invoice, shipment, credit memo and item information as well as product attributes to your PDF Template. For product exports, you can also access all product-related information as well.

Example how to output the customer email: {{var order.customer_email}}

You can easily see all available variables by clicking the buttons in the "PDF Template" tab.

It is also possible to apply modifiers to variables, for example to convert new lines to <br/> html tags: {{var order.some_field|nl2br}}

Prefix your field with "custom_" to get a localized version, for example of date or currency values: {{var custom_order.created_at}}

Outputting the product image thumbnail can be done like this (as a reminder, all variables can be found via the "Show variables" buttons easily): {{var order_item_product.thumbnail_image_html}}


The extension supports dozens of different barcode types that can be output into PDFs:

Outputting barcodes couldn't be simpler. Let's say you currently output the invoice# like this:

{{var invoice.increment_id}}

To output the invoice# as a c128 barcode simply add "barcode_c128_" in front of the variable name:

{{var barcode_c128a_invoice.increment_id}}

Supported for: order, invoice, shipment, creditmemo and customer prefixes. Another example:

{{var barcode_QR_order.entity_id}}

This works for almost any of the variables that can be output.


In general, most of the directives ({{...}}, can be described as "functions") that you are familiar with from the Magento "email template" system can be used. See here for more details about directives.


Used to translate text in the PDF templates: {{trans "Once your package ships we will send you a tracking number."}} or {{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}}

It is recommended to output all the text in your PDF Template like this, to make sure localization works once you add, for example, another store view in another language.

{{depend}}, {{if}}, {{else}}

If-then-else or just if constructs can be set up using the depend, if and else directives.

Example, for an "if without else", just append "_if" to the variable you are trying to access, before the "dot":

{{depend customer_if.telephone}}
...output something if customer telephone is not empty...

Or another example for an if-then-else if the "order field some_field" evaluates to 1:

{{if order_if.some_field}}
...output something...
...output something else...

You cannot use logical expressions (if X is 123) in depend and if directives. Instead, you will need to set up a variable that evaluates to 0 or 1 and use it with depends/if. Contact us if you need help.


Get a value from the Magento "System" configuration. Example:

{{config path="web/unsecure/base_url"}}

Allowed "path" values:

Example to get the store city: {{config path="general/store_information/city"}}


The store directive is used to retrieve the stores URL: {{store url=""}}


Output a custom variable (maintained at System > Custom Variables):

{{customVar code="..."}}

Adding images in PDFs

You can either upload images to a webserver and embed it in the PDF Template like this: <img src=""/>

where you simply place the full link to the image in the "src" tag. This, however, only works if your Magento server is able to connect to "itself" via http/https, which sometimes isn't the case. In that case, simply host the image elsewhere or use an absolute path such as /var/www/folder/media/image.jpg to embed the image.

Or in case you want to upload the logo in the Magento backend, you can simply use the following logo variable which takes the image you upload at "Stores > Configuration > Sales > Sales > Invoice and Packing Slip Design > Logo for PDF Print-outs": <img src="{{logo_url}}"/>

It is also possible to dynamically retrieve the path to an image using the {{media}} directive: <img src="{{media url="images/some_image.png"}}" alt="" />

Using the extension

The PDFs you set up that have "Default Template" set to "Yes" will be used when printing invoices/shipments etc. from within an order/invoice/shipment/credit memo.

To print your custom PDFs, simply go to, for example, the Sales > Orders grid and select the "Print PDF: ..." action from the "Actions" dropdown.

Printing products/the catalog is possible from the Catalog > Products grid using the "PDF Catalog" mass action as well as from within a product using the "Print PDF" button.


Personal tools
General Information
Magento 2 Guides
Magento 2 Extensions
Magento 1 Guides
Magento 1 Extensions
Magento Integration Suite
Product Feed Guides