PHPackages                             pdfshift/pdfshift-php - 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. [API Development](/categories/api)
4. /
5. pdfshift/pdfshift-php

AbandonedArchivedLibrary[API Development](/categories/api)

pdfshift/pdfshift-php
=====================

Convert HTML documents to PDF using the PDFShift.io API.

v1.0.9(7y ago)845.1k↓44.8%2[1 issues](https://github.com/pdfshift/pdfshift-php/issues)MITPHPPHP &gt;=5.3.0

Since Jun 12Pushed 5y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (8)Used By (0)

⚠️ **PDFShift's API being simple to implement and use, we realized that using a custom library just to wrap a network library was not necessary. As such, we decided to close this package and we recommend you to use a network library such as `cURL` to communicate with PDFShift.**

PDFShift PHP Package
====================

[](#pdfshift-php-package)

This PHP package provides a simplified way to interact with the [PDFShift](https://pdfshift.io) API.

Documentation
-------------

[](#documentation)

See the full documentation on [PDFShift's documentation](https://pdfshift.io/documentation).

Requirements
------------

[](#requirements)

PHP 5.4.0 and later.

Composer
--------

[](#composer)

You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:

```
composer require pdfshift/pdfshift-php
```

To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):

```
require_once('vendor/autoload.php');
```

Manual Installation
-------------------

[](#manual-installation)

If you do not wish to use Composer, you can download the [latest release](https://github.com/pdfshift/pdfshift-php/releases). Then, to use the bindings, include the `init.php` file.

```
require_once('/path/to/pdfshift-php/init.php');
```

Usage
-----

[](#usage)

This library needs to be configured with your `api_key` received when creating an account. Setting it is easy as:

```
\PDFShift\PDFShift::setApiKey('your_api_key');
```

### Basic example

[](#basic-example)

#### With an URL

[](#with-an-url)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');
PDFShift::convertTo('https://www.example.com', null, 'result.pdf');
```

#### With inline HTML data:

[](#with-inline-html-data)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

$data = file_get_content('invoice.html');
PDFShift::convertTo(data, null, 'result.pdf');
```

### Custom CSS

[](#custom-css)

#### Loading CSS from an URL:

[](#loading-css-from-an-url)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

$data = file_get_content('invoice.html');
PDFShift::convertTo(data, ['css' => 'https://www.example.com/public/css/print.css'], 'result.pdf');
```

#### Loading CSS from a string:

[](#loading-css-from-a-string)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

$data = file_get_content('invoice.html');
PDFShift::convertTo(data, ['css' => 'a {text-decoration: underline; color: blue}'], 'result.pdf');
```

### Custom HTTP Headers

[](#custom-http-headers)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

// We use an instance of PDFShift instead of the ::convertTo to easily handle advanced configuration
$pdfshift = new PDFShift();
$pdfshift->setHTTPHeaders(['X-Original-Header' => 'Awesome value']);
$pdfshift->addHTTPHeader('user-agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0'); // Also works like this
$pdfshift->convert('https://httpbin.org/headers');
$pdfshift->save('result.pdf');
```

### Accessing secured pages

[](#accessing-secured-pages)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

// We use an instance of PDFShift instead of the ::convertTo to easily handle advanced configuration
$pdfshift = new PDFShift();
$pdfshift->auth('user', 'passwd');
$pdfshift->convert('https://httpbin.org/basic-auth/user/passwd');
$pdfshift->save('result.pdf');
```

### Using cookies

[](#using-cookies)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

// We use an instance of PDFShift instead of the ::convertTo to easily handle advanced configuration
$pdfshift = new PDFShift();
$pdfshift->addCookie('session', '4cb496a8-a3eb-4a7e-a704-f993cb6a4dac');
$pdfshift->convert('https://httpbin.org/cookies');
$pdfshift->save('result.pdf');
```

### Adding Watermark (Oh hi Mark!)

[](#adding-watermark-oh-hi-mark)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

// We use an instance of PDFShift instead of the ::convertTo to easily handle advanced configuration
$pdfshift = new PDFShift();
$pdfshift->watermark([
    'image' => 'https://pdfshift.io/static/img/logo.png',
    'offset_x' => 50,
    'offset_y' => '100px',
    'rotate' => 45
])
$pdfshift->convert('https://www.example.com');
$pdfshift->save('result.pdf');
```

### Custom Header (or Footer)

[](#custom-header-or-footer)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

// We use an instance of PDFShift instead of the ::convertTo to easily handle advanced configuration
$pdfshift = new PDFShift();
$pdfshift->setFooter('Page {{page}} of {{total}}', '50px');
$pdfshift->convert('https://www.example.com');
$pdfshift->save('result.pdf');
```

### Protecting the generated PDF

[](#protecting-the-generated-pdf)

```
require_once('vendor/autoload.php');
use \PDFShift\PDFShift;

PDFShift::setApiKey('your_api_key');

// We use an instance of PDFShift instead of the ::convertTo to easily handle advanced configuration
$pdfshift = new PDFShift();
$pdfshift->protect([
    'userPassword' => 'user',
    'ownerPassword' => 'owner',
    'noPrint' => true
]);
$pdfshift->convert('https://www.example.com');
$pdfshift->save('result.pdf');
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/pdfshift/pdfshift-php/blob/master/CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 88.2% 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

Every ~30 days

Recently: every ~24 days

Total

7

Last Release

2716d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0fdb2f052abea716e9c614d6925dd165866a85607a6b376e0df8623f34ad36dc?d=identicon)[pdfshift](/maintainers/pdfshift)

---

Top Contributors

[![cnicodeme](https://avatars.githubusercontent.com/u/317142?v=4)](https://github.com/cnicodeme "cnicodeme (15 commits)")[![SoftCreatR](https://avatars.githubusercontent.com/u/81188?v=4)](https://github.com/SoftCreatR "SoftCreatR (2 commits)")

---

Tags

apipdfconverthtmldocumentpdfshift

### Embed Badge

![Health badge](/badges/pdfshift-pdfshift-php/health.svg)

```
[![Health](https://phpackages.com/badges/pdfshift-pdfshift-php/health.svg)](https://phpackages.com/packages/pdfshift-pdfshift-php)
```

###  Alternatives

[pdfcrowd/pdfcrowd

A client library for the Pdfcrowd API. It lets you convert between HTML, PDF and various image formats

631.1M1](/packages/pdfcrowd-pdfcrowd)[docraptor/docraptor

A native client library for the DocRaptor HTML to PDF/XLS service.

221.7M5](/packages/docraptor-docraptor)

PHPackages © 2026

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