node--生成pdf

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_42813491/article/details/102646051

学习资源推荐

nodejs--生成pdf

安装

  • npm i puppeteer

快速使用

  • app.js
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});
  await page.pdf({path: 'hn.pdf', format: 'A4'});

  await browser.close();
})();

执行

  • node app.js

API文档

猜你喜欢

转载自blog.csdn.net/qq_42813491/article/details/102646051
今日推荐