wkhtmltopdf多页避免分页

时间:2015-08-17 13:53:11

标签: wkhtmltopdf

我正在从两个网址生成一个pdf文件,到目前为止工作正常。唯一的问题是,我不希望这两个文件之间有分页符。第二个文件应该在第一个文件结束后直接启动。由于两者都是我服务器上的html文件,我试图不在第一个文件中关闭body和html标签,但没有运气。

我执行的脚本如下所示:

'/usr/local/bin/wkhtmltopdf ' . $sessionstring . '--no-stop-slow-scripts --print-media-type --enable-javascript --margin-top 35mm --margin-bottom 25mm --margin-right 25mm --margin-left 20mm --orientation portrait --header-html "' . $env['HEADER'] . '"  --header-spacing 10 -s A4 --dpi 96 --encoding utf-8 --image-quality 100 ' . $env['CONTENT'] . ' ' . $_SERVER['DOCUMENT_ROOT'] . $outputname

任何有关实现的提示?顺便说一句,我不能在发送给WKHTML之前合并这两个文件。我确实需要在WKHTML中组合它们。

1 个答案:

答案 0 :(得分:0)

WK将在每次单独输入后始终创建分页符,因此无法以这种方式执行此操作。

我真的只是找到一种方法来组合这两个文件。

例如,使用PHP脚本可以很容易地实现这一点:

$file1 = file_get_contents('path_to_file1');
$file2 = file_get_contents('path_to_file2');
file_put_contents('save_path', $file1 . $file2);

您甚至可以通过相同的PHP脚本运行WK脚本:

exec('wkhtmltopdf your_wk_params_here');
相关问题