1 总体
1.1 问题描述
通过 html 和 svg 构建的页面或图形,需要下载或者导出。html转打印不易处理,伴随出现一些问题,如模糊,不一致,错乱等。
急需有一个完善的方案解决,可以清晰的打印html。
1.2 截图
使用截图转换为图片,然后再打印,可以很清晰。目前的截图都需要人工敲击快捷键,才执行截图操作,无法自动执行。
1.3 引入开源组件
通过分析研究,可以引入开源组件puppeteer, 编程实现截图调用操作。开源地址:
https://github.com/GoogleChrome/puppeteer, 项目特点说明:
Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.
What can I do?
Most things that you can do manually in the browser can be done using Puppeteer! Here are a few examples to get you started:
Generate screenshots and PDFs of pages.
Crawl a SPA (Single-Page Application) and generat