我正在 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)