微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

调用未定义的方法Smalot \ PdfParser \ Encoding :: __ toString

如何解决调用未定义的方法Smalot \ PdfParser \ Encoding :: __ toString

我正在使用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

还有其他方法吗?

解决方法

按照以下步骤

1。在编辑器上打开下面提到的文件

供应商\ smalot \ pdfparser \ src \ Smalot \ PdfParser \ Font.php

  1. 搜索功能

translateChar 3.注释掉以下代码(或删除)

如果(\ strlen($ char) has('Encoding')&&'WinAnsiEncoding' === $ this-> get('Encoding')-> __ toString()){ $ fallbackDecoded = self :: uchr($ dec); }

  1. 保存文件并退出。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。