Thinkphp5整合wkhtmltox扩展将html转image或pdf
安装php-wkhtmltox扩展
参看 https://blog.youkuaiyun.com/LAMPDOWN/article/details/87785359
实现转换的类
<?php
namespace app\common\helper;
use think\image\Exception as ImageException;
/**
* 转换器助手
* 提供html转image、pdf的功能
* Class Conversion
*/
class Conversion{
/**
* @var array 图片后缀名
*/
private $imageSuffix = ['.jpg','.png','.jpeg','.bmp','.gif','.ico'];
/**
* @var string 图片存储路径
*/
private $imagePath = RUNTIME_PATH . 'image'. DS ;
/**
* @var string pdf文档存储路径
*/
private $pdfPath = RUNTIME_PATH . 'pdf'. DS ;
/**
* @var string 图片名
*/
private $imageName;
/**
* @var string pdf文档名
*/
private $pdfName;
public function __construct()
{
if (!file_exists($this-

本文介绍如何在ThinkPHP5中整合wkhtmltox扩展,实现将HTML网页转换为图片或PDF文档的功能。文章详细讲解了wkhtmltox扩展的安装过程,并提供了转换类的代码示例,包括对图片和PDF文档存储路径的处理。
最低0.47元/天 解锁文章
1033





