javascript - 使用 puppeteer API 生成 pdf 时无法捕获图像

标签 javascript node.js selenium-chromedriver puppeteer google-chrome-headless

Node- v8.11.1 headless Chrome
我正在尝试生成 PDF,但不知何故,PDF 中未捕获背景图像。 下面是代码。感谢任何帮助

const puppeteer = require('puppeteer'); 
(async () => {
const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
await page.goto('http://54.201.139.151/', {waitUntil : 'networkidle0'});
await page.pdf({path: 'hn40.pdf', printBackground: true, width: '1024px' , height: '768px'});
await browser.close();
})();

最佳答案

更新:page.emulateMedia() 已被删除,取而代之的是 page.emulateMediaType()

关于javascript - 使用 puppeteer API 生成 pdf 时无法捕获图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49743757/

相关文章:

javascript - NodeJS/mssql 错误处理差异

javascript - 如何为 Node.js 创建模块?

python - Selenium 2.53.5 httplib.BadStatusLine : '' Python

javascript - focus() 函数在 Firefox 中不起作用

javascript - Navbar 更多在右侧

javascript - onclick 事件仅适用于按钮,不适用于与按钮一起使用的字形

javascript - 允许用户使用图像和文本编写动态博客页面

ajax - node.js 表达 ajax session

python - urllib3.exceptions.ProtocolError : ('Connection aborted.' , 错误 (10054, 'An existing connection was forcibly closed by the remote host' ))

c# - 将浏览器缩放设置为 80% 的 ChromeOptions