Invoice PDF Generator For Magento 2

Last update: Oct 18, 2021

Magento Invoice PDF Generator CircleCI

Maintainability

Magento 2 Invoice PDF Generator - helps you to customize the pdf templates for Magento 2. If you have an enabled template and a default template for the store you need your template the system will print the pdf template.

B2C Theme demo

How to use the module

Add a new template from the "Add new template" button. This will prompt you with a set of fields.

  • Enable template - you need to enable the template in order to use it;
  • Default template - make the template as default for the current store;
  • Template name - this is for your own information as well as the template description;
  • Template for website - here you select the website you need the template for;
  • The template body, header and footer is where you can add the html that will be transformed into the PDF body;
  • The template CSS filed allows you to create styles for the html like "h1 {color:red;} h2 {color:blue}", do not use the style tag, it is not need. In the body you can also specify html like in the email templates;
  • The template settings are used to shape the template as you need. The "Template file name" can be made from variables as long as they are ok for file naming {{var invoice.increment_id}}-{{var invoice.id}}-file-invoice. The "Template paper orientation" is used to set the pdf as landscape or portrait. If you chose to use the custom format the "Custom height" and "Custom width" in millimeters will be used. The paper orientation and the "Template paper format" will be ignored in this case. If the template has standard format the "Template paper format" will allow you to set the paper in a few formats (A4,A5,A3,Letter and Legal). The other settings are the margins (in millimeters) for the top, right, left and bottom. If the header or footer overlaps over your body increase the top and bottom margins to fix this.

The extension will allow you to harness all the power of the email template system and more. You can add phtml files to your template for very advanced configurations ({Error in template processing} and {Error in template processing}). You can add your own item processing layout so you can output taxes item prices as you want ({{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}}).

You can also localize your template using the trans directive.

{{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}}{{trans "Once your package ships we will send you a tracking number."}}

Using the extension you are able to change the invoice PDF as you desire. The PDF Generator has multiple features as follows:

  • change the Magento invoice PDF to meet your needs;
  • add custom CSS to your template to further personalize the PDF;
  • add templates for each store with different design and features;
  • change the file name of the PDF file using variables;
  • you can send the invoice as PDF attachment to the invoice mail;
  • you can disable enable the PDF from the system configuration area.

For the variable system you can read the Magento domentation here. We use the exact same system to generate the variables.

Supported Versions

  • Magento 2.1.*
  • Magento 2.2.*
  • Magento 2.3.*

Installation

You can install the module via composer or manually by adding it to the app/code directory. The module is available on packagist.org

Via composer:

composer config repositories.magento2-pdf-generator2 git [email protected]:EaDesgin/magento2-pdf-generator2.git
composer require eadesignro/module-pdfgenerator
php bin/magento setup:upgrade

Requirements

Video install and use

IMAGE ALT TEXT HERE

GitHub

