wkhtmltopdf return 空白页
wkhtmltopdf return blank page
我无法使用 wkhtmltopdf 将我的 php 转换为 pdf。
require 'vendor/autoload.php';
ob_start();
require 'pdf/test.html';
$content = ob_get_clean();
$pdf = new \mikehaertl\wkhtmlto\Pdf($content);
$pdf->send();
我在我的 PC 上安装了 composer 和 wkhtmltopdf,当我启动我的代码时,我有一个空白页面。
你有解决方案可以提供给我吗?
提前谢谢你。
尝试使用,将'/path/to/page.html'更改为您的页面link/url :
use mikehaertl\wkhtmlto\Pdf;
// You can pass a filename, a HTML string, an URL or an options array to the constructor
$pdf = new Pdf('/path/to/page.html');
// On some systems you may have to set the path to the wkhtmltopdf executable
// $pdf->binary = 'C:\...';
if (!$pdf->saveAs('/path/to/page.pdf')) {
$error = $pdf->getError();
// ... handle error here
}
谢谢 Simone Rossaini。
我添加了这一行并且它起作用了,我用 saveAs () 替换了 send () 但是 css 没有加载。
//path to the wkhtmltopdf executable
$pdf->binary = 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf';
$pdf->saveAs('pdf/report.pdf');
我无法使用 wkhtmltopdf 将我的 php 转换为 pdf。
require 'vendor/autoload.php';
ob_start();
require 'pdf/test.html';
$content = ob_get_clean();
$pdf = new \mikehaertl\wkhtmlto\Pdf($content);
$pdf->send();
我在我的 PC 上安装了 composer 和 wkhtmltopdf,当我启动我的代码时,我有一个空白页面。
你有解决方案可以提供给我吗?
提前谢谢你。
尝试使用,将'/path/to/page.html'更改为您的页面link/url :
use mikehaertl\wkhtmlto\Pdf;
// You can pass a filename, a HTML string, an URL or an options array to the constructor
$pdf = new Pdf('/path/to/page.html');
// On some systems you may have to set the path to the wkhtmltopdf executable
// $pdf->binary = 'C:\...';
if (!$pdf->saveAs('/path/to/page.pdf')) {
$error = $pdf->getError();
// ... handle error here
}
谢谢 Simone Rossaini。
我添加了这一行并且它起作用了,我用 saveAs () 替换了 send () 但是 css 没有加载。
//path to the wkhtmltopdf executable
$pdf->binary = 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf';
$pdf->saveAs('pdf/report.pdf');