温馨提示×

PHP中wkhtmltopdf的配置选项有哪些

PHP
小樊
96
2024-08-09 21:50:38
栏目: 编程语言

在PHP中,可以通过exec()函数来调用wkhtmltopdf命令并设置配置选项。以下是一些常用的wkhtmltopdf配置选项:

  1. --page-size: 设置页面大小,例如A4、Letter等。
  2. --orientation: 设置页面方向,可以是Portrait(纵向)或Landscape(横向)。
  3. --margin-top, --margin-bottom, --margin-left, --margin-right: 设置页面的上、下、左、右边距。
  4. --header-html, --footer-html: 设置页眉和页脚的HTML内容。
  5. --header-spacing, --footer-spacing: 设置页眉和页脚与内容之间的距离。
  6. --header-font-size, --footer-font-size: 设置页眉和页脚的字体大小。
  7. --disable-smart-shrinking: 禁用智能缩放,即不自动调整页面大小以适应内容。
  8. --no-images: 禁止加载图片。
  9. --no-background: 禁止加载页面背景。
  10. --print-media-type: 强制使用打印媒体样式。

这些配置选项可以在调用wkhtmltopdf时作为参数传递,例如:

exec('wkhtmltopdf --page-size A4 --margin-top 20mm --margin-bottom 20mm input.html output.pdf');

0