Cod*_*key 5 google-chrome-headless
我想模仿用户在查看我的网页时缩小到80%的情况。遵循以下原则
`google-chrome --headless --disable-gpu --screenshot --zoom=0.8 --window-size=1920,1080 http://www.example.com/`
Run Code Online (Sandbox Code Playgroud)
但是“ zoom”属性不存在,在此列表中我找不到任何可比的东西:
https://peter.sh/experiments/chromium-command-line-switches/
对于人们来说,这肯定是一件很平常的事情,所以我觉得我一定错过了一些简单的事情……
您不需要为此使用 chrome 无头功能 - 只要您在那里进行缩放,chrome 就会渲染您的 css。这是我使用的CSS:
@media print{
@page { margin: 2%; size: A4 }
body { margin: 1.6cm; zoom: .7;}
footer {
position: fixed;
bottom: 1;
}
header {
position: fixed;
top: 1;
}
}
Run Code Online (Sandbox Code Playgroud)
注意zoom: .7正文中的 ... 发出以下 chrome 无头调用:
chrome --headless --disable-gpu --print-to-pdf \
'https://qto.fi:442/qto/view/installations_doc?&bid=0&as=print-doc'
Run Code Online (Sandbox Code Playgroud)
奖励:如果您想要带有一些徽标等的自定义页眉和页脚,只需添加页眉和页脚标签:
<header><p>header</p></header>
<footer><p>footer</p></footer>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
452 次 |
| 最近记录: |