PDF Invoice
Module description
Magedia PDF Invoice module for Magento 2 is a professional tool that helps a store admin quickly and easily customize invoices and other billing documents and send them to customers. Extension functionality allows a user to select from several modern ready-to-use PDF templates, right after module installation or create his own PDF docs and customize them with ease. Furthermore, it is possible to add a company logo and various images to the PDF file, implement QR codes and barcodes with additional info about online stores or store products. A4 & US Letter PDF's sizes and RTL version are available. Both store admins and customers can download, print or send these documentation via email.
Account & Pricing
A separate account creation won’t be needed for installation of the extension. There are some additional charges to use Magedia services: - installation fee ($35); - extension support/12 months ($300). For any inquiries please contact us.
Features
- Use pre-configured templates
- Generate your own PDF templates with HTML code
- Create an unlimited number of templates
- Add barcodes to your templates
- Automatically attach PDF files to sales emails
- Print all PDF documents separately or in bulk
- Polish your PDF templates with images and logos
- Use different templates for various Store Views
- Handy Template Preview functionality
- LTR & RTL formats are available
System requirements
Your store should be running on Magento Community Edition version 2.3.x or 2.4.x.
Installation
You can follow this link to check the Installation Guide.
NOTE: Please also make sure the additional libs named mpdf/mpdf and mpdf/qrcode are installed on the server. To install them via composer please run the following command: cat composer.json | grep -q 'magento/project-community-edition' && (composer require mpdf/mpdf "^8.1" ; composer require mpdf/qrcode "^1.2" ; composer dump-autoload) || echo 'composer.json seems to be broken! cannot install.'
General Settings
To configure the extension, go to Magedia → PDF Invoice → Configuration
General
Order
Expand this tab to configure the general settings of PDF order.
Enabled - set to Yes to activate the extension.
Attach PDF files to Emails: Set to Yes to include PDF files into emails.
Admin: Print All Button Label - This option allows you to print all
documents related to this order. You can set a custom name for this
button label.
To see the result, please go to the Admin panel -> Sales -> Orders -> "Actions" dropdown above the grid.
Admin: Print Order Button Label - This option allows you to create a
custom Print order button on the Order page in Admin panel. You can set
a custom name for this button label.
To see the result, please go to the Admin panel -> Sales -> Orders -> Order page
Admin: Print Bulk Orders Button Label - This option allows you to
print several orders selected from the grid. You can set a custom name
for this button label.
To see the result, please go to the Admin panel -> Sales -> Orders -> Actions dropdown above the grid.
Show in Customer Account: Choose "Custom PDF" option to replace the
default Print link and enable customers to download a customized version
of PDF file right from their account.
Select "Both" to enable both default and customized PDF document
printing.
Customer: Print Order Button Label: This option allows the Customer
to print the order from his account. You can set a custom name for this
button label.
Customer: Print Bulk Orders Button Label- This option allows the
Customer to print several orders from his account. You can set a custom
name for this button label.
Configure all these options in the Invoice, Shipment and
Credit Memo tabs.
The example of a Customer: Print Order Button Label with custom name
on the backend:
The example of a Customer: Print Order Button Label on the frontend:
Save the configuration.
PDF Templates
To manage all PDF templates in a handy grid, go to Magedia → PDF Invoice → Manage Templates.
Magento 2 PDF Invoice extension provides you with a set of
pre-configured templates for invoices, orders, shipments and credit
memos.
To modify the existing template, click on the Edit link of the Action
column in the corresponding row on the grid.
The extension also allows you to sort the documents by their Status, Template Type, ID and so on.
You can also enable, disable, duplicate or delete the particular document using "Actions" dropdown above the grid.
Template Customization
To create a new template, hit the Add Template button and choose the
document type from the dropdown.
General Settings tab
- Template Name: Specify the template name
- Template Enabled: Enable or disable the template
-
Default Template: Specify whether the template is default or not (for example for Orders - if "Default Template" is set to Yes, then this means this template will be attached to the emails that are sent to the Customer and also this template will be applied to downloadable files and those files that will be printed)
-
Store View: Specify which store views should use this template. You can set up different templates for different stores or countries.
- Customer Group: Choose the customer groups for which the template will be used.
- Priority: Specify the priority for the template. If an order has several templates for one type of document, the template with the highest priority will be applied. Here 0 is the lowest priority.
PDF Configuration
-
PDF Filename: Specify the file name that will be used after the PDF is generated
-
Use Legacy Mode: Beginning with Magento 2.3.4, only scalar values for variable data are allowed to be used in custom email templates (see more info here). Legacy Mode allows you to use direct calls to methods when working with custom email templates in our module. Choose "Yes" to allow this option.
PDF Configuration
- Paper Orientation: Specify the general PDF layout (portrait or
landscape)
- Page format: Choose the necessary page format
- Text direction: Specify the direction of the text. Extension support for Right
To Left language too(e.g. Arabic, Hebrew, Syriac, etc.)
- Custom Page Format: Choose Yes to specify custom size of the document
- Custom Page Format: Choose Yes if you want to set custom height and width of the document and then set the required values in the lines below.
Set the document margins in the lines below. - Custom Note: If necessary, add your custom note to the document. For example, terms and conditions of your Store.
PDF Template
This is the section of the template where you specify the exact PDF
contents and layout.
With the help of the extension it is easy to create a new custom PDF. To
generate PDFs we integrated the module with the popular "mPDF" library
which helps to convert HTML/CSS into PDF. Thus to create new PDF
documents you don't need to know HTML or CSS. Simply use one of the
ready-to-use PDF Templates that comes with the extension out of the box
as the base.
You can see the tags supported by the mPDF library here:
https://mpdf.github.io/html-support/html-tags.html
As well as tags that are supported by CSS:
https://mpdf.github.io/css-stylesheets/supported-css.html
Order ID - Please insert here the order increment ID from the order
grid.
PDF Template Content - Use HTML/CSS editor to modify your template.
Click the Insert Base Variable button to add a new block to your
template.
Use any of the default Magento variables:
Click the Insert Template Variable button to add a new block to your template.
Lots of different variables can be used to add dynamic content to your
PDFs. In the "PDF Template" tab, simply click one of the variable
buttons to see the available variables. When clicking on a variable, it
will be inserted at the current cursor position.
You can use various Template variables to add varied content into your
PDFs.
Easily add variables such as order, invoice, shipment, credit memo and
item information as well as product attributes to your PDF Template.
See an example on how to output the customer email:
{{var order.customer_email}}
For a list of all fields, simply use the "Insert Template Variable" buttons in the "PDF Template" tab and you can see which fields are there and how they are called exactly.
Barcodes
The module supports various barcode types that can be inserted into PDFs. See their list here:
-
ean13
-
isbn
-
issn
-
upca
-
upce
-
ean8
-
imb
-
rm4scc
-
kix
-
postnet
-
planet
-
c128a
-
c128b
-
c128c
-
ean128a
-
ean128b
-
ean128c
-
c39
-
c39+
-
c39e
-
c39e+
-
s25
-
s25+
-
i25
-
i25+
-
i25b
-
i25b+
-
c93
-
msi
-
msi+
-
codabar
-
code11
-
qr
To output the barcode, please use the following example:
Let's say you have the order# like this:
{{var order.increment_id}}
Use this tag combination to output the order# as a ean13 barcode:
This option is supported for: order, invoice, shipment, credit memo.
Another example:
Directives
Most of the directives ({{...}} that are used in the Magento "email template" system can be used. See the details below.
{{trans}}
This directive is used for text translation in the documents. See an example of trans directive usage:
{{trans "After we ship your goods we will update your order with the tracking number."}}
{{depend}}, {{if}}, {{else}}
If-then-else or just if constructs can be set up using the depend, if and else directives.
See an example of depend variable usage.
If customer email is not empty in the order, the following text will be
added to the order template: As soon as your order is shipped you will
receive a confirmation email including track and trace details.
{{depend order.customer_email}}
As soon as your order is shipped you will receive a confirmation email including track and trace details.
{{/depend}}
Or another example for an if-then-else if the "order field some_field" evaluates to 1:
{{if order.customer_email}}
As soon as your order is shipped you will receive a confirmation email including track and trace details. {{else}} Please add your email address to your customer account in order to receive a confirmation email including track and trace details when your order is shipped. {{/if}}
Sections that can be used for "depends": billing, shipping, customer, order, invoice, shipment, credit memo, store information.
The usage of "for constructs"* for Invoice Items и Item Product variables display*
In order to display some variables (such as Invoice Items and Item Product) it is necessary to use "for constructs". For example:
To add {{var item.product.description}} variable in the Template you
need to insert such a code construction:
{{for item in order.items}}
{{var item.product.description}}
{{/for}}
Adding images in PDFs
You can add images to you Template, to do this upload images to a web
server and use a "src" tag with the full link to the image :
<img src="https://www.server.com/my/folder/image.jpg"/>
NOTE: This method works if your Magento server is able to connect to "itself" via http/https. Alternatively, you need to host the image on another server or use an absolute path such as /var/www/folder/media/image.jpg to insert the image. It is recommended to upload the images where the width equals the height.
It is also possible to dynamically retrieve the path to an image (stored in the "media" folder of Magento) using the {{media}}
directive:
<img src="{{media url="some_folder/some_image.png"}}" alt="" />
Preview PDF
NOTE: If you have an error and unable to download the template, please make sure the additional libs named mpdf/mpdf and mpdf/qrcode are installed on the server. To install them via composer please run the following command: cat composer.json | grep -q 'magento/project-community-edition' && (composer require mpdf/mpdf "^8.1" ; composer require mpdf/qrcode "^1.2" ; composer dump-autoload) || echo 'composer.json seems to be broken! cannot install.'
Use this utility to see a preview of the changes you have made in the
"PDF Template" tab. You can also print or download the document - just
click the Print or Download button.
Documents Printing
To print all PDF documents in bulk, go to Sales → Orders and select the "Print Invoice: Print All" action from the "Actions" dropdown menu. Be sure not to confuse them with the default-Magento print options, as those will return the old PDFs!
If you want to print a particular PDF file, open the order you need and click the PDF Invoice:Print Order button.
You can also print the PDF file on the Preview PDF tab - just click the Print button.
Module Update
When a new update is available, we will provide you with a new package containing our updated extension. You will have to delete the module directory and repeat the installing steps above. Flush the config cache. Your store and newly installed module should be working as expected.
Module Support
We offer lifetime free updates and 3-months free support for all of our paid products. Support includes answering questions related to our products, bug/error fixing to make sure our products fit well in your site exactly like our demo. Support does not include other services such as customizing our products, installation and uninstallation service.