PHPackages                             jihel/html-to-pdf-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. jihel/html-to-pdf-bundle

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

jihel/html-to-pdf-bundle
========================

A SF2 bundle to easely handle pdf generation and merge with wkhtmltopdf

05271PHP

Since Mar 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Jihell/HtmlToPdfBundle)[ Packagist](https://packagist.org/packages/jihel/html-to-pdf-bundle)[ RSS](/packages/jihel-html-to-pdf-bundle/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

HtmlToPdfBundle
===============

[](#htmltopdfbundle)

A SF2 bundle to easily handle pdf generation and concatenation with wkhtmltopdf and pdftk This bundle only provide a php object way to g, basically it will simply execute the command. If you need some particular feature, you should create your own command abstraction class.

1- Install
----------

[](#1--install)

Add plugin to your composer.json require:

```
{
    "require": {
        "jihel/html-to-pdf-bundle": "dev-master",
    }
}

```

or

```
php composer.phar require jihel/html-to-pdf-bundle:dev-master

```

Install packages binaries:

```
aptitude install wkhtmltopdf pdftk xvfb

```

Add bundle to your AppKernel.php

```
public function registerBundles()
{
    $bundles = array(
        ...
        new Jihel\Plugin\HtmlToPdfBundle\JihelPluginHtmlToPdfBundle(),
    );
}

```

2- Configure your config.yml
----------------------------

[](#2--configure-your-configyml)

The default configuration file and explanations can be found [here](doc/config.md)

3- Usage
--------

[](#3--usage)

Get the generator service **jihel.plugin.html\_to\_pdf.generator.pdf**:

- From a controller

    /\*\* @var \\Jihel\\Plugin\\HtmlToPdfBundle\\Generator\\PdfGenerator $pdfGenerator \*/ $pdfGenerator = $this-&gt;get('jihel.plugin.html\_to\_pdf.generator.pdf');
- From a service

    service: my.super.pdf.service: class: %my.super.mdf.service.class% arguments: { '@jihel.plugin.html\_to\_pdf.generator.pdf' }

The class provite two methods, one to generate a pdf from a template name and datas, and the other to concatenate all pages from pdf files in an array list or a folder.

```
/**
 * Create a .pdf file from the given $template name with given $data parameters
 *
 * @param string $template
 * @param array $data
 * @return \SplFileObject
 */
public function create($template, array $data = array())

/**
 * Concatenate the given pdf files.
 * If you provide a path a folder,
 * concatenate them by alphabetic order
 *
 * @param \SplFileObject[]|string $files
 * @param bool $unlink
 * @return \SplFileObject
 * @throws Exception\NotASplFileObjectException
 */
public function concatenate($files, $unlink = false)

```

Both will return an SplFileObject temporally saved in the /tmp folder.

You can read execution messages with the methods :

```
public function getLastConcatenateCommandResult()
public function getLastCreateCommandResult()

```

Only the last executed command output will be visible. Think about the verbose option to have more details.

4- Note
-------

[](#4--note)

The `use_xvfb` option is resources consuming. Think about using wkhtmltopdf on a server with a permanent xserver running.

If you want to include background pictures, put the absolute path in your $data array.

5- Thanks
---------

[](#5--thanks)

Thanks to Romain Sebille (Give me your email man !) who made the research and the first iteration of the command generator. Thanks to my cat to keep meowing me. Thanks to me for giving my free time doing class for lazy developers. You can access read CV [here](http://www.joseph-lemoine.fr)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/19ed41f54971ca2c9a6d2cd25178b46b7d38164bc8a16b046dc0556c5871d991?d=identicon)[Jihel](/maintainers/Jihel)

---

Top Contributors

[![Jihell](https://avatars.githubusercontent.com/u/3269035?v=4)](https://github.com/Jihell "Jihell (8 commits)")

### Embed Badge

![Health badge](/badges/jihel-html-to-pdf-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/jihel-html-to-pdf-bundle/health.svg)](https://phpackages.com/packages/jihel-html-to-pdf-bundle)
```

###  Alternatives

[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.2k57.6M131](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)[setasign/tfpdf

This class is a modified version of FPDF that adds UTF-8 support. The latest version is based on FPDF 1.85.

426.1M30](/packages/setasign-tfpdf)[aspera/xlsx-reader

Spreadsheet reader library for XLSX files

52742.2k5](/packages/aspera-xlsx-reader)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
