福尔摩斯对我笑 2018-12-07 29881 次 13259条

参考gitHub: pdfjs 毕竟强大,但是主要靠把网页转成图片在转为PDF的方式,这样很多PDF里面都是图片,用户体验不好,pass

  • https://github.com/linwalker/render-html-to-pdf


参考:https://www.cnblogs.com/dreamless/p/9673792.html https://www.jianshu.com/p/8e65fdcb6d85 https://juejin.im/post/5a68a501f265da3e54693f30

API文档: https://pptr.dev/ https://my.oschina.net/reamd7/blog/1634846 中文版: https://blog.csdn.net/deeplies/article/details/80861761#class-browserfetcher

删除PDF第一页的标题 ` @page:first {margin-top: 0;} body {margin-top: 1cm;}



var detalStr = /<div class=\"productLink\">[\s\S]*?<\/div>.*<div class=\"productMain\">/;
const sequenceStr = /<div class="show_sequence.*<\/a><\/div>/;
const Protocol = /<div ><a  >Request for protocol<\/a><\/div>/g;
(async () => {
var enDetail = fs.readFileSync("./en-detail.html","utf-8"); //获取html代码
enDetail = enDetail.replace(/[\r\n]/g,""); //去除换行和空格
enDetail = enDetail.replace(detalStr,`<div >`) //去除头信息
enDetail =enDetail.replace(/\/static\/main\/products\//g,"./").replace(detalStr,"").replace(sequenceStr, "").replace(Protocol, ""); //替换图片路径和其他内容
const browser = await puppeteer.launch();
const page = await browser.newPage();
var pp = await page.goto(`file:${path.join(__dirname)}`);
await page.setContent(enDetail); //设置PDF内容
await page.addStyleTag
path: './en.css',

标签: 无


未来博客 博主大人



已有 13259 条评论 1

  1. StevDede

    Zithromax Dosing Chart Cialis Professional Generique 20 Mg Keflex 250 Mg viagra Priligy Forum 2013 Propecia Temples Levitra Italiano

    回复 2019年10月13日
  2. nike epic react flyknit

    I as well as my friends came analyzing the nice solutions found on the website and so suddenly I had a terrible feeling I never thanked the web site owner for them. Those boys are actually absolutely passionate to study them and have now extremely been loving them. I appreciate you for actually being quite kind as well as for choosing varieties of very good resources millions of individuals are really wanting to learn about. My personal honest regret for not expressing gratitude to you sooner.

    回复 2019年10月13日
  3. golden goose sneakers

    Thanks a lot for giving everyone such a special chance to discover important secrets from this website. It can be very excellent plus packed with a great time for me personally and my office co-workers to visit your blog at the very least three times weekly to read through the fresh things you have. And of course, I’m so actually contented concerning the attractive solutions you give. Some 2 facts on this page are ultimately the most effective I’ve had.

    回复 2019年10月12日
  4. nhl jerseys

    I truly wanted to send a message to thank you for all the pleasant tricks you are giving out on this website. My long internet look up has finally been paid with reputable facts and techniques to exchange with my best friends. I ‘d express that we website visitors actually are really lucky to dwell in a notable site with many wonderful individuals with beneficial opinions. I feel truly privileged to have seen your web page and look forward to some more pleasurable times reading here. Thanks once again for everything.

    回复 2019年10月11日
  5. nike air vapormax

    Needed to post you one tiny remark to help say thanks over again over the incredible techniques you’ve provided at this time. It was so particularly open-handed with people like you to present publicly all that many of us could have sold as an e-book in making some dough for their own end, mostly seeing that you might well have tried it in case you wanted. These good tips also acted as a great way to understand that some people have the identical desire the same as my personal own to figure out very much more with regard to this matter. Certainly there are several more fun times up front for those who examine your blog post.

    回复 2019年10月10日
  6. coach outlet

    I enjoy you because of every one of your labor on this blog. My aunt really loves carrying out research and it’s simple to grasp why. Most of us hear all regarding the compelling means you create very helpful guidelines by means of your web site and as well as increase response from people on this content plus our simple princess has been becoming educated so much. Enjoy the remaining portion of the new year. You are performing a remarkable job.

    回复 2019年10月9日
  7. moncler

    Thank you so much for providing individuals with an extraordinarily brilliant possiblity to check tips from this blog. It is always so terrific plus stuffed with a great time for me and my office peers to visit your web site at a minimum thrice in 7 days to read through the new things you will have. And of course, I’m so usually astounded with the effective creative ideas you give. Some 3 ideas in this posting are without a doubt the finest we have all ever had.

    回复 2019年10月8日
  8. nike shoes for women

    I actually wanted to type a small word in order to appreciate you for all the nice suggestions you are placing at this website. My time intensive internet lookup has at the end of the day been honored with wonderful strategies to talk about with my two friends. I ‘d claim that we visitors are undeniably endowed to be in a wonderful network with very many wonderful individuals with beneficial secrets. I feel truly fortunate to have encountered your site and look forward to many more thrilling moments reading here. Thanks a lot once again for all the details.

    回复 2019年10月7日