Download the PHP package orkestra/pdf-bundle without Composer

On this page you can find all versions of the php package orkestra/pdf-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pdf-bundle

OrkestraPdfBundle

Build Status

Abstracts different PDF generation libraries. Currently supports TCPDF, Zend PDF and wkhtmltopdf.

This bundle is under active development and is prone to backwards compatibility breaks.

Installation

Using composer, in your project's root directory:

Update AppKernel.

In addition, you should add TCPDF or Zend PDF to your project, as necessary.

If planning to use wkhtmltopdf, ensure it is installed on your system.

Configuration

No configuration is necessary, unless you want to change default settings.

Configuration defaults reference:

Usage

This bundle's aim is to provide a uniform API for generating PDFs using different generation tools.

Currently supported: TCPDF, Zend PDF, and wkhtmltopdf.

Generators

The basis of this bundle revolves around services called "Generators". Generators know how to take some input, such as entities and other data, and return a PDF ready to be used. Generators encapsulate library-specific logic, returning a subtype of Orkestra\Bundle\PdfBundle\Pdf\PdfInterface which can then be used to send the generated PDF to the browser, save it to the filesystem, etc.

All Generators should implement PdfGeneratorInterface. Additionally, a base class called AbstractPdfGenerator is included. This document details how to extend AbstractPdfGenerator

Creating an Invoice Generator

The two main methods to implement are: doGenerate and setDefaultParameters.

Implementing the doGenerate method

This method actually performs the PDF generation. It takes two parameters, $parameters and $options.

Implementing the setDefaultParameters method

This method configures an OptionsResolver and allows specification of required and available parameters that the Generator supports.

NOTE: There's also a setDefaultOptions method available. Parameters are intended to be passed to the templating engine, things like entities and collections. Options are intended to allow configuration of the generator at runtime.

Example implementation: InvoiceGenerator

In this example, we use the WkPdf adapter and the built in templating engine to render a PDF.

Useful methods

AbstractPdfGenerator->createPdf($type, $options) wraps the PDF factory registry. As the first parameter, pass the type of PDF and options to configure it. Available PDF types: tcpdf, wkpdf, and zendpdf.

AbstractPdfGenerator->render($template, array $parameters = array()) uses the application's templating engine to render templates for use in generating the content for the PDF.

Registering your generator

In services.yml:

AbstractPdfGenerator by default, takes a PDF factory registry and the templating service. You may need to add more dependencies, depending on your implementation.

Using your service

From within one of your controllers:

Strategies

Using TCPDF to render template fragments

TCPDF can be difficult to use, especially when rendering HTML. Usually, the easiest way is to position different smaller sections of the page, making multiple writeHTML or writeHTMLCell calls on the TCPDF object.

Here's an example of the same Invoice Generator from before.

See TCPDF documentation for more details.

Using custom subclasses with TCPDF

TCPDF offers the ability to extend the TCPDF class directly to implement, for example, page headers and footers.

The default TcPdfFactory lets you specify a custom subclass by specifying the 'className' option when creating a PDF. For example:

Notice that $builder in the example above is an instance of My\Bundle\CustomTcpdf.


All versions of pdf-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
tecnick.com/tcpdf Version ~6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package orkestra/pdf-bundle contains the following files

Loading the files please wait ....