PHPackages                             subtlephp/phpwkhtmltox - 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. subtlephp/phpwkhtmltox

ActiveLibrary

subtlephp/phpwkhtmltox
======================

PHP wrapper for wkhtmltox

453CSS

Since Dec 29Pushed 8y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

phpwkhtmltopdf
==============

[](#phpwkhtmltopdf)

- [phpwkhtmltopdf](#phpwkhtmltopdf)
    - [解析数组形式的配置](#%E8%A7%A3%E6%9E%90%E6%95%B0%E7%BB%84%E5%BD%A2%E5%BC%8F%E7%9A%84%E9%85%8D%E7%BD%AE)
    - [例子](#%E4%BE%8B%E5%AD%90)

为了用 PHP 解决 HTML 转 PDF 的麻烦, 简单的封装了一个库, 它的主要作用有两个:

1. 解析数组形式的配置
2. 调用 wkthmltopdf 二进制文件生成 PDF

解析数组形式的配置
---------

[](#解析数组形式的配置)

更有三种形式的选项

1. 类似`--header-line`, 是单独的选项, 不带值, 在配置里面写作:

```
[
    'header-line' => '',
]
```

2. 类似`toc`这种大类选项, 作为二级数组

```
[
    'toc' => [
        'toc-header-text' => 'kkkk',
    ],
]
```

3. 类似`--page-size A4` 这种有选项又有值的

```
[
    'page-size' => 'A4'
]
```

例子
--

[](#例子)

```
use SubtlePHP\WkHtmlTo\PDF\Factory;

require __DIR__ . '/../../vendor/autoload.php';

$pdf = (new Factory())->setPdfPath(__DIR__ . '/tmp/pdf')
    ->setTemporaryHtmlPath(__DIR__ . '/tmp/html')
    ->setBinary('/usr/local/bin/wkhtmltopdf');

$html = [
    'kdfjsdl',
    'ksdjflsadj',
];

$pdf->generateFromHtml($html, 'test', [
    'print-media-type' => '',
]);
```

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/33b3fa8af3ccd135899139440b0c902f1271f7edb5831ec3e11f1c0ae34fc08c?d=identicon)[lovelock](/maintainers/lovelock)

---

Top Contributors

[![lovelock](https://avatars.githubusercontent.com/u/2208731?v=4)](https://github.com/lovelock "lovelock (9 commits)")

### Embed Badge

![Health badge](/badges/subtlephp-phpwkhtmltox/health.svg)

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

PHPackages © 2026

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