I need to provide an option for sellers/vendors to download their order information like name, sku, price, qty, etc. in PDF format on a custom page.

I am planning to use any PDF plugin as mentioned in link1 or in link2. I wanted to know which PDF plugin Magento uses to generate invoices [ sales > orders ] in PDF format.

I mean which one of the following does Magento use?

  • ApacheFOP
  • dompdf
  • FPDF
  • html2ps
  • mPDF
  • PDFlib
  • wkhtmltopdf
  • Zend_Pdf
  • 1
    Not an answer to your particular question, but a suggestion based on your use case: Check out PhantomJS. It's a free headless WebKit browser controlled via simple JavaScript logic, and can save directly to PDF and image formats like PNG. You would simply create a page that renders the desired information with HTML/CSS, then invoke PhantomJS to grab the page and render a PDF out of it. It's far more reliable than most "HTML to PDF" converters.
    – Agop
    Dec 21, 2016 at 15:21

4 Answers 4


Magento does not use any plugin to generate the pdfs. It uses Zend_Pdf.
You can take a look at all the classes in here and see how it's done.
Unfortunately Zend_Pdf is not something magical. It requires a lot of work and some knowledge of geometry.
It is like drawing something on a canvas. You ca use methods as drawRectangle or drawText to actually place your elements on the page.
You can find a more detailed documentation about Zend_Pdf here


By default magento using ZEND_PDF to customization on pdf invoice,order and shipment.

You have to refer link for more customization of your task,

You can start from here,

Zend Pdf Customization Basics Link



By default magento uses Zend_Pdf here is sample fo creating your own pdf

simple zend pdf file not generate in magento

If you want to use third party library then i recommend use the tcpdf library it is easy to use.


Try With MPDF Code


namespace VendoreName\ModuleName\Controller\Index;

use Magento\Framework\App\Action\Action;
use Zend_Loader;

class GetPdfData extends \Magento\Framework\App\Action\Action
     * @var \Magento\Framework\View\Result\PageFactory
    protected $resultPageFactory;

     * @var \Magento\Framework\Filesystem\DirectoryList
    protected $dir;

     * @param \Magento\Framework\App\Action\Context $context
     * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\Filesystem\DirectoryList $dir,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
        $this->dir = $dir;
        $this->resultPageFactory = $resultPageFactory;

     * @inheritdoc
    public function execute()
        $pdfData = [];
        $pdfData["body_data"] = "<h1><b>TEST Data</b></h1>";
        $config = [
            'mode' => 'utf-8',
            'format' => 'A4',
            'default_font_size' => 10,
            'default_font' => "dejavusans",
            'margin_left' => 1.5,
            'margin_right' => 1.5,
            'margin_top' => 1.5,
            'margin_bottom' => 1.5,
            'allow_charset_conversion' => true,
            'orientation' => 'P',
            'showBarcodeNumbers' => false,
            'tempDir' => $this->dir->getPath('var'),
        $pdf = new \Mpdf\Mpdf($config);
        $outputData = $pdf->Output('test.pdf', 'I'); // D , F , S

     * Initialization of mpdf library
    protected function initializePDF()

        $path = $this->dir->getRoot() . "/vendor/mpdf/mpdf/src/";

        $this->pdf = $path . 'Mpdf.php';

        //include_once $this->pdf;
        Zend_Loader::loadFile($this->pdf, null, true);

        $this->config = $path . 'Config/ConfigVariables.php';

        // require_once $this->config;
        Zend_Loader::loadFile($this->config, null, true);

        $this->ucdn = $path . 'Ucdn.php';

        // require_once $this->ucdn;
        Zend_Loader::loadFile($this->ucdn, null, true);

        $this->defaultCss = $path . 'Css/DefaultCss.php';

        // require_once $this->defaultCss;
        Zend_Loader::loadFile($this->defaultCss, null, true);

        $this->sizeConvertor = $path . 'SizeConverter.php';

        // require_once $this->sizeConvertor;
        Zend_Loader::loadFile($this->sizeConvertor, null, true);

        $this->colorconverter = $path . 'Color/ColorConverter.php';

        // require_once $this->colorconverter;
        Zend_Loader::loadFile($this->colorconverter, null, true);

        $this->gradient = $path . 'Gradient.php';

        // require_once $this->gradient;
        Zend_Loader::loadFile($this->gradient, null, true);

        $this->tableOfContents = $path . 'TableOfContents.php';

        // require_once $this->tableOfContents;
        Zend_Loader::loadFile($this->tableOfContents, null, true);

        $this->cache = $path . 'Cache.php';

        // require_once $this->cache;
        Zend_Loader::loadFile($this->cache, null, true);

        $this->fontCache = $path . 'Fonts/FontCache.php';

        // require_once $this->fontCache;
        Zend_Loader::loadFile($this->fontCache, null, true);

        $this->fontsFileFinder = $path . 'Fonts/FontFileFinder.php';

        // require_once $this->fontsFileFinder;
        Zend_Loader::loadFile($this->fontsFileFinder, null, true);

        $this->cssManager = $path . 'CssManager.php';

        // require_once $this->cssManager;
        Zend_Loader::loadFile($this->cssManager, null, true);

        $this->otl = $path . 'Otl.php';

        // require_once $this->otl;
        Zend_Loader::loadFile($this->otl, null, true);

        $this->form = $path . 'Form.php';

        // require_once $this->form;
        Zend_Loader::loadFile($this->form, null, true);

        $this->hyphenator = $path . 'Hyphenator.php';

        // require_once $this->hyphenator;
        Zend_Loader::loadFile($this->hyphenator, null, true);

        $this->tag = $path . 'Tag.php';

        // require_once $this->tag;
        Zend_Loader::loadFile($this->tag, null, true);

        $this->namedcolors = $path . 'Color/NamedColors.php';

        // require_once $this->namedcolors;
        Zend_Loader::loadFile($this->namedcolors, null, true);

        $this->pageformat = $path . 'PageFormat.php';

        // require_once $this->pageformat;
        Zend_Loader::loadFile($this->pageformat, null, true);

        $this->fontVariables = $path . 'Config/FontVariables.php';

        // require_once $this->fontVariables;
        Zend_Loader::loadFile($this->fontVariables, null, true);

        $this->textvars = $path . 'Css/TextVars.php';

        // require_once $this->textvars;
        Zend_Loader::loadFile($this->textvars, null, true);

        $this->border = $path . 'Css/Border.php';

        // require_once $this->border;
        Zend_Loader::loadFile($this->border, null, true);

        $this->logcontext = $path . 'Log/Context.php';

        // require_once $this->logcontext;
        Zend_Loader::loadFile($this->logcontext, null, true);

        $this->ttfontfile = $path . 'TTFontFile.php';

        // require_once $this->ttfontfile;
        Zend_Loader::loadFile($this->ttfontfile, null, true);

        $this->destination = $path . 'Output/Destination.php';

        // require_once $this->destination;
        Zend_Loader::loadFile($this->destination, null, true);

        $this->mpdfexception = $path . 'MpdfException.php';

        // require_once $this->mpdfexception;
        Zend_Loader::loadFile($this->mpdfexception, null, true);

        $this->metricsgenerator = $path . 'Fonts/MetricsGenerator.php';

        // require_once $this->metricsgenerator;
        Zend_Loader::loadFile($this->metricsgenerator, null, true);

        $this->GlyphOperator = $path . 'Fonts/GlyphOperator.php';

        // require_once $this->GlyphOperator;
        Zend_Loader::loadFile($this->GlyphOperator, null, true);

        $this->barcode = $path . 'Barcode.php';

        // require_once $this->barcode;
        Zend_Loader::loadFile($this->barcode, null, true);



Note: MPdf is installing via composer require mpdf/mpdf command which placed into the vendor directory.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.