定制 royalty/chrome-pdf 二次开发

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

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

royalty/chrome-pdf

Composer 安装命令:

composer require royalty/chrome-pdf

包简介

Chrome PHP wrapper for generating PDF files easily

README 文档

README

License

ChromePDF is an very simple Chrome PDF wrapper, written in PHP

This library is inspired by DomPDF, attempting to retain most of the applicable syntax that it uses, while reducing the amount of effort needed in development. It also aims to reduce the external dependency that comes along with using other (excellent) libraries like PuPHPeteer and chrome-php/chrome.

Features

  • Works

Requirements

  • PHP version 7.1 or higher
  • Chrome

Easy Installation

Install with composer

To install with Composer, simply require the latest version of this package.

composer require royalty/chrome-pdf

Make sure that the autoload file from Composer is loaded.

// somewhere early in your project's loading, require the Composer autoloader
// see: http://getcomposer.org/doc/00-intro.md
require 'vendor/autoload.php';

Install with git

From the command line, switch to the directory where ChromePDF will reside and run the following commands:

git clone https://github.com/runbiscuit/ChromePDF.git

Require ChromePDF and it's dependencies in your PHP.

Quick Start

Just pass your HTML in to ChromePDF and save the output:

// reference the ChromePDF namespace
use Royalty\ChromePDF\ChromePDF;

// instantiate and use the ChromePDF class
$chromepdf = new ChromePDF();
$chromepdf->loadHtml('<h1>Hello world! If you can see this, this library works!</h1>');

// Save the pdf
$chromepdf->save('output.pdf');

Setting Options

Set options anytime before running save(string $output_path):

Method Signature Description (default is bolded)
setGPUAcceleration(bool $setting) Set GPU Acceleration (on/off)
setMargins(bool $setting) Set Margins (on/off)
setPDFHeaders(bool $setting) Set PDF Headers (on/off)
setWindowSize($width, $height) Set Window Size (default: 800x600)
setRenderWait($duration = 0) Set Render Wait (timeout before loading, default: 0)
improveRenderingQuality(bool $setting = true) Improve Rendering Quality (on/off)

License

This project is licensed under the The MIT License (MIT).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-14