https://github.com/EaDesgin/magento2-pdf-generator2
Comments
  • 1. Magento 2.2 Compatibility

    This module has a hard requirement on version 100.1.* of several Magento modules. Magento 2.2 was released today and it would be nice to have compatibility for this new Magento version.

    Reviewed by danslo at 2017-09-26 21:18
  • 2. Unexpected error during installation

    CE 2.3.0 , Php 7.1 after installation, before Success page displays an error shown in the image attached here. Previous versions showed Exception Printing Error messages. 2019-02-14_18-58-05

    I downloaded the zip and extracted in APP Folder and Enabled it through Setup Wizard>Module Manager

    Reviewed by rishabhchd19 at 2019-02-14 14:24
  • 3. PHP Errors after migration to Magento 2.2 and PHP7.1

    After the migration to Magento 2.2 and PHP 7.1 I got PHP errors in the mpdf library files. File cssmgr.php method MergeCSS tries to set $attr['ID'] for not initialized variables. I fixed it locally by changing if (!isset($attr['ID'])) { $attr['ID'] = ''; }

    to

    if (!isset($attr['ID'])) { if (!is_array($attr)) { $attr=array("ID"=> ''); } else { $attr['ID'] = ''; } }

    File mpdf.php method ConvertSize has an implicit cast from string to float, witch results to the following error message:

    Warning: A non-numeric value encountered in /var/www/magento/vendor/eadesignro/mpdf/mpdf.php on line 30648

    I fixed it locally by changing ` }} else { $size *= (25.4 / $this->dpi); //nothing == px }

    ` to

    ` } elseif (is_numeric ($size)) { $size *= (25.4 / $this->dpi); //nothing == px } else { $size = floatval ($size *(25.4 / $this->dpi); //nothing == px }

    ` Is it possible to upgrade EaDesgin/mpdf to the current branch of mpdf/mpdf?

    Reviewed by nobodyMO at 2017-10-06 13:26
  • 4. Admin Login Error after installing the module

    1 exception(s): Exception #0 (OutOfRangeException): Specified invalid parent id (Eadesigndev_Eacore::eadesign)

    Exception #0 (OutOfRangeException): Specified invalid parent id (Eadesigndev_Eacore::eadesign) #0 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Backend\Model\Menu\Builder->getResult(Object(Magento\Backend\Model\Menu)) #1 /var/www/html/var/generation/Magento/Backend/Model/Menu/Builder/Interceptor.php(39): Magento\Backend\Model\Menu\Builder\Interceptor->___callPlugins('getResult', Array, Array) #2 /var/www/html/vendor/magento/module-backend/Model/Menu/Config.php(146): Magento\Backend\Model\Menu\Builder\Interceptor->getResult(Object(Magento\Backend\Model\Menu)) #3 /var/www/html/vendor/magento/module-backend/Model/Menu/Config.php(109): Magento\Backend\Model\Menu\Config->_initMenu() #4 /var/www/html/vendor/magento/module-backend/Model/Url.php(348): Magento\Backend\Model\Menu\Config->getMenu() #5 /var/www/html/vendor/magento/module-backend/Model/Url.php(308): Magento\Backend\Model\Url->_getMenu() #6 /var/www/html/vendor/magento/module-backend/Controller/Adminhtml/Index/Index.php(21): Magento\Backend\Model\Url->getStartupPageUrl() #7 /var/www/html/var/generation/Magento/Backend/Controller/Adminhtml/Index/Index/Interceptor.php(24): Magento\Backend\Controller\Adminhtml\Index\Index->execute() #8 /var/www/html/vendor/magento/framework/App/Action/Action.php(102): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->execute() #9 /var/www/html/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http)) #10 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http)) #11 /var/www/html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->___callParent('dispatch', Array) #12 /var/www/html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Backend...', 'dispatch', Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor), Array, 'adminAuthentica...') #13 /var/www/html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain{closure}(Object(Magento\Framework\App\Request\Http)) #14 /var/www/html/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #15 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Backend...', 'dispatch', Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor), Array, 'adminMassaction...') #16 /var/www/html/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http)) #17 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #18 /var/www/html/var/generation/Magento/Backend/Controller/Adminhtml/Index/Index/Interceptor.php(39): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array) #19 /var/www/html/vendor/magento/framework/App/FrontController.php(55): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #20 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http)) #21 /var/www/html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array) #22 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install') #23 /var/www/html/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http)) #24 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #25 /var/www/html/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array) #26 /var/www/html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #27 /var/www/html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch() #28 /var/www/html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http)) #29 {main}

    Reviewed by shazadmaved at 2017-01-04 08:53
  • 5. "Print" prints normal magento2 invoice

    I can successfully intall the module. The db table are there. The admin config is there. But when I click on "print" it creates just the normal magento2 invoice. Any idea?

    Reviewed by jaykobi at 2016-08-17 08:00
  • 6. Error when di compile on Magento 2.3.0

    When I run setup:di:compile I get following error

    Class Magento\Email\Model\Source\Variables does not exist                                             
      Class Eadesigndev\Pdfgenerator\Controller\Adminhtml\Variable\Template\Interceptor generation error:   
      The requested class did not generate properly, because the 'generated' directory permission is read-  
      only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' direc  
      tory permission is set to write --- the requested class did not generate properly, then you must add  
       the generated class object to the signature of the related construct method, only.
    

    This is because the referred Magento class does not exist. In below class, /var/www/magento-docker/src/vendor/eadesignro/module-pdfgenerator/Controller/Adminhtml/Variable/Template.php it tries to use a class which is not available on Magento.

    In magento 2.3.0 below class is not available use Magento\Email\Model\Source\Variables as EmailVariables;

    Reviewed by chamikax at 2018-12-12 12:04
  • 7. Feature Request - print multiple invoices at once

    The current implementation can only print single invoices. For 40+ invoices you need to navigate into every single order and print the invoices individually.

    The default invoice module of magenta as well as postage printing can print via a mass action for a number of selected orders at once. This extension should not be worse then the default module.

    Reviewed by MarcusWolschon at 2018-09-03 11:41
  • 8. Issue after manual installation

    After installing the module manually. And after runing php bin/magento setup:upgrade I get the following error.

    image

    Is there any version bug in the last release (1.23) ? I installed the last version from master.

    Reviewed by cristianst at 2017-11-29 08:42
  • 9. Incorrect status of an order in Invoice

    There's an issue in displaying the Order Status. The order status it displays as Status Code, not a Status Title. Like, I changed the status from Default to but default code doesn't change and remains same as "processing". When an invoice is generated it doesn't display Processed but shows processing while the order status shows correct in the Admin as Status> Processed. 2017-10-13_21-41-16 2017-10-13_21-44-25

    Reviewed by rishabhchd19 at 2017-10-13 16:24
  • 10. Not working on magento CE 2.1.7

    Module is activated from stores->configuration, Template is activated and set as default. If i try to print the order i get the magento defult template, the invoice is not sent by email. No errors. Nothing in logs.

    Can you help with this issue please?

    Reviewed by blacklizardul at 2017-07-28 13:26
  • 11. Compilation issue

     Total Errors Count: 1
     Errors during compilation:
     Eadesigndev\Pdfgenerator\Controller\Adminhtml\Templates\Edit 
     Incorrect dependency in class Eadesigndev\Pdfgenerator\Controller\Adminhtml\Templates\Edit 
     in /var/www/html/vendor/eadesignro/module-pdfgenerator/Controller/Adminhtml/Templates/Edit.php
     \Magento\Backend\Model\Session already exists in context object
    
    Reviewed by gewaechshaus at 2017-04-01 20:55
  • 12. Fix TransportBuilder for Magento2.3.5 compatibility

    Remove di for Message preference, update TransportBuilder to handle attachment, update SenderBuilder to use TransportBuilder

    Module latest 12.10 allows PHP7.3 but dev dependencies for testing require <7.3 so no test for this PR. Fix the dev dependencies in the latest version and we can have tests here.

    Reviewed by thisisandrew at 2020-11-26 16:05
  • 13. 'Insert Variable' functionality in templares does not work (Exception, call on null)

    In Magento 2.3.5 and Magento 2.4 as well, i can not make the variables to work.

    When you try to create or edit a PDF template and press the 'insert variable' button an error occures:

    Error: Call to a member function getId() on null in /app/web/vendor/magento/module-email/Block/Adminhtml/Template/Edit.php:295
    ...
    

    I managed to find the potential cause for this, in Line 134-136 of /Controller/Adminhtml/Variable/Template.php bute evene if i changed it to something like this (as copied from module-email), its not fixed (but then you even will get json response...)

    $templateBlock = $this->_view->getLayout()->createBlock(
                    \Magento\Email\Block\Adminhtml\Template\Edit::class,
                    'template_id',
                    [
                        'data' => [
                            'email_template' => $template
                        ]
                    ]
                );
    

    I assume that there have to be made several changes in order to make it compatible to the code of module-email. Actually there are many parts of the code which seem to be deprecated, so this might not be the only problem. Hard to say at this point... But might be a starting point for someone that had the same issue.

    Reviewed by Emanuel-23 at 2020-08-12 13:58
  • 14. Remove deprecated functionality

    The code is full of registry operations and inheritance that should be removed in favor of composition. When updating the extension for Magento 2.4 it would be the right time to refactor the code entirely.

    Reviewed by Emanuel-23 at 2020-08-12 08:54
Magento 2 Product PDF/File Attachment FREE Extension
Magento 2 Product PDF/File Attachment FREE Extension

Overview: Magento 2 Product Attachment extension allows attaching additional information such as manuals, warranty, recipes, etc. in different formats

Jun 22, 2022
A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2

Simple Import / Export tool A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2. Table data

Jun 9, 2022
Magento 2 Code Generator

Magento 2 Code Generator Created by Orba Inspired by https://github.com/staempfli/magento2-code-generator Purpose In day-to-day Magento 2 development

Jun 29, 2022
Code generator for Magento 2
Code generator for Magento 2

Magento 2 Code Generator Tool Installation Option1: Downloading .phar wget https://github.com/staempfli/magento2-code-generator/releases/download/<ver

May 31, 2022
Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)

COPS COPS stands for Calibre OPDS (and HTML) Php Server. See : COPS's home for more details. Don't forget to check the Wiki. Why ? In my opinion Calib

Jun 23, 2022
This Magento 2 extension integrates EasyTranslate into Magento 2.
This Magento 2 extension integrates EasyTranslate into Magento 2.

EasyTranslate Magento 2 Connector This Magento 2 extension integrates EasyTranslate into Magento 2. Mind that you need to have an account with EasyTra

Dec 21, 2021
Magento - Magento Community Editions

Magento Community Edition /// THIS REPOSITORY IS DEPREACTED /// 1.9.4.1 will be the last version update. Please switch over to OpenMage! Either to the

May 26, 2022
Magento-Vagrant-Puppet-Nginx - Installs magento and a nginx server

Magento-Vagrant-Puppet-Nginx Installs Magento MySQL PHP PHP-FPM Nginx n98-magerun Setup git submodule init git submodule update vagrant up Modify pupp

Apr 1, 2022
Docker-magento - Docker image for Magento 1.6 to 1.9

Docker image for Magento 1.x This repo creates a Docker image for Magento 1.x. Please note The primary goal of this repo is to create Docker images fo

Dec 17, 2021
Magento-composer-installer - Composer installer for Magento modules
Magento-composer-installer - Composer installer for Magento modules

!!! support the maintainer of this project via Patreon: https://www.patreon.com/Flyingmana Magento Composer Installer The purpose of this project is t

May 18, 2022
Chef-magento - Installs and Configures a Magento project

Description Requirements Chef 0.10.0 or higher required (for Chef environment use). Platform Debian, Ubuntu CentOS, Red Hat, Fedora Your basebox must

Jun 30, 2020
Cookbook-magento - Collection of recipes to build app stack for the Magento deployments with Chef

Magento Cookbook Collection of recipes to build app stack for the Magento deployments with Chef Installation With Berkshelf echo "cookbook 'magento',

Sep 26, 2020
Magento-bulk - Bulk Import/Export helper scripts and CLI utilities for Magento Commerce

Magento Bulk Bulk operations for Magento. Configuration Copy config.php.sample to config.php and edit it. Product Attribute Management List All Attrib

Mar 25, 2021
Phpcs-magento-rules - A set of PHPCS rules used by made.com when hacking Magento

Made.com PHPCS Magento Rules A set of PHPCS rules used by made.com when hacking Magento. Pre-Requisites PHPCS Installation Short Version Clone this re

Jun 3, 2020
Magento-Functions - A Resource of Magento Functions

Magento-Functions A Resource of Magento Functions Table of Contents Category Product User Cart Checkout General Account [Working w/ URL's] (#urls) Cat

Apr 19, 2021
Foundation 3 Framework for Magento 1.7. Foundation styles and libraries. Magento Responsive theme. Off-canvas Left-Right sidebar columns for mobile.

Magento Foundation 3 Framework Zurb Foundation 3 framework for Magento 1.7. Magento Foundation 3 Version 1.3.0. Demo page: http://magendation.internet

Apr 1, 2022
Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Nov 20, 2021