Download the PHP package eckinox/pdf-bundle without Composer

On this page you can find all versions of the php package eckinox/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

Generate PDFs from Twig templates in Symfony

Generating PDFs in Symfony should be simple.
And now, it is!

With this bundle, you can just render your PDFs like you render your Twig templates.

Getting started

1. Install Puppeteer

Before you proceed, make sure you have node and npm installed.

To install Puppeteer and its dependencies, we recommend you take a look at Puppeteer's official installation guide as well as their official troubleshooting guide.

Here is a snippet for Ubuntu (tested on 20.04) that works well at the time of writing:

2. Install this package via Composer

3. Configure the request context globally

The bundle needs to know the URL of your app to do some nifty stuff under the hood.
You must therefore define the request context for your app in your parameters.

To learn more about these parameters, check out Symfony's console documentation.

4. Start generating PDFs!

Here's a basic example to get you started.
For more complete examples and information, check out the documentation below.

Formats

The PdfGeneratorInterface::renderPdf() accepts a third optional parameter named $format. This allows you to define the format and orientation that will be used to generate the PDF.

Using built-in formats

The easiest and most common way of specifying a format is to use the built-in FormatFactory, which can provide you with all of the most common formats.

Specifying a format using one of the built-in formats looks like the following:

Each format factory method accepts a boolean parameter $landscape that allows you to determine the desired orientation. This parameter defaults to Portrait mode (false).

List of built-in formats

Here is the list of built-in formats:

Format Size Factory method
Letter 8.5in x 11in FormatFactory::letter(bool $landscape = false)
Legal 8.5in x 14in FormatFactory::legal(bool $landscape = false)
Tabloid 11in x 17in FormatFactory::tabloid(bool $landscape = false)
Ledger 17in x 11in FormatFactory::ledger(bool $landscape = false)
A0 33.1in x 8in FormatFactory::a0(bool $landscape = false)
A1 23.4in x 1in FormatFactory::a1(bool $landscape = false)
A2 16.54in x 4in FormatFactory::a2(bool $landscape = false)
A3 11.7in x 54in FormatFactory::a3(bool $landscape = false)
A4 8.27in x 7in FormatFactory::a4(bool $landscape = false)
A5 5.83in x 27in FormatFactory::a5(bool $landscape = false)
A6 4.13in x 83in FormatFactory::a6(bool $landscape = false)

Specifying a custom format

If the built-in formats don't offer the size you're looking for, you can always create your own formats.

Simply create an instance of Format and specify your desired width and height. Optionnally, you may define orientation and margins as well.

The width and height arguments accept the following units: px, in, cm and mm.

Margins

Margins for the document should be handled directly in CSS within your document.

Although this library offers some margin support and provides this information to Puppeteer, Puppeteer does not actually use it in its current implementation.

You should therefore define margins with physical units (in, cm, or mm) on the @page or html element in CSS.

Outputting, downloading and storing PDFs

The PdfInterface instance returned by the PDF generator has three methods you can use:

Troubleshooting

Large filesize (or: my PDFs are way too big!!)

This bundle relies on Puppeteer, which relies on Chromium's PDF generation. And Chromium's PDF generation, depending on which version is used, can generate PDFs with a very large filesize when the PDF contains images or emojis.

An easy fix for this is to wrap your images in an SVG tag, like so:

When you do this, your image will be embedded into the PDF at its regular filesize instead of being re-rendered as a PDF. This should dramatically reduce the file size of your generated PDFs.

License

This bundle is licensed under the MIT license.


All versions of pdf-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.10
eckinox/php-puppeteer Version ^1.0
symfony/http-foundation Version ^5.4|^6.0
symfony/http-kernel Version ^5.4|^6.0
symfony/string Version ^5.4|^6.0
twig/twig Version ^3.8
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 eckinox/pdf-bundle contains the following files

Loading the files please wait ....