嘿,我很难安装wkhtmltopdf和php wkhtmltopdf。我需要首先将它放在本地服务器上,但稍后必须安装在Web服务器上。我首先在我的项目文件夹中安装了wkhtmltopdf,然后我通过作曲家安装了php wkhtmltopdf 1,这是我从未使用过的。所以我不完全确定我是否正确安装了它,但似乎很简单,我不认为这是问题所在。当我运行一个测试PHP脚本我收到此错误信息:在本地服务器上安装php wkhtmltopdf
警告:proc_open():CreateProcess的失败,错误代码 - 2在C:\ XAMPP \ htdocs中\删除\供应商\ mikehaertl \ PHP-shellcommand \第313行的src \ Command.php 无法运行命令cd“wkhtmltopdf \ bin”& & wkhtmltopdf.exe“C:\ Users \ Robert \ AppData \ Local \ Temp \ tmpE437.tmp.html”“C:\ Users \罗伯特\应用程序数据\本地的\ Temp \ tmpE438.tmp.pdf”
这里是我的测试代码:
/**
* Register Composer Autloader
*/
define('VENDOR_DIR', __DIR__ . '\vendor' . DIRECTORY_SEPARATOR);
if (!is_file(VENDOR_DIR . 'autoload.php')) {
throw new \RuntimeException(
'[Error] Bootstrap: Could not find "vendor/autoload.php".' . PHP_EOL .
'Did you forget to run "composer install --dev"?' . PHP_EOL
);
}
require VENDOR_DIR . 'autoload.php';
/**
* Use library
*/
use mikehaertl\wkhtmlto\Pdf;
$pdf = new Pdf(array(
'binary' => 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe',
'ignoreWarnings' => true,
'commandOptions' => array(
'procEnv' => array(
// Check the output of 'locale' on your system to find supported languages
'LANG' => 'en_US.utf-8',
),
'escapeArgs' => false,
'procOptions' => array(
// This will bypass the cmd.exe which seems to be recommended on Windows
'bypass_shell' => true,
// Also worth a try if you get unexplainable errors
'suppress_errors' => true,
),
),
));
$pdf->addPage('<html>
<head>
</head>
<body>
<div id="print-area">
<div id="header">
This is an example header.
</div>
<div id="content">
<h1>Demo</h1>
<p>This is example content</p>
</div>
<div id="footer">
This is an example footer.
</div>
</div>
</body>
</html>');
if (!$pdf->saveAs('page.pdf')) {
echo $pdf->getError();
}
有谁知道这个问题可能是什么?我需要从本地服务器执行wkhtmltopdf,因为它需要联机工作。我发现另一个有用的堆栈溢出主题,我将链接2,我经历了所有的步骤,但无法正确执行它。任何帮助将非常感激! :)
php wkhtmltopdf stack overflow -installing php wkhtmltopdf