Giter VIP home page Giter VIP logo

zhtmltopdf's Introduction

zhtmltopdf

zhtmltopdf, 把html页面转成pdf或image的php扩展

编译和安装

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

  1. 缺少字体,可以把本地的字体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的安装目录)

zhtmltopdf's People

Contributors

shenzhe avatar edengzv avatar

Watchers

James Cloos avatar Du avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.