【问题标题】:Call to undefined method Smalot\PdfParser\Encoding::__toString()调用未定义的方法 Smalot\PdfParser\Encoding::__toString()
【发布时间】:2020-10-26 06:52:54
【问题描述】:

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

还有其他方法吗?

【问题讨论】:

    标签: php pdf-parsing


    【解决方案1】:

    按照以下步骤进行

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

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

    1. 搜索函数

    翻译字符 3. 注释掉下面提到的代码(或删除)

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

    1. 保存文件并退出。

    【讨论】:

      猜你喜欢
      • 2023-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-27
      • 2019-10-25
      • 2018-07-11
      • 2013-10-23
      相关资源
      最近更新 更多