承接 brs-software/html2pdf 相关项目开发

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

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

brs-software/html2pdf

最新稳定版本:v1.1.0

Composer 安装命令:

composer require brs-software/html2pdf

包简介

Common interface for converting HTML documents to PDF using adapters

README 文档

README

Common interface for converting HTML documents to PDF using adapters.

Available adapters

Examples

Example for Wkhtmltopdf adapter

<?php
use Brs\Html2Pdf\Html2Pdf;
use Brs\Html2Pdf\Adapter\Wkhtmltopdf;

// you can optionally test the environment
Wkhtmltopdf::testEnv();

$adapter = new Wkhtmltopdf;

// you can change path to binary on your server
$adapter->getWkhtmltopdfCmd()
    ->setPrefix('/special/path/to/whhtmltopdf')
;

// add wkhtmltopdf parameter
$adapter->getWkhtmltopdfCmd()
    ->add('--ignore-load-errors')
    ->add('--lowquality')
;

// if you must to use xvfb-run you can configure it
$adapter->getXvfbCmd()
    ->setPrefix('/special/path/to/xvfb-run')
    ->setArguments(['--server-args=-screen 0, 800x600x24'])
;

$converter = new Html2Pdf($adapter);

// set html file to convert
$converter->setHtmlFile('path/to/document.html');
// or html string
$converter->setHtmlDocument('
<html>
    <body>
        <strong>test pdf</strong>
    </body>
</html>
');
// or url
$converter->setUrl('http://google.com');

// generate the pdf file
$pdf = $converter->getPdfFile();

// send to client for download
$pdf->sendToBrowser('file.pdf');

// or save as local file
$pdf->saveAs('some/path/to/file.pdf');

Requirments

  • PHP 5.4 or higher

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: The
  • 更新时间: 2015-10-15