webimgpdf-convert
网页,html,pdf,图片互转
Dependencies
使用前安装配置phantomjs环境
安装请参考 http://phantomjs.org/download
Installation
npm
npm install webimgpdf-convert
yarn
yarn add webimgpdf-convert
Usage
const path = require('path');const wip = require('webimgpdf-convert');const web = 'https://www.baidu.com'; const pdf = path.join(process.cwd(),'a.pdf');const img = path.join(process.cwd(),'a.jpg');const html = path.join(process.cwd(),'a.html'); //将网页转成pdfwip.webToPdf(web, pdf); //将网页转成imgwip.webToImg(web, img); //将html转成pdfwip.htmlToPdf(html, pdf); //将html转成imgwip.htmlToImg(html, img);