首页 > 解决方案 > sh:pdftotext:找不到命令

问题描述

我有一个 PHP 页面,它调用 pdftotext 命令将 pdf 文件转换为文本文件,然后进行一些后续处理。我使用 shell_exec 命令来执行 pdftotext 命令。

在执行时,我收到以下错误:

sh: pdftotext: command not found

代码:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$url = 'https://testdomain.com/sample.pdf';
$contents = file_get_contents($url);
file_put_contents('delta_file.pdf', $contents);
echo shell_exec("pdftotext -layout delta_file.pdf text_contents.txt 2>&1");

我究竟做错了什么?我已经安装了pdftotext。

有任何想法吗?

标签: phppdfshell-execpdftotext

解决方案


推荐阅读