Code Monkey home page Code Monkey logo

pdfbundlewkhtmltopdf's Introduction

PDFBundle

PDF Bundle provides an easy way to create PDF's from your views based siphoc/PdfBundle

Installation

Step 1: Download the bundle using Composer

Add frchoPdfBundle to composer.

{
    "require": {
        "frcho/pdf-bundle": "dev-master"
    }
}

Install the bundle:

$ composer.phar update frcho/pdf-bundle

Composer will install the bundle with the required dependencies.

Step 2: Enable the bundle

In your AppKernel add the following:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new frcho\PdfBundle\SiphocPdfBundle(),
    );
}

Step 3: configure your bundle

In your config.yml file:

kijhoTechnologies_pdf:
    basepath: "%kernel.root_dir%/../web"
    binary: "/usr/local/bin/wkhtmltopdf"
    options:
        'lowquality': false
        'enable-javascript': true
        'debug-javascript': true

Usage

Download

In your controller, you can download the contents of your controller like this:

$pdfGenerator = $this->get('frcho.pdf.generator');
$pdfGenerator->setName('my_pdf.pdf');
return $pdfGenerator->downloadFromView(
    'AcmeDemoBundle:Demo:index.html.twig', array(
        'name' => $name,
    )
);

Inline display

There's also an option to display the contents in the browser. To do so, use the following example:

$pdfGenerator = $this->get('frcho.pdf.generator');
$pdfGenerator->setName('my_pdf.pdf');
return $pdfGenerator->displayForView(
    'AcmeDemoBundle:Demo:index.html.twig', array(
        'name' => $name,
    )
);

Documentation

The main Documentation can be found in Resources/doc/index.html. It is auto-generated by PHPDocumentor2. The directory itself is excluded through git because we use the PHPDoc Markdown plugin to create proper MD files to include in Git.

If you want to contribute, be sure to update the documentation and run both PHPDocumentor2 and PHPDoc Markdown. This way the documentation keeps up to date properly.

Tests

For tests I've used PHPUnit. Contributions need to be supported with tests.

License

This bundle is under the MIT License.

Dependencies

Buzz

For external calls, I've included the Buzz Bundle from @kriswallsmith.

Snappy

To create the actual PDF. We're using Snappy. This has the wkhtmltopdf dependency. Be sure that you use the latest version (>=0.11.0_rc1).

Symfony

Since this is a Symfony bundle, there are some Symfony dependencies.

Http Foundation

To create a proper response, I've implemented the Symfony 2.1 Http Foundation component.

Templating

To render the views automatically, I've added the templating component to force a proper templating engine.

HttpKernel

Since version 1.1.2 we've implemented a logger instance. This depends on the Symfony2 HttpKernel component.

pdfbundlewkhtmltopdf's People

Contributors

frcho avatar

Watchers

 avatar

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.