wkhtmltopdf+cpdf实现多个html转pdf,并级联输出pdf

wkhtmltopdf官网https://wkhtmltopdf.org/cpdf官网https://community.coherentpdf.com/wkhtmltopdf下载:wkhtmltopdf 安装相应系统安装包

cpdf下载:https://github.com/coherentgraphics/cpdf-binaries/archive/master.zip

使用场景:

1.页数较多的pdf

2.对页眉页脚有具体需求的pdf

3.可生成相应页码

4.对分页易容易实现,将所需生成的pdf拆分成不同子部分的html,再将pdf级联到一起便可

5.可在页面端实现,pdf生成(html数据需用jquery填充)

命令:

wkhtmltopdf  -B 0 -R 0 -L 0 -T 0   0-report.html 0-report.pdf

说明:将 0-report.html输出为0-report.pdf ,-B -R -L -T分别为下右左上边距

wkhtmltopdf  -B 40 -R 0 -L 0 -T 40  --header-html header.html --footer-html footer-1.html 1-report.html 1-report.pdf

说明:将1-report.html 输出为1-report.pdf ,并指定页眉页脚部分html

cpdf -pos-right "545 22"  -font  "Times-Roman"  -font-size 9  -add-text  "%Page  
 /  %EndPage" -outline   0-report.pdf 1-report.pdf   -o merge.pdf

说明:使用cpdf将0,1html输出为merge.pdf ,merge.pdf为最终输出pdf,-pos-right指定页码相对位置,-font 为字体,-font-size 为页码

注:具体参数可查看wkhtmltopdf  ,cpdf官网说明,实现方式比html2canvas更加灵活,感谢大家支持~~~~

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值