Jor*_*gal 3 command-line command google-chrome
我正在 Windows 中使用命令行,使用 Google Chrome 和无头选项“打印到 PDF”来打印 PDF。我想知道如何使用其他可用选项作为边距和页面大小甚至方向。我注意到https://chromedevtools.github.io/devtools-protocol/tot/Page#method-printToPDF中提供了这些选项
但基于这个问题,它似乎不起作用https://superuser.com/questions/1281309/how-can-i-print-a-webpage-in-landscape-mode-using-headless-chromium-on-the-逗号
有人使用任何可用的选项吗?正确的sintaxis是什么,因为下面的代码生成pdf但忽略页面大小?
chrome.exe --headless --disable-gpu --print-to-pdf=C:\\Spotfire_Export\\'+filename+'.pdf --paperWidth=15 '+tempFolder+filename+'.html
Run Code Online (Sandbox Code Playgroud)
小智 6
我也遇到了同样的问题,并找到了前面提到的相同链接。
我正在使用 PHP 生成页面并通过exec.
然后我找到了这个页面并尝试了我的案例,效果很好。
这是我在 CSS 中添加的代码。
@page {
size: A4 landscape;
margin: 0;
}
Run Code Online (Sandbox Code Playgroud)
我希望这对某人有帮助。