PHP code example of smachara / html2pdfbundle

1. Go to this page and download the library: Download smachara/html2pdfbundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

smachara / html2pdfbundle example snippets



public function printAction()
    {
        $pdf = $this->get('html2pdf_factory')->create();
        $html = $this->renderView('PdfBundle:Pdf:content.html.twig', array( 'preview' => false));
        $pdf->writeHTML($html);
        $response = new Response($pdf->Output('test.pdf','D'));
        return $response;
    }
 php
// app/autoload.php

// ...
$loader->add('smachara',   __DIR__ . '/../vendor');
 php
// app/AppKernel.php


public function registerBundles()
{
    $bundles = array(
        // ...
        new smachara\html2pdfbundle\smacharaHtml2pdfBundle(),
    );
}

$pdf = $this->get('html2pdf_factory')->create('P', 'A4', 'en', true, 'UTF-8', array(10, 15, 10, 15));