desarrollo-cespi/pm-p-d-f-kit-plugin

symfony1 plugin that enables you to export any page as a PDF file by only adding the pdf format to the request

Installs: 9 002

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 8

Forks: 0

Open Issues: 0

Type:symfony1-plugin

dev-master 2013-12-30 00:25 UTC

This package is not auto-updated.

Last update: 2024-12-17 04:11:42 UTC


README

The pmPDFKitPlugin plugin is a clone on jdpace's PDFKit library for Ruby (and Ruby on Rails). It allows you to export any page as PDF only adding the pdf format to the request. IE: calling http://example.com/post/1.pdf

Requirements

wkhtmltopdf library is required. You can download it from wkhtmltopdf on Google code.

Installation

  • Via composer:
{
  "require": {
    "desarrollo-cespi/pm-p-d-f-kit-plugin": "dev-master"
  }
}
  • Or using git, from source.

  • Enable the plugin in the project configuration:

// in config/ProjectConfiguration.class.php add:
$this->enablePlugin('pmPDFKitPlugin');

Usage

  • Enable the pmPDFKitFilter
pm_pdfkit:
  class: pmPDFKitFilter
  • By default, this plugin expects the wkhtmltopdf executable to be in /usr/local/bin/wkhtmltopdf. If it does not you can specify it in app.yml:
all:
  pm_pdf_kit:
    executable: /home/patricio/bin/wkhtmltopdf
  • Clear the cache

  • Finally, try to access any resource appending the .pdf format.

Advanced usage

  • Edit the default routes so any page can be transformed as pdf:
default_index:
  url:   /:module.:sf_format
  param: { action: index, sf_format: html }

default:
  url:   /:module/:action.:sf_format/*
  param: { sf_format: html }
  • You can save any view to a file (instead of inline view in the browser) using the pmPDFKit class.

  • Specify extra parameters for wkhtmltopdf appending them to the url:

http://somedomain.com/something/1.pdf?orientation=landscape&page-size=Letter&print-media-type=true

See all options executing wkhtmltopdf -H in the terminal.

TODO

  • fix images paths (because images are loaded from the stylesheets).