PHPackages                             silvioiannone/electron-pdf-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. silvioiannone/electron-pdf-php

ActiveLibrary

silvioiannone/electron-pdf-php
==============================

A PHP wrapper for electron-pdf

05151PHP

Since Jan 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/silvioiannone/electron-pdf-php)[ Packagist](https://packagist.org/packages/silvioiannone/electron-pdf-php)[ RSS](/packages/silvioiannone-electron-pdf-php/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Introduction
------------

[](#introduction)

**electron-pdf-php** is a PHP wrapper of [electron-pdf](https://github.com/fraserxu/electron-pdf). It simply provides a PHP interface for the `electron-pdf` cli tool.

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

[](#requirements)

- Linux or MacOS
- Electron PDF

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

[](#installation)

First install **electron-pdf** globally:

```
npm install -g electron-pdf

```

Require **electron-pdf-php** using composer:

```
composer require silvioiannone/electron-pdf-php

```

Usage
-----

[](#usage)

Usage is super easy:

```
$generator = new SI\ElectronPdfPhp\Generator();
$pdf = $generator->fromHtml($html)
    ->content();

```

### Settings

[](#settings)

When instantiating a new generator instance the following settings may be passed to the constructor:

- `executable` =&gt; `string` - Path to the electron-pdf executable. Default: 'electron-pdf'
- `proxyWithNode` =&gt; `bool` - Execute the command using node. This may be necessary in some cases where the error `env: node: command not found` is thrown. Default: false
- `graphicalEnvironment` =&gt; `bool` - Whether the server has a graphical environment. This is only valid on Linux machines that have [Xvfb](https://www.x.org/archive/X11R7.6/doc/man/man1/Xvfb.1.xhtml) installed. Default: false
- `marginsType` =&gt; `int` - Specify the type of margins to use:
    - `0`: default margins
    - `1`: no margins (electron-pdf default setting)
    - `2`: minimum margins

Example:

```
$generator = new SI\ElectronPdfPhp\Generator([
    'executable' => '/usr/local/bin/electron-pdf'
    ...
]);

```

### Specify a source

[](#specify-a-source)

Generate a PDF from a URL:

```
// Generate the PDF from a URL
$pdf = $generator->from('http://google.com')
    ->content();

```

Generate a PDF from HTML:

```
// Generate the PDF from HTML
$pdf = $generator->fromHtml('Test')
    ->content();

```

### Specify a destination

[](#specify-a-destination)

Save the PDF to a file:

```
$generator->from('http://google.com')
    ->to('/home/downloads/test.pdf');

```

Get the PDF contents:

```
$pdf = $generator->from('http://google.com')
    ->content();

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity38

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://avatars.githubusercontent.com/u/8558526?v=4)[Silvio Iannone](/maintainers/silvioiannone)[@silvioiannone](https://github.com/silvioiannone)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/silvioiannone-electron-pdf-php/health.svg)

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

PHPackages © 2026

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