PHPackages                             boundstate/yii2-htmlconverter - 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. boundstate/yii2-htmlconverter

ActiveYii2-extension[PDF &amp; Document Generation](/categories/documents)

boundstate/yii2-htmlconverter
=============================

Supports conversion of HTML to PDF or images

v0.0.1(11y ago)917.2k↓45.4%1[2 issues](https://github.com/boundstate/yii2-htmlconverter/issues)MITPHP

Since May 14Pushed 11y ago2 watchersCompare

[ Source](https://github.com/boundstate/yii2-htmlconverter)[ Packagist](https://packagist.org/packages/boundstate/yii2-htmlconverter)[ RSS](/packages/boundstate-yii2-htmlconverter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

yii2-htmlconverter
==================

[](#yii2-htmlconverter)

Extension for the Yii2 framework that converts HTML to PDF or images using [wkhtmltopdf](http://wkhtmltopdf.org/).

Installation
------------

[](#installation)

This extensions relies on `wkhtmltopdf`. Installation insructions are provided on the \[wkhtmltopdf website\] [wkhtmltopdf](http://wkhtmltopdf.org/).

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist boundstate/yii2-htmlconverter "*"

```

or add

```
"boundstate/yii2-htmlconverter": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Setup the components in your config:

```
'htmlToPdf' => [
    'class' => 'boundstate\htmlconverter\HtmlToPdfConverter',
    'bin' => '/usr/bin/wkhtmltopdf',
    // global wkhtmltopdf command line options
    // (see http://wkhtmltopdf.org/usage/wkhtmltopdf.txt)
    'options' => [
        'print-media-type',
        'disable-smart-shrinking',
        'no-outline',
        'page-size' => 'letter',
        'load-error-handling' => 'ignore',
        'load-media-error-handling' => 'ignore'
    ],
],
'htmlToImage' => [
    'class' => 'boundstate\htmlconverter\HtmlToImageConverter',
    'bin' => '/usr/bin/wkhtmltoimage',
],
'response' => [
    'formatters' => [
        'pdf' => [
            'class' => 'boundstate\htmlconverter\PdfResponseFormatter',
            // Set a filename to download the response as an attachments (instead of displaying in browser)
            'filename' => 'attachment.pdf'
        ],
        'image' => [
            'class' => 'boundstate\htmlconverter\ImageResponseFormatter',
        ],
    ]
],

```

Now you can format a response as a PDF:

```
Yii::$app->response->format = 'pdf';

```

Or format a response as an image:

```
Yii::$app->response->format = 'image';

```

You can also manually generate a PDF from HTML:

```
$html = $this->render('hello-word');
$header = $this->render('hello-world-header');
$pdf = Yii::$app->htmlToPdf->convert($html, ['page-size' => 'A4', 'header-html' => $header]);

```

Or manually generate an image from HTML:

```
$html = $this->render('hello-word');
$pdf = Yii::$app->htmlToImage->convert($html);

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4022d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c8f627574f6bee1e622a2c9ada35d4347e67f6c92377bb80045c7c6661f390c?d=identicon)[mikejpeters](/maintainers/mikejpeters)

---

Top Contributors

[![mikejpeters](https://avatars.githubusercontent.com/u/3334654?v=4)](https://github.com/mikejpeters "mikejpeters (7 commits)")

---

Tags

pdfwkhtmltopdfimagehtmlwkhtmltoimageyii2wkhtmltox

### Embed Badge

![Health badge](/badges/boundstate-yii2-htmlconverter/health.svg)

```
[![Health](https://phpackages.com/badges/boundstate-yii2-htmlconverter/health.svg)](https://phpackages.com/packages/boundstate-yii2-htmlconverter)
```

###  Alternatives

[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

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

A slim PHP wrapper around wkhtmltopdf with an easy to use and clean OOP interface

1.6k20.0M44](/packages/mikehaertl-phpwkhtmltopdf)[gotenberg/gotenberg-php

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

3685.2M19](/packages/gotenberg-gotenberg-php)[luketowers/oc-snappypdf-plugin

SnappyPDF integration for OctoberCMS

121.1k](/packages/luketowers-oc-snappypdf-plugin)

PHPackages © 2026

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