Day*_*ras 17 php pdf wkhtmltopdf
如何更改pdf
生成的文件的方向Wkhtmltopdf
.我在PHP中调用它如下:
$file = fopen("tmp/html/pdfTmp_$numRand.html",
"w") or exit("Unable to open file!");
fwrite($file, $html);
fclose($file);
exec("..\library\wkhtmltopdf\wkhtmltopdf " .
"tmp/html/pdfTmp_$numRand.html tmp/pdf/pdfTmp_$numRand.pdf");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=".$nom."_".$residence.".pdf");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize("tmp/pdf/pdfTmp_$numRand.pdf"));
ob_clean();
flush();
readfile("tmp/pdf/pdfTmp_$numRand.pdf");
Run Code Online (Sandbox Code Playgroud)
$html
在html中包含我的整个页面,这会打开一个临时文件.
这会生成.pdf
纵向方向.我知道wkhtlktopdf可以选择-O landscape
改变方向,但我不知道在PHP脚本中我可以在哪里以及如何编写它.我正在使用Windows 7.
Man*_*tas 29
选项-O landscape
可以解决问题.
只是chage
exec("..\library\wkhtmltopdf\wkhtmltopdf tmp/html/pdfTmp_$numRand.html tmp/pdf/pdfTmp_$numRand.pdf");
Run Code Online (Sandbox Code Playgroud)
喜欢的东西
exec("..\library\wkhtmltopdf\wkhtmltopdf -O landscape tmp/html/pdfTmp_$numRand.html tmp/pdf/pdfTmp_$numRand.pdf");
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20192 次 |
最近记录: |