GithubHelp home page GithubHelp logo

mpdf-bundle's Introduction

xare - Mpdf Bundle

Pdf generator for Symfony.

What is it?

This is a Symfony Pdf Factory for use inside a controller to generate a PDF file from twig rendring using MPDF lib.

Installation

Step 1: Download HiddenEntityTypeBundle using composer

$ composer require xare/mpdf-bundle

Composer will install the bundle to your project's vendor directory.

Step 2: Enable the bundle

Enable the bundle in the config if flex it did´nt do it for you:

<?php
// config/bundles.php

return [
    // ...
    xare\MpdfBundle\xareMpdfBundle::class => ['all' => true],
    // ...
];

Usage

You can use the factory in your controllers just like this:

<?php

use xare\MpdfBundle\Factory\MpdfFactory;

// ...
public function pdf($id, Request $request, MpdfFactory $MpdfFactory) {
// ...
$mPdf = $MpdfFactory->createMpdfObject([
'mode' => 'utf-8',
'format' => 'A4',
'margin_header' => 5,
'margin_footer' => 5,
'orientation' => 'P'
]);
$mPdf->SetTopMargin("50");
$mPdf->SetHTMLHeader($this->renderView('twigfolder/pdf/pdf_header.html.twig', $TwigVars));
$mPdf->SetFooter($this->renderView('twigfolder/pdf/pdf_footer.html.twig', $TwigVars));
$mPdf->WriteHTML($this->renderView('twigfolder/pdf/pdf_content.html.twig', $TwigVars));
return $MpdfFactory->createDownloadResponse($mPdf, "file.pdf");
}
// ...

Reporting an issue or a feature request

Feel free to report any issues. If you have an idea to make it better go ahead and modify and submit pull requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.