我使用Pdfparser Library来解析pdf。在解析时,读取20页pdf文件中的某些页面,而不读取某些页面。这是我正在使用的代码
$str_path = 'example_book.pdf';
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($str_path);
$pages = $pdf->getPages();
$page = $pages[7];
$text = $page->getText();
echo $text;当我运行php脚本时,我得到了这个错误:
Call to undefined method Smalot\PdfParser\Encoding::__toString()
Smalot\PdfParser\Font::translateChar
vendor/smalot/pdfparser/src/Smalot/PdfParser/Font.php:104有没有其他方法可以做到这一点?
发布于 2020-11-23 01:04:31
请按照以下步骤操作
1.在编辑器中打开下面提到的文件
vendor\smalot\pdfparser\src\Smalot\PdfParser\Font.php
translateChar 3.注释掉下面提到的代码(或删除)
如果(\strlen($char) <2 && $this->has('Encoding') && 'WinAnsiEncoding‘=== $this->get('Encoding')->__toString()) { $fallbackDecoded = self::uchr($dec);}
https://stackoverflow.com/questions/64532610
复制相似问题