定制 phppdf/html-converter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phppdf/html-converter

Composer 安装命令:

composer require phppdf/html-converter

包简介

Convert HTML and CSS into PDF documents on top of phppdf/phppdf

README 文档

README

Convert HTML and CSS into PDF documents on top of phppdf/phppdf.

Requirements

  • PHP 8.4+
  • ext-dom
  • ext-libxml

Installation

composer require phppdf/html-converter

Documentation

The documentation can be found here: https://phppdf.github.io/html-converter/

Quick start

use PhpPdf\Html\HtmlConverter;
use PhpPdf\Output\PdfMemoryOutput;
use PhpPdf\Serialization\PdfDocumentSerializer;

$html = '<h1>Hello World</h1><p>Welcome to the PDF.</p>';

$document = HtmlConverter::fromHtml($html)->build();

$output = new PdfMemoryOutput();
(new PdfDocumentSerializer($output))->writeDocument($document);

header('Content-Type: application/pdf');
echo $output->getContent();

Because HtmlConverter::fromHtml() returns a plain PdfDocumentBuilder, you can prepend or append pages, add metadata/encryption/signatures, and apply compression before serialising.

Examples

Working examples live in the examples repository: https://github.com/phppdf/examples

Development

composer install
composer phpunit
composer phpunit:coverage
composer phpcs
composer phpstan

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 1

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-17