从使用Headless Chrome创建的PDF中删除时间戳和页面URL

时间:2018-09-27 23:10:31

标签: google-chrome-headless

我有一个PHP应用程序,通过将一些无头的Chrome指令包装到命令行语句中,然后使用shell_exec()运行它,将网页另存为pdf文件。

 Sidekiq.configure_server do |config|
  config.redis = { url: 'redis://redis:6379/12' }
 end

这对我来说很好,并且可以满足我的需求。但是,生成的pdf文件在页眉和页脚中具有日期和时间,在页脚中也具有页面url。我尝试使用--no-margins选项删除此多余的文本,但这没有用,我的Goggle-Fu使我失败了。是否可以从使用Headless Chrome创建的pdf中删除时间戳和网址?

我提出了以下类似问题,但尚未找到答案:

1 个答案:

答案 0 :(得分:0)

答案实际上是在另一个StackOverflow问题中找到的:

How to remove the URL from the printing page?

<style type="text/css" media="print">
@page {
    size: auto;   /* auto is the initial value */
    margin: 0;  /* this affects the margin in the printer settings */
}
</style>

我本来尝试过,但是我的样式标签没有media属性。