PHPackages                             knplabs/knp-snappy - 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. knplabs/knp-snappy

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

knplabs/knp-snappy
==================

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.

v1.6.0(3mo ago)4.5k68.3M—0.3%436[7 issues](https://github.com/KnpLabs/snappy/issues)[12 PRs](https://github.com/KnpLabs/snappy/pulls)20MITPHPPHP &gt;=8.1CI passing

Since Nov 7Pushed 3d ago128 watchersCompare

[ Source](https://github.com/KnpLabs/snappy)[ Packagist](https://packagist.org/packages/knplabs/knp-snappy)[ Docs](http://github.com/KnpLabs/snappy)[ RSS](/packages/knplabs-knp-snappy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (51)Used By (20)Security (2)

Snappy
======

[](#snappy)

[![Build Status](https://github.com/KnpLabs/snappy/actions/workflows/build.yaml/badge.svg)](https://github.com/KnpLabs/snappy/actions/workflows/build.yaml/badge.svg)[![AppVeyor CI Build Status](https://camo.githubusercontent.com/2082d6c0ce2b362503108ce845904a3ae9bb6591a534e04c60c62d28ace5ce9f/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f6769746875622f4b6e704c6162732f736e617070793f6272616e63683d6d6173746572267376673d74727565)](https://ci.appveyor.com/project/NiR-/snappy)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2e8750ad0febfe3e61d7ce34560fecf2b10184e7bcf2cfee2691144f1a129084/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4b6e704c6162732f4761756672657474652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/KnpLabs/Gaufrette/?branch=master)

Snappy is a PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based [wkhtmltopdf and wkhtmltoimage](http://wkhtmltopdf.org/)available on OSX, linux, windows.

You will have to download wkhtmltopdf `0.12.x` in order to use Snappy.

Please, check [FAQ](doc/faq.md) before opening a new issue. Snappy is a tiny wrapper around wkhtmltox, so lots of issues are already answered, resolved or wkhtmltox ones.

Following integrations are available:

- [`knplabs/knp-snappy-bundle`](https://github.com/KnpLabs/KnpSnappyBundle), for Symfony
- [`barryvdh/laravel-snappy`](https://github.com/barryvdh/laravel-snappy), for Laravel
- [`mvlabs/mvlabs-snappy`](https://github.com/mvlabs/MvlabsSnappy), for Zend Framework

Installation using [Composer](http://getcomposer.org/)
------------------------------------------------------

[](#installation-using-composer)

```
composer require knplabs/knp-snappy
```

Usage
-----

[](#usage)

> ⚠️ **Security Warning**
>
> The `--enable-local-file-access` option in `wkhtmltopdf` can be risky if used with untrusted HTML or JavaScript. This may expose local files or lead to remote code execution.
>
> To stay safe:
>
> - Avoid enabling `--enable-local-file-access` unless necessary.
> - Always sanitize user input before processing.
> - Run `wkhtmltopdf` in a sandbox like **AppArmor** or **SELinux**.
> - For untrusted content, consider alternatives like **WeasyPrint**, **Prince**, or **Puppeteer**.
>
> This risk was responsibly reported by
> **Nikita Sveshnikov (Positive Technologies)**.
>
> 🔗 [Official recommendations](https://wkhtmltopdf.org/status.html#recommendations)

### Initialization

[](#initialization)

```
