Giter Club home page Giter Club logo

pdfize's Introduction

About

A simple component to generate PDF output from any controller/action.

Uses dompdf (v0.6.0beta1) for PDF generation. http://code.google.com/p/dompdf/

You could probably plug it in to a different engine - since this plugin was started, there have been a few others that look promising. But at the time, dompdf was the simplest I could find that did what we needed it to do.

Should work with CakePHP 1.2 & 1.3. I've used it with both. You can see an example of its usage in the expozine project.

Things you should know

  • dompdf in the pdfize/vendors folder. As a convenience, I have included that library with this plugin. You should go there to make sure you have the laest copy of the lib.
  • PDFize will look for views/layouts/pdf.ctp. If that doesn't exist, will fallback to plugins/pdfize/views/layouts/pdf.ctp
    • re: views/layouts/pdf.ctp Treat it just like any other layout.
  • You will need a view for the action, as usual.
  • For images, you will probably need to output the full http:// path. I didn't have much luck with relative.
  • The PDF file outputted is named based on Inflector::slug($controller->pageTitle), otherwise it falls back on Inflector::slug($controller->name.' '.$controller->action)
  • Depending on the amount of images and whatnot, you might have to up your memory limit. In PdfComponent::shutdown() we use ini_set('memory_limit', '96M');
  • Make sure your webserver can write to pdfize/vendors/dompdf/lib/fonts/ (usually this involves just chmod 777 that directory)

Usage

In your controller, add it to $components. Pass in an array with some config info:

public $components = array('Pdfize.Pdf' => array(
        'actions' => array('admin_pdf'),
        'debug' =>false,
        'size' => 'legal',
        'orientation' => 'landscape'
    ));
  • actions: (required) Array of names of the actions in the controller that you want PDFize to hijack and output as a pdf.
  • debug: Set to TRUE to output to browser instead of generating pdf.
  • size: default is legal. For the full list of valid sizes, see CPDF_Adapter::PAPER_SIZES dompdf/include/cpdf_adapter.cls.php
  • orientation: landscape (default) or portrait

pdfize's People

Contributors

meeech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

mangomagic nam162

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.