定制 frengky/php-wkhtmltox 二次开发

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

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

frengky/php-wkhtmltox

Composer 安装命令:

composer require frengky/php-wkhtmltox

包简介

Simple wkhtmltox wrapper for PHP

README 文档

README

Wkhtmltopdf is the top choice to render your html into a pdf or image. This package is a clean and easy wrapper for wkhtmltopdf and wkhtmltoimage. This package is working directly with wkhtmltopdf's process (stdin and stdout) without creating any temporary files.

Requirements

Install the Wkhtmltopdf binaries for your operating system, make sure wkhtmltopdf and wkhtmltoimage executable in your PATH.

Installation

Install the package via Composer

composer require frengky/php-wkhtmltox

Usage

Convert HTML string into a PDF file:

<?php
use Frengky\WkHtml\PDF;

$htmlString = 'Hello, <strong>World</strong>!'
$outputPath = PDF::fromHtml($contents)
           ->set('--page-size',  'A4') // the args to wkhtmltopdf
           ->set('--orientation',  'Portrait')
           ->saveAs('storage/files/test-success.pdf');

if ($result) {
   echo "Generated pdf output file path: " . $outputPath;
}

You can also working with stream. See PSR-7 StreamInterface and check out guzzle/psr7:

$htmlSource = Psr7\stream_for('Hello, <strong>World</strong>!');
$retval = PDF::fromHtml($htmlSource)
           ->set('--page-size',  'A4') // the args to wkhtmltopdf
           ->set('--orientation',  'Portrait')
           ->render(function(StreamInterface $output) {
				// Do something with the stream
				file_put_contents('output.pdf', $output->getContents());
			});

This is the recommended way if you working with large pdf file output.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固