问题描述
我正在使用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;
Call to undefined method Smalot\PdfParser\Encoding::__toString()
Smalot\PdfParser\Font::translateChar
vendor/smalot/pdfparser/src/Smalot/PdfParser/Font.PHP:104
还有其他方法吗?
解决方法
按照以下步骤
1。在编辑器上打开下面提到的文件
供应商\ smalot \ pdfparser \ src \ Smalot \ PdfParser \ Font.php
- 搜索功能
translateChar 3.注释掉以下代码(或删除)
如果(\ strlen($ char) has('Encoding')&&'WinAnsiEncoding' === $ this-> get('Encoding')-> __ toString()){ $ fallbackDecoded = self :: uchr($ dec); }
- 保存文件并退出。