fpdi读取部分版本PDF失败

时间:2022-02-10 16:40:18

打开部分版本报此问题: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)

后来查看有问题的版本是1.6

图片.png

没问题的是1.7

图片.png

代码类库:xthiago/pdf-version-converter - Packagist

GIT地址: GitHub - xthiago/pdf-version-converter: PHP library for converting the version of PDF files (for compatibility purposes).

版本转换:

1

2

3

4

5

6

7

8

9

// 处理pdf版本问题,发现1.6读取失败,统一转成1.7即可讯出来

$localFile 'xxxxx/xx/xx.pdf';// 绝对路径pdf文件 

$version = (new RegexGuesser())->guess($localFile);

if ($version && $version != '1.7') {

    $command new GhostscriptConverterCommand();

    $filesystem new Filesystem();

    $converter new GhostscriptConverter($command$filesystem);

    $converter->convert($localFile'1.7');

}

由于symfony/process版本兼容问题,没敢直接更新项目的版本。所以直接把git址址中的代码做了变更实现的。

相关文档

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值