承接 andrew72ru/web-to-print 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

andrew72ru/web-to-print

最新稳定版本:v1.0.0

Composer 安装命令:

composer require andrew72ru/web-to-print

包简介

The package for generating PDF pages from HTML with headless Chrome and Chrome-driver

README 文档

README

The package for generating PDF pages from HTML with headless Chrome and Chrome driver.

Requirements

This package requires PHP >= 8.0 with ctype and iconv extensions. You must also have installed Chrome (chromium) and cromedriver executables in your working environment.

Usage

First, create an instance of the Chrome Driver runner:

$logger = new \Psr\Log\NullLogger(); // Choose your Psr\Log\LoggerInterface implementation
$runner = new \Andrew72ru\Web2print\DriverRunner($logger, '/path/to/chromedriver');

After that, you can call the PrintToPdf class:

$printer = new \Andrew72ru\Web2print\PrintToPdf($runner, $logger);
$result = $printer('https://google.com', asBas64: true); // You can get Base64 or binary string
\file_put_contents('google.pdf', \base64_decode($result));

As a result, you will have a 'google.pdf' file in your working directory.

Default options

The PrintToPdf class has a set of default options to run the Chrome and the print command.

Chrome options

$defaultArguments = ['--headless', '--run-all-compositor-stages-before-draw'];

Print options

$defaultParams = [
    'displayHeaderFooter' => false,
    'printBackground' => true,
    'marginTop' => 0,
    'marginBottom' => 0,
    'marginLeft' => 0,
    'marginRight' => 0,
];

See references in Chrome manual.

Testing

Before tests, you must put the chromedriver executable into the project root.

Run tests:

vendor/bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固