当前位置: 移动技术网 > IT编程>开发语言>JavaScript > phantom.js - HTML To PDF

phantom.js - HTML To PDF

2018年07月30日  | 移动技术网IT编程  | 我要评论
  1. import phantom from 'phantom';  
  2. const pageToPdf = (url) => {  
  3.  phantom.create().then((ph) {  
  4.  ph.createPage().then((page) => {  
  5.   page.open(url).then((status) => {  
  6.   // 配置存储的pdf地址  
  7.   page.render('存储的地址.pdf').then((status) => {  
  8.    console.log('Page rendered');  
  9.    ph.exit();  
  10.   });  
  11.   });  
  12.  });  
  13.  });  
  14. };  
  15. pageToPdf('https://www.tongbanjie.com');  

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网