2017 © Pedro Peláez
 

library wkhtml-module

ZF2 Module for Wkhtmltopdf

image

krona/wkhtml-module

ZF2 Module for Wkhtmltopdf

  • Thursday, February 5, 2015
  • by Arilas
  • Repository
  • 0 Watchers
  • 0 Stars
  • 35 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Krona WKHTML Module

Krona WKHTML is an ZF2 Module for simplify working with PDF generation, (*1)

Install

Composer

Install Composer Composer:, (*2)

$ curl -s https://getcomposer.org/installer | php

Add requirements to composer.json:, (*3)

{
    "require": {
        "krona/wkhtml-module": "dev-master"
    }
}

Configuration

In your application config add module:, (*4)

<?php
return [
    // This should be an array of module namespaces used in the application.
    'modules' => [
        'Krona\CommonModule',
        'Krona\WKHTML',
        ...
    ],
    ...
],

If you want to use lib with ability to send PDF directly to user from Action register Strategy inside global config:, (*5)

'view_manager' => [
    'strategies' => [
        \Krona\WKHTML\Strategy\PdfStrategy::class,
    ],
],

Also you need to add config for placement and base URL for temporary location of HTML for example:, (*6)

    'krona' => [
        'wkhtml' => [
            'dir' => 'public/placement/',
            'base_url' => 'http://my.domain/placement/'
        ],
    ],

Usage

Simple use with sending PDF to user

class SomeController extends AbstractController
{
    public function testAction()
    {
        //...
        $view = new PdfModel( //The same as ViewModel
            [

            ]
        );
        $view->setOrientation(PdfModel::ORIENTATION_LANDSCAPE);

        return $view;
    }
}

The Versions