wkhtmltopdf页眉和页脚间距不起作用

huangapple go评论79阅读模式
英文:

wkhtmltopdf header and footer spacing is not working

问题

使用wkhtmltopdf 0.12.6和mikehaertl的phpwkhtmltopdf,我正在尝试在设置页眉和页脚间距的同时为每个页面添加页眉和页脚。
在服务器上安装的wkhtmltopdf版本从较旧的二进制文件切换到0.12.6后,此功能曾经可以正常工作。服务器正在运行AlmaLinux 8.7。

创建文件:

$pdf_options = array(
	'load-error-handling' => 'ignore',
	'ignoreWarnings' => true,
	'enable-javascript',
	'dpi' => '300',
	'no-outline',
	'margin-bottom' => '0mm',
	'margin-top' => '0mm',
	'margin-left' => '0mm',
	'margin-right' => '0mm',
	'header-html' => '/path/to/header.html',
	'footer-html' => '/path/to/footer.html',
	'header-spacing' => 20,
	'footer-spacing' => 15,
);
$pdf = new Pdf($pdf_options);
$pdf->addPage($html);
$pdf->send('pdf.pdf');

预期输出:
预期输出

实际输出:
实际输出

如你所见,间距丢失,没有页眉或页脚。
可能导致这个问题的原因是什么?

英文:

Using wkhtmltopdf 0.12.6 and mikehaertl's phpwkhtmltopdf I'm trying to add a header and footer to each page while setting the header and footer spacing.
This used to work when using an older binary file, but we recently switched to 0.12.6 installed on the server. The server is running on AlmaLinux 8.7.

Creating the file:

$pdf_options = array(
	'load-error-handling' => 'ignore',
	'ignoreWarnings'=> true,
	'enable-javascript',
	'dpi' => '300',
	'no-outline',
	'margin-bottom' => '0mm',
	'margin-top' => '0mm',
	'margin-left' => '0mm',
	'margin-right' => '0mm',
	'header-html' => '/path/to/header.html',
	'footer-html' => '/path/to/footer.html',
	'header-spacing' => 20,
	'footer-spacing' => 15,
);
$pdf = new Pdf($pdf_options);
$pdf->addPage($html);
$pdf->send('pdf.pdf');

Expected output:
Expected output

Given output
Given output

As you can see, the spacing is lost and there is no header or footer.
What can cause the issue?

答案1

得分: 1

找到了解决方案,经过一番尝试。设置header-spacing和footer-spacing而不设置margin-top和margin-bottom是无效的。同时应用这两个选项可以使其工作。仅设置margin会将页眉放在真实文本之上而不是在其上方。

英文:

Found the solution myself after fiddling around.
Setting the header-spacing and footer-spacing without the margin-top and margin-bottom does not work. Applying both options makes it work.
Also setting just the margin puts the header over of the real text and not above it.

huangapple
  • 本文由 发表于 2023年3月7日 23:06:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663714.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定