padam87/rasterize-bundle

A bundle to rasterize web pages with PhantomJS for Symfony2

Installs: 6 567

Dependents: 0

Stars: 6

Watchers: 1

Open Issues: 2

Language: PHP

v1.1.4 2015-08-28 14:20 UTC

README

Build Status Scrutinizer Code Quality Coverage Status SensioLabsInsight

License Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads

A bundle to rasterize web pages with PhantomJS for Symfony2

1. Example

$response = new Response(
    $this->get('padam87_rasterize.rasterizer')->rasterize(
        $this->renderView('Bundle:Folder:template.pdf.twig')
    ),
    200, [
        'Content-Type'          => 'application/pdf',
        'Content-Disposition'   => 'attachment; filename="my.pdf"'
    ]
);

2. Installation

2.1. Composer

"padam87/rasterize-bundle": "~1.0",

2.2. AppKernel

$bundles = array(
    ...
    new Padam87\RasterizeBundle\Padam87RasterizeBundle(),
);

2.3 Install assets

php app/console assets:install

3. Configuration reference

NOTE: No configuration necessary by default

padam87_rasterize:
    web_dir:              /../web # Temp dir location related to %kernel.root_dir%.
    temp_dir:             /bundles/padam87rasterize/temp # Temp dir location related to web dir. Must be in a location accessible by the web server.
    phantomjs:
        callable:             phantomjs
        options:              [] # https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options
    script:               /bundles/padam87rasterize/js/rasterize.js # Relative to web dir
    arguments: # You can define your own custom arguments. Will be added by default to every process.
        format:              pdf # Default, will always be added, even if you remove it from here.