首页 > 解决方案 > 使用 PDF 文件输入的 Chrome Headless print-to-pdf

问题描述

我正在尝试使用 Headless Chrome 从 pdf 文件重新打印 pdf 文件。

类似帖子:在 ubuntu 中使用无头 chrome 打印 PDF

我已经尝试了几种变体:

chrome --headless --disable-gpu --print-to-pdf=E:/Python/Working/foo_flat3.pdf  file://E:/Python/Working/foo_flat2.pdf

chrome --headless --disable-gpu --print-to-pdf=E:/Python/Working/foo_flat3.pdf  "E:/Python/Working/foo_flat2.pdf"

并且不会生成 PDF 文件。当我使用网页时,例如:

chrome --headless --disable-gpu --print-to-pdf=E:/Python/Working/foo_flat3.pdf  https://www.google.com/

它按预期运行,并生成“foo_flat3.pdf”。

我为什么要这样做?我正在尝试利用 Chrome 解锁和展平 pdf 文件的能力,因为它是我找到的最快的选项。如果还有其他选择,我也会对这些感兴趣。

标签: google-chromegoogle-chrome-headless

解决方案


推荐阅读