node.js - 使用 puppeteer 生成的 PDF 中的所有页面中的表标题均不重复

标签 node.js puppeteer

我正在使用 puppeteer 生成网页的 pdf。但问题是表格标题并未出现在所有页面中。请找到下面的代码。

const browser = await puppeteer.launch({headless: true, windowSize: '1024,768'});

const page = await browser.newPage();
await page.goto('https://my.website.io/sample.php/647/26669?report_id=647&search_engine_id=26669&data_rows=45&view_type=summary,competition-wise,page-wise,competitor-landscape,advertisers&from_date=2018-8-4&pdf_view=yes&compare_to_date=&keyword_rankings_sort_by=search_volume&keyword_rankings_sort_order=asc&api-key=45454545454554545');

await page.setViewport({width:1024, height:768, isLandscape:true, deviceScaleFactor: 1});
await page.waitFor(15000);
await page.pdf({path: 'sample.pdf',printBackground: true,format:'A3',width:'1024px',height:'768px',landscape:true,margin:{top: "190px",bottom: "150px"}});
await browser.close();

上面的代码在我的服务器上不起作用。但与 https://try-puppeteer.appspot.com/ 配合得很好

最佳答案

我已经找到解决方案了。我必须将 puppeteer 1.5.0 升级到 1.7.0

谢谢

关于node.js - 使用 puppeteer 生成的 PDF 中的所有页面中的表标题均不重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52154485/

相关文章:

node.js - 在 Vagrant VM 上安装旧版本的 Node.js

javascript - 在 Buster.js 测试中导入其他 .js 文件

puppeteer - Windows 10 - 运行 puppeteer 脚本会打开一个空白的 Chromium 窗口

node.js - 使用 Tor 运行 Puppeteer

javascript - 在 Chrome 中加载页面时如何捕获所有网络请求和完整响应数据?

javascript - nodejs - 等待 fs.stat 完成

javascript - nodemailer - anchor 标记不起作用

node.js - 在 Angular 和 Node Js postgreSQL 中登录

node.js - 是否可以从 Chrome 跟踪事件数据中获取 Web Vitals?

docker - 通过 no-sandbox 但仍然出现错误 'Running as root without --no-sandbox is not supported.`