使用fpdf读取PDF文件时,报错:This PDF document probably uses a compression technique which is not supported by the free parser shipped with FPDI. (See https://www.setasign.com/fpdi-pdf-parser for more details)
提示这个文件是采用了一个压缩格式,到官网上查看之后,发现他们提供了fpdi-pdf-paser2,但是这是收费的。。。啊啊啊,短时间内先忽略吧。毕竟这样的PDF不多。
后面再关注一下有没有类似的东西。
1、安装pdf-parser2 : FPDI PDF-Parser 2.x (setasign.com)
2、查看这里的测试代码和示例:https://www.setasign.com/products/fpdi-pdf-parser/details/
目前我是放弃了,因为,他develop version,要100欧,然而这只是我自己用来测试,没必要。
------
后记:
1、读了PDF的第一行,发现这个PDF版本是PDF1.5,尝试用chrome打开,另存为,无效。选择打印->另存为PDF,成功
2、网上也有教程,建议是使用ghostscript来处理,比如:php - FPDF error: This document (testcopy.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI - Stack Overflow,代码比较简单:
PHP代码
- // USE GHOSTSCRIPT IF PDF VERSION ABOVE 1.4 AND SAVE ANY PDF TO VERSION 1.4 , SAVE NEW PDF OF 1.4 VERSION TO NEW LOCATION
- <?php
- exec('gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="'.$srcfile_new.'" "'.$srcfile.'"');
- ?>
结果,官网上没有mac的可执行文件,又不想编译,所以纯记录一下吧
-----
0227更新:
GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
GPL Ghostscript 9.50: Cannot open X display `(null)'.
**** Unable to open the initial device, quitting.
纠结。