红联Linux门户
Linux帮助

zhtmltopdf v0.2版发布 url页面转存为pdf或image扩展

发布时间:2014-06-05 21:24:24来源:红联作者:empast
zhtmltopdf 是一个把 url页面转存为 pdf 或者 image 的php扩展:

本次更新:

1) 只输入url,可直接得到转换后的内容,可直接echo输出。

2) 图片新增 quailty参数选项,可控制图片的品质

更多内容: https://github.com/shenzhe/zhtmltopdf
附介绍:

编译和安装
phpize
./configure
make
make install

得到的zhtmltopdf.so文件加入到你的php.ini里
用法
//参数1: 网址
//参数2: 输出的pdf文件名
//会生成pdf文件
zhtml2pdf("http://www.baidu.com", "./baidu.pdf");

//参数1: 网址
//只输入参数,可直接到到pdf的数据, 可直接echo或输出到浏览器
$content = zhtml2pdf("http://www.baidu.com");
echo $content;

//参数1: 网址
//参数2: 生成的img文件名 (可选)
//参数3: 图片fmt(可选) jpeg(默认), png, bmp
//参数4: 图片质量(可选) 默认80
zhtml2img("http://www.baidu.com", "./baidu.jpg");

//参数1: 网址
//只输入参数,可直接到到图片的数据, 可直接echo或输出到浏览器
$content = zhtml2img("http://www.baidu.com");
echo $content;
一些问题

一、线上服务器乱码解决:

1)系统的LANG设置为: LANG=zh_CN.UTF-8

2) 缺少字体,可以把本地的字体copy到服务器上 /usr/share/fonts/chinese/TrueType目录下

二、mac等系统编译问题 (自带的so是在linux amd64 下编译的)

1) 去:https://github.com/wkhtmltopdf/wkhtmltopdf 下载,然后编译安装到xxx目录,

2)安装扩展时 ./configure --with-wkhtmltox-dir=xxx (xxx为1里wkhtmltopdf的安装目录)

来自:开源中国社区
文章评论

共有 0 条评论