2017 © Pedro Peláez
 

symfony-bundle html-to-pdf-bundle

A simple bundle to add html 2 pdf service provider in a simple way to your symfony project.

image

schoenef/html-to-pdf-bundle

A simple bundle to add html 2 pdf service provider in a simple way to your symfony project.

  • Tuesday, April 4, 2017
  • by Andreas-Schoenefeldt
  • Repository
  • 1 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

SchoenefHtmlToPdfBundle

A simple bundle to add html 2 pdf service provider in a simple way to your symfony project. Currently it supports:, (*1)

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)

$ composer require schoenef/html-to-pdf-bundle:~1.0

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*4)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Schoenef\HtmlToPdfBundle\SchoenefHtmlToPdfBundle(), // takes care of html to pdf conversion via third party services
        );

        // ...
    }

    // ...
}

Step 3: Configure the Bundle

Add the following configuration to your app/config/config.yml:, (*5)

schoenef_html_to_pdf:
  provider: pdfrocket
  timeout: 20
  apikey: "%html_to_pdf_apikey%"
  default_options:
     shrinking: false
     dpi: 300
     image_quality: 100
     page_size: A4
     zoom: 1.2
     js_delay: 500

And to your app/config/parameter.yml:, (*6)

parameters:
  ...
  html_to_pdf_apikey: yourApiKey

Available configuration options

  1. provider: default: pdfrocket - no other value available at the moment
  2. timeout: default: 20 - the timeout in seconds of a single http call
  3. apikey: The api key you got from your provider to turn html pages into pdf
  4. default_options: mapping of pdf options
    1. shrinking | (boolean) - if set to false, smart-shrinking is dissabled
    2. dpi | (integer) - allows to set the dpi
    3. image_quality | (integer) - allows to define the image quality
    4. page_size | (enum) - allows to define the pdf page size - A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 B0 B1 B1 B2 B3 B4 B5 B6 B7 B8 B9 C5E Comm10E DLE Executive Folio Ledger Legal Letter Tabloid
    5. zoom | (float) - a float number, to zoom the page
    6. js_delay | (integer) - render delay in milliseconds - good to allow the load of external fonts are ajax requests to finish

Usage

To use the html to pdf connector and save pdf files, you can use the following inside of symfony controllers:, (*7)

$connector = $this->get('schoenef_html_to_pdf.connector');
$connector->saveUrlAsPdf('http://some.url', 'some/file/path.pdf', ['dpi' => 96]);

The Versions

04/04 2017

dev-master

9999999-dev

A simple bundle to add html 2 pdf service provider in a simple way to your symfony project.

  Sources   Download

MIT

The Requires

 

by Andreas Schönefeldt

04/04 2017

v1.0.0-RC2

1.0.0.0-RC2

A simple bundle to add html 2 pdf service provider in a simple way to your symfony project.

  Sources   Download

MIT

The Requires

 

by Andreas Schönefeldt

01/04 2017

v1.0.0-RC1

1.0.0.0-RC1

A simple bundle to add html 2 pdf service provider in a simple way to your symfony project.

  Sources   Download

MIT

The Requires

 

by Andreas Schönefeldt