我正在尝试使用 PHP 中的 unoconv 将 word 文档转换为 PDF。当我在 CLI 中运行以下命令时,它可以正常工作而没有任何错误:
export HOME=/tmp/converts && unoconv -f pdf -o ~/da063764384fb612971bfc92c52c40fc.pdf ~/da063764384fb612971bfc92c52c40fc.docx
但问题是当我尝试在 PHP 中运行它时,如下所示:
$env = ['PATH' => '/sbin:/bin:/usr/sbin:/usr/bin'];
$bash = "export HOME=${tmpDir} && /usr/bin/unoconv -f pdf -o ~/${fileName}.pdf $srcFile";$process = new Process($bash);
$process->setTimeout(120);
$process->run(null, $env);
$output = "\nOutput: " . $process->getOutput();
$error = "\nError: " . $process->getErrorOutput();
结果:
Output:
Error: unoconv: RuntimeException during import phase: Office probably died. Binary URP bridge disposed during call
任何人都知道我该如何解决这个问题!?