PDF项目

福尔摩斯对我笑 2018-12-07 13326 次 11897条

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

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

puppeteer的实现方式

参考: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;}

`

页面页脚添加图片时,比较将图片转为base64编码格式,才能正常使用


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内容
//注意这个必须放到设置HTML之后
await page.addStyleTag
({
path: './en.css',
})

标签: 无

非特殊说明,本博所有文章均为博主原创。

上一篇
下一篇
头像也是LOGO
未来博客 博主大人
到了这个年纪,不应该再彷徨!

发表评论



 


已有 11897 条评论 1


  1. kyrie 5 shoes

    My spouse and i got very thrilled that Ervin could complete his investigation out of the precious recommendations he had from your web pages. It is now and again perplexing to just possibly be offering steps which often people may have been making money from. So we fully grasp we now have the blog owner to give thanks to for that. The specific illustrations you made, the simple blog navigation, the relationships your site make it easier to promote – it’s most terrific, and it’s making our son and us understand the topic is pleasurable, and that’s very mandatory. Many thanks for all!

    回复 2019年10月30日
  2. coach outlet

    I wanted to create you this very small remark in order to thank you very much the moment again just for the pretty methods you have documented here. This has been quite pretty generous of people like you to convey without restraint just what many of us could have offered for sale as an ebook to get some dough for themselves, primarily seeing that you might have done it in case you wanted. Those suggestions as well served as a good way to be sure that someone else have the same interest just like my own to know a lot more when it comes to this condition. I’m sure there are thousands of more pleasurable instances up front for those who read through your blog post.

    回复 2019年10月30日
  3. Kanye West shoes

    I precisely desired to thank you very much once more. I am not sure the things I could possibly have created in the absence of these tips contributed by you on that area. It was before a scary issue in my view, but coming across the very skilled style you dealt with the issue forced me to leap with gladness. I will be happier for your service and thus trust you recognize what an amazing job that you are providing instructing others via your websites. Most probably you haven’t come across any of us.

    回复 2019年10月30日
  4. air max 95

    A lot of thanks for all your hard work on this web page. Kim really loves going through investigations and it’s easy to see why. My partner and i hear all concerning the lively form you provide valuable techniques by means of the website and as well as attract participation from people about this issue while our favorite child is now understanding a whole lot. Take pleasure in the rest of the new year. You’re doing a useful job.

    回复 2019年10月29日
  5. hermes belts

    I would like to express appreciation to the writer for rescuing me from this type of challenge. Because of exploring throughout the the web and finding concepts which were not pleasant, I assumed my entire life was well over. Living without the presence of solutions to the issues you have sorted out all through your main short post is a crucial case, as well as those that could have badly damaged my career if I hadn’t discovered the website. Your good mastery and kindness in dealing with all things was tremendous. I’m not sure what I would have done if I hadn’t encountered such a point like this. I can also at this moment look forward to my future. Thanks a lot very much for your high quality and results-oriented guide. I will not think twice to propose your blog post to any individual who ought to have assistance on this problem.

    回复 2019年10月29日
  6. nike shox

    I have to show thanks to the writer for bailing me out of this particular predicament. Right after surfing throughout the search engines and seeing methods which are not powerful, I assumed my entire life was over. Being alive devoid of the strategies to the difficulties you’ve solved as a result of the posting is a crucial case, as well as the kind which might have adversely affected my entire career if I had not discovered your blog. The natural talent and kindness in maneuvering the whole thing was important. I am not sure what I would have done if I hadn’t come across such a point like this. I can also at this point look forward to my future. Thanks very much for this reliable and effective help. I will not hesitate to endorse your web page to any person who needs and wants guidelines on this topic.

    回复 2019年10月29日
  7. golden goose

    I am also commenting to make you understand of the excellent discovery my cousin’s princess enjoyed reading through yuor web blog. She came to understand too many issues, which included what it’s like to possess an amazing helping heart to get men and women completely grasp specific problematic subject areas. You truly exceeded our own expected results. Thank you for churning out the priceless, safe, educational and fun guidance on the topic to Kate.

    回复 2019年10月29日
  8. supreme

    I actually wanted to compose a comment so as to thank you for the unique secrets you are placing on this website. My prolonged internet research has at the end of the day been recognized with extremely good content to share with my contacts. I ‘d assert that we site visitors are extremely lucky to be in a really good place with very many marvellous people with helpful tricks. I feel extremely blessed to have seen your website page and look forward to tons of more enjoyable minutes reading here. Thanks a lot once more for a lot of things.

    回复 2019年10月29日
  9. fitflop

    I and my friends were actually going through the good helpful hints on your website and all of the sudden I had a terrible feeling I had not expressed respect to the site owner for those secrets. Those men became totally passionate to see them and have absolutely been loving those things. Appreciation for getting so thoughtful and also for considering this form of smart themes millions of individuals are really desperate to understand about. My personal sincere regret for not saying thanks to sooner.

    回复 2019年10月28日
  10. kyrie 5

    I simply wanted to send a brief word so as to thank you for all of the precious suggestions you are writing at this website. My time consuming internet search has finally been honored with extremely good facts and techniques to write about with my company. I ‘d assert that we website visitors actually are undoubtedly fortunate to be in a fine community with so many brilliant people with insightful concepts. I feel truly privileged to have encountered your web pages and look forward to plenty of more brilliant times reading here. Thank you once again for everything.

    回复 2019年10月28日
  11. timberland boots

    A lot of thanks for your own work on this site. Ellie take interest in making time for internet research and it is obvious why. Most people learn all concerning the dynamic form you produce useful suggestions by means of this blog and even recommend contribution from visitors on the point so our own simple princess is always being taught a whole lot. Have fun with the remaining portion of the new year. You are always carrying out a really great job.

    回复 2019年10月28日
  12. air max 270

    I and my guys came reviewing the excellent strategies located on your web site then quickly I got a terrible suspicion I never expressed respect to the blog owner for those tips. My people came as a consequence very interested to read them and have seriously been having fun with them. Thanks for getting very helpful and also for deciding upon some remarkable things millions of individuals are really desirous to be informed on. My very own sincere regret for not expressing gratitude to sooner.

    回复 2019年10月28日
  13. christian louboutin shoes

    I enjoy you because of your whole hard work on this blog. Betty take interest in working on research and it’s simple to grasp why. Most people notice all of the compelling form you give reliable guidelines through this web site and as well welcome contribution from other people on the area of interest while our simple princess is undoubtedly being taught a great deal. Enjoy the rest of the new year. You are always carrying out a first class job.

    回复 2019年10月27日
  14. bape hoodie

    I just wanted to post a quick note so as to thank you for some of the unique guidelines you are giving on this site. My time intensive internet look up has at the end of the day been honored with wonderful suggestions to go over with my family and friends. I ‘d point out that we readers are very fortunate to be in a perfect site with so many wonderful professionals with very beneficial techniques. I feel very much lucky to have used your entire web pages and look forward to many more fabulous minutes reading here. Thank you once again for a lot of things.

    回复 2019年10月27日
  15. nike lebron 15

    I must express my thanks to this writer for rescuing me from this setting. As a result of surfing throughout the world wide web and obtaining notions that were not powerful, I figured my entire life was done. Existing without the answers to the difficulties you’ve solved as a result of this article content is a crucial case, as well as the ones which might have in a wrong way affected my entire career if I hadn’t noticed your site. Your own skills and kindness in dealing with every item was excellent. I don’t know what I would’ve done if I had not come across such a thing like this. I can at this point look forward to my future. Thanks for your time so much for your expert and amazing help. I won’t hesitate to refer your web page to anybody who needs and wants guide on this issue.

    回复 2019年10月27日
  16. supreme clothing

    I just wanted to compose a simple message so as to thank you for some of the superb advice you are writing at this site. My particularly long internet research has now been paid with brilliant content to share with my partners. I ‘d express that many of us visitors actually are quite fortunate to exist in a useful website with so many awesome individuals with beneficial opinions. I feel extremely fortunate to have discovered your website page and look forward to tons of more fabulous minutes reading here. Thank you once more for a lot of things.

    回复 2019年10月27日
  17. balenciaga speed trainer

    A lot of thanks for all your valuable hard work on this site. My mom takes pleasure in setting aside time for investigation and it is easy to understand why. All of us learn all about the powerful mode you convey useful information via the web blog and even welcome response from other people on this area of interest so our own girl is in fact discovering so much. Enjoy the rest of the year. You’re the one performing a dazzling job.

    回复 2019年10月26日
  18. golden goose

    I and my friends happened to be examining the nice secrets and techniques on your website and unexpectedly I had an awful suspicion I never expressed respect to the blog owner for those tips. Those young boys are already joyful to read all of them and have in effect extremely been taking advantage of those things. I appreciate you for simply being very considerate and for settling on some magnificent themes most people are really eager to be informed on. My honest apologies for not expressing appreciation to you earlier.

    回复 2019年10月26日
  19. jordan shoes

    I want to show my respect for your generosity giving support to individuals who must have help with in this concern. Your special commitment to passing the message all over became surprisingly beneficial and has frequently enabled professionals much like me to reach their pursuits. Your personal helpful recommendations means much to me and substantially more to my mates. With thanks; from everyone of us.

    回复 2019年10月26日
  20. coach outlet

    Needed to create you that little observation to help give thanks the moment again on the marvelous secrets you’ve documented above. This has been quite generous of you giving freely what many individuals would have marketed as an e-book to get some money for themselves, chiefly since you might well have tried it if you wanted. The pointers likewise acted to be the good way to understand that most people have the identical passion similar to my own to figure out more and more with regard to this matter. I am sure there are some more enjoyable sessions up front for many who scan your blog post.

    回复 2019年10月26日
  21. off white clothing

    I not to mention my pals happened to be examining the good key points located on your web site then immediately came up with a horrible feeling I never thanked the blog owner for those tips. All of the men happened to be as a consequence passionate to read all of them and already have very much been taking advantage of these things. I appreciate you for being very considerate and also for deciding on this sort of great subjects most people are really desperate to know about. My very own honest apologies for not expressing gratitude to you sooner.

    回复 2019年10月25日
  22. golden goose outlet

    I definitely wanted to make a small comment in order to express gratitude to you for the marvelous tips you are writing at this website. My time consuming internet look up has at the end of the day been recognized with awesome know-how to write about with my neighbours. I would say that many of us readers actually are very much lucky to be in a really good network with many awesome people with beneficial opinions. I feel pretty blessed to have encountered your webpage and look forward to really more brilliant moments reading here. Thanks once more for all the details.

    回复 2019年10月25日
  23. cheap nba jerseys

    I have to show some appreciation to the writer just for rescuing me from this particular trouble. Right after scouting through the internet and meeting methods that were not powerful, I assumed my life was gone. Being alive minus the answers to the issues you’ve resolved by means of your good review is a serious case, and the ones that might have badly affected my career if I hadn’t come across the blog. Your own know-how and kindness in playing with the whole lot was very useful. I am not sure what I would’ve done if I hadn’t come across such a point like this. I can also at this point relish my future. Thank you so much for the skilled and effective help. I will not think twice to suggest your web sites to any individual who should receive tips on this topic.

    回复 2019年10月25日
  24. off white hoodie

    My husband and i were so joyful when Peter could finish off his survey through your precious recommendations he was given in your blog. It is now and again perplexing to simply always be handing out helpful hints that many many people might have been selling. Therefore we do know we now have the blog owner to thank because of that. The explanations you have made, the straightforward site menu, the friendships your site make it easier to create – it’s got everything remarkable, and it is leading our son and us do think the subject matter is fun, and that’s incredibly indispensable. Thank you for the whole lot!

    回复 2019年10月25日
  25. curry 6 shoes

    I want to voice my admiration for your kindness giving support to men who absolutely need assistance with the field. Your personal dedication to passing the solution across appeared to be certainly good and has consistently enabled men and women just like me to realize their aims. Your new insightful publication signifies so much a person like me and extremely more to my peers. Thanks a ton; from all of us.

    回复 2019年10月24日
  26. air max 2019

    I as well as my buddies have been examining the great information located on your web blog and then then I got an awful feeling I never expressed respect to the web site owner for those tips. These guys had been as a result warmed to study them and have in effect actually been loving these things. Thank you for getting really helpful and for having these kinds of essential topics most people are really needing to discover. My honest apologies for not saying thanks to you earlier.

    回复 2019年10月24日
  27. jordan shoes

    I have to express my thanks to you for rescuing me from this particular incident. Right after browsing through the world wide web and seeing proposals that were not productive, I believed my entire life was over. Living without the presence of strategies to the issues you have sorted out by means of your main article is a critical case, and those which may have in a negative way damaged my career if I hadn’t discovered your website. Your personal capability and kindness in playing with all the pieces was precious. I don’t know what I would have done if I hadn’t come upon such a solution like this. I am able to at this point relish my future. Thank you very much for your reliable and effective help. I will not be reluctant to suggest your web blog to any individual who desires support on this area.

    回复 2019年10月24日
  28. balenciaga

    I want to express some appreciation to you just for rescuing me from this type of problem. Because of browsing through the search engines and coming across basics that were not pleasant, I was thinking my life was well over. Being alive devoid of the strategies to the issues you have solved through this website is a crucial case, as well as ones which may have in a wrong way affected my career if I hadn’t noticed the blog. Your personal skills and kindness in maneuvering a lot of stuff was crucial. I am not sure what I would have done if I hadn’t come upon such a point like this. I can at this point relish my future. Thanks very much for this skilled and amazing help. I will not be reluctant to endorse your web sites to any individual who should receive guidelines on this issue.

    回复 2019年10月23日
  29. kyrie irving shoes

    I am just writing to make you know of the brilliant experience my friend’s daughter went through going through your site. She mastered many things, which include how it is like to possess a very effective giving heart to get folks clearly gain knowledge of some grueling subject matter. You undoubtedly exceeded people’s desires. Many thanks for producing these practical, healthy, edifying and even unique guidance on that topic to Julie.

    回复 2019年10月23日
  30. nfl jerseys

    I’m commenting to let you know of the awesome encounter our child obtained studying the blog. She noticed several things, which include what it is like to possess an awesome giving nature to get men and women clearly know a variety of specialized subject matter. You actually exceeded people’s expected results. Thanks for supplying the precious, dependable, informative not to mention cool thoughts on this topic to Evelyn.

    回复 2019年10月22日
  31. nike shoes

    I wish to express some thanks to this writer just for rescuing me from this type of matter. After scouting throughout the world-wide-web and finding things that were not helpful, I assumed my life was done. Being alive without the presence of strategies to the difficulties you have resolved all through this site is a serious case, as well as those which might have adversely affected my entire career if I had not discovered your blog. Your main talents and kindness in touching every aspect was tremendous. I am not sure what I would have done if I had not come across such a stuff like this. I’m able to now look forward to my future. Thanks for your time very much for your professional and results-oriented guide. I won’t think twice to propose the website to any individual who would like guidelines on this problem.

    回复 2019年10月21日
  32. golden goose outlet

    I and my buddies were actually checking out the good key points from your web page while suddenly I had a horrible feeling I had not thanked the website owner for those techniques. These young men are already absolutely thrilled to learn all of them and already have pretty much been taking advantage of these things. I appreciate you for simply being quite considerate and then for picking this kind of smart subject matter millions of individuals are really eager to understand about. My very own sincere regret for not saying thanks to sooner.

    回复 2019年10月20日
  33. jordan 13

    A lot of thanks for your own efforts on this site. Betty loves getting into internet research and it’s easy to see why. I know all of the lively way you produce practical tactics on your web blog and therefore foster participation from others about this theme plus our child is certainly starting to learn a great deal. Have fun with the rest of the year. You have been carrying out a tremendous job.

    回复 2019年10月19日
  34. jordan 12

    I enjoy you because of all your efforts on this web site. My aunt delights in conducting internet research and it’s really obvious why. I know all concerning the compelling manner you deliver invaluable tactics through your blog and even strongly encourage participation from other individuals on that subject so our favorite simple princess is certainly starting to learn so much. Take pleasure in the remaining portion of the year. You have been doing a pretty cool job.

    回复 2019年10月18日
  35. jimmy choo shoes

    I and also my guys were actually going through the excellent pointers located on your web blog then the sudden came up with a terrible suspicion I never expressed respect to the site owner for them. These boys had been for this reason stimulated to study them and have now seriously been taking advantage of those things. I appreciate you for getting indeed considerate and then for picking this sort of great subjects millions of individuals are really wanting to know about. Our own honest regret for not saying thanks to sooner.

    回复 2019年10月17日
  36. nike air max 2018

    I wanted to post you one little note to help give many thanks again over the gorgeous advice you have shared on this website. It is wonderfully generous of people like you in giving openly precisely what many individuals would’ve advertised for an e book to make some cash for their own end, chiefly considering the fact that you could have done it in case you desired. The basics as well worked to be the great way to be aware that other people have a similar zeal the same as my personal own to learn very much more with regards to this matter. I’m sure there are a lot more pleasurable situations ahead for many who browse through your website.

    回复 2019年10月16日
  37. yeezy

    I have to get across my affection for your kindness for folks that should have guidance on this important subject matter. Your real commitment to getting the solution all through ended up being amazingly good and have really helped men and women like me to reach their endeavors. Your entire warm and helpful guide denotes a lot to me and much more to my office colleagues. Many thanks; from everyone of us.

    回复 2019年10月15日
  38. off white

    I wanted to send you a tiny note to finally give thanks as before for all the pleasant concepts you have shown on this page. This has been so incredibly generous with you to grant publicly all that a few people would have supplied for an e book to help make some profit for themselves, specifically considering the fact that you might have done it in case you decided. These solutions in addition served to become a good way to fully grasp that the rest have a similar dream just like my own to see many more when it comes to this condition. I’m sure there are many more fun occasions in the future for individuals who discover your website.

    回复 2019年10月14日
  39. fila

    I wanted to send a brief comment in order to appreciate you for the magnificent ways you are writing on this site. My long internet search has now been paid with awesome concept to exchange with my visitors. I would tell you that most of us readers are really blessed to be in a good community with very many perfect professionals with good points. I feel very fortunate to have come across your entire webpage and look forward to so many more entertaining minutes reading here. Thanks a lot once more for a lot of things.

    回复 2019年10月14日
  40. StevDede

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

    回复 2019年10月13日
  41. 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日
  42. 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日
  43. 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日
  44. 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日
  45. 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日
  46. 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日
  47. 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日