zoukankan      html  css  js  c++  java
  • 利用WkHtmlToPdf,把H5 转成PDF

    工具下载地址:

    链接:https://pan.baidu.com/s/1TSq2WWZcvPwuIfPRHST-FA
    提取码:wkx8

     原理:

    通过IIS访问页面,利用WkHtmlToPdf.exe,把H5 转成PDF,方法如下

                
     1 string fileNameWithOutExtention = "test111";
     2             string AbsolutePath = Server.MapPath("~/Tools/wkhtmltopdf.exe");
     3             //执行wkhtmltopdf.exe
     4             //Process p = System.Diagnostics.Process.Start(@"D:wkhtmltopdfwkhtmltopdf.exe", @"http://localhost/JDBPMPDF/HtmlPage1.html D:" + fileNameWithOutExtention + ".pdf");
     5             Process p = System.Diagnostics.Process.Start(AbsolutePath, @"http://localhost/JDBPMPDF/HtmlPage1.html D:" + fileNameWithOutExtention + ".pdf");
     6             //若不加这一行,程序就会马上执行下一句而抓不到文件发生意外:System.IO.FileNotFoundException: 找不到文件 ''。
     7             p.WaitForExit();
     8             //把文件读进文件流
     9             FileStream fs = new FileStream(@"D:" + fileNameWithOutExtention + ".pdf", FileMode.Open);
    10             byte[] file = new byte[fs.Length];
    11             fs.Read(file, 0, file.Length);
    12             fs.Close();
  • 相关阅读:
    centos6和centos7网卡修改
    centos7.4编译安装LNMP
    centos7yum安装LNMP
    jira搭建
    centos6.9编译安装LNMP
    监控命令命令
    linux设置命令历史的时间戳
    zabbix3.0安装
    Mysql(centos7) 主从搭建
    Android 利用剪切板(clipboardManager )实现数据传递
  • 原文地址:https://www.cnblogs.com/ywkcode/p/10886393.html
Copyright © 2011-2022 走看看