在鲲鹏版的centos操作系统 上使用wkhtmltopdf,html文件中找不到本地的css和png文件

在使用wkhtmltopdf将网页转换为PDF时,遇到无法访问本地文件及样式表的问题,本文介绍了解决方案,即通过添加--enable-local-file-access和--allow参数来允许访问本地资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用的 wkhtmltopdf wkhtmltox-0.12.6-1.centos7.aarch64.rpm

转换的时候wkhtmltopdf 报错信息:

Warning: Blocked access to file /home/xxx/apache-tomcat-8.5.47/webapps1/xxx/WEB-INF/classes/images/service/logo_zr.png
Warning: Blocked access to file /home/xxx/apache-tomcat-8.5.47/webapps1/xxx/WEB-INF/classes/images/service/level2.png
Warning: Blocked access to file /home/xxx/apache-tomcat-8.5.47/webapps1/xxx/WEB-INF/classes/images/service/over_zr.png
Warning: Failed to load /home/xxx/apache-tomcat-8.5.47/webapps1/xxx/WEB-INF/classes/static/css/service/pdf.css (ignore)
Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown
Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown
Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown

 

解决方案:

添加:这个两个参数 --enable-local-file-access  --allow 而且要放在 wkhtmltopdf 命令之后其他命令之前。

 

========================================================================================

如果centos7上安装了wkhtmltox-0.12.5-1.centos7.x86_64.rpm,则可以不用添加 这个两个参数 --enable-local-file-access --allow

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值