当前位置:首页 > PHP > 正文内容

php将html转为pdf,php将html页面导出pdf

高老师9年前 (2017-07-23)PHP2087
  1. 首先下载wkhtmltox-0.12.4_linux-generic-amd64.tar.xz   (不要下载RPM包,依赖太多,需要x-server支持),并解压,执行测试运行正常

  2. tar wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    cd   wkhtmltox-0.12.4_linux-generic-amd64/bi
    ./wkhtmltopdf   http://www.gaojiufeng.cn   1.pdf
  3. 移动文件夹到规范目录,设置系统环境变

  4. mv  wkhtmltox      /usr/local                 //移动文件
    vi  /etc/profile                                    //编辑配置文件
    PATH=/usr/local/wkhtmltox/bin:$PATH
    
    export PATH
    
    //以上复制文件底部
    source /etc/profile                               //配置文件立即生效
    wkhtmltopdf  http://www.gaojiufeng.cn 1.pdf
  5. .PHP调用代码

  6. <?php
    
        exec('/usr/local/wkhtmltox/bin/wkhtmltopdf --zoom 1.1 http://www.gaojiufeng.cn 1.pdf',$return);  
        //exec("wkhtmltopdf  http://www.gaojiufeng.cn 2.pdf",$output);  //低PHP版本可以用.
        if(!$return){
        	echo 'success';
        }
        else{
        	echo 'failed';
        }
    ?>

           提示:如果无法执行exec请在php.ini中允许执行exec函数

扫描二维码推送至手机访问。

版权声明:本文由高久峰个人博客发布,如需转载请注明出处。

本文链接:https://blog.20230611.cn/post/35.html

分享给朋友:

“php将html转为pdf,php将html页面导出pdf” 的相关文章

PHP模拟并发请求

PHP模拟并发请求

原理:使用curl_init()创建多个请求实例,再使用curl_multi_init()批量执行创建的多个请求实例。文件1:curl.php<?php  $threads=500;//并发请求次数 $url='http://blog.cn/index.php?';...

packagist包发布稳定版

packagist包发布稳定版

自己的composer已经发布到packagist,但是无法使用composer require easy-task/easy-task来安装,只能在配置文件使用如下方式安装:"require": {     "easy...

 thinkphp5定时任务,tp5定时任务,thinkphp定时任务,php定时任务,php定时器

thinkphp5定时任务,tp5定时任务,thinkphp定时任务,php定时任务,php定时器

本教程使用的定时任务基于EasyTak,EasyTask官方文档:https://gitee.com/392223903/EasyTask(1).安装tp5.0或者5.1composer create-project topthink/think=5.0.* tp5&n...

No releases available for package,pecl 安装扩展提示No releases available for package

No releases available for package,pecl 安装扩展提示No releases available for package

安装php-redis扩展提示No releases available for package我直接去php官网下载redis扩展.tgz文件,然后直接用pecl安装本地文件pecl install  ./redis.tgz...

php定时任务,php定时器,php定时器,php定时任务管理,php定时任务框架,php实现定时任务,php定时任务系统

php定时任务,php定时器,php定时器,php定时任务管理,php定时任务框架,php实现定时任务,php定时任务系统

        本教程使用的定时任务基于EasyTak实现,EasyTask官方参考文档:https://gitee.com/392223903/EasyTask首先我们必须明白PHP的定时器只能基于CLI命令行形式运行...

EasyTask使用redis队列教程

EasyTask使用redis队列教程

场景:模拟验证码发送。仅做代码演示。(1).创建一个验证码发送接口sendCaptcha/**  * 发送验证码  */ public function sendCaptcha() {     //外部参数(获...