Loading...
Développement-code

Convertir du HTML en PDF via PHP

Pour convertir du HTML en fichier PDF, voici une solution en PHP :

Cette solution utilise le projet  HTML2PDF  (sourceforge.net/projects/html2fpdf/).  Trés simplement le texte HTML est généré en fichier PDF. Ce projet est basé sur le script FPDF  (www.fpdf.org),  qui est en pur PHP, sans utiliser  PDFlib ou tout autre librairie. Télécharger HTML2PDF, ajouter le à vos projets et voici un script d’exemple de code.

Code exemple

require(« html2fpdf.php »);

$htmlFile = « http://www.mirpod.com »;

$buffer = file_get_contents($htmlFile);

$pdf = new HTML2FPDF(‘P’, ‘mm’, ‘Letter’);

$pdf->AddPage();

$pdf->WriteHTML($buffer);

$pdf->Output(‘test.pdf’, ‘F’);

42 comments
  1. curry 7 shoes

    I would like to voice my gratitude for your kind-heartedness in support of those people who really need help on the concept. Your personal dedication to getting the message across ended up being pretty beneficial and has consistently encouraged those like me to achieve their aims. Your personal warm and helpful tutorial means this much to me and even further to my office workers. Thanks a lot; from all of us.

  2. curry 7 sour patch

    I simply wanted to thank you so much again. I do not know what I could possibly have taken care of in the absence of those solutions shared by you over this situation. Completely was a real difficult problem in my position, however , looking at the well-written approach you resolved it forced me to weep over gladness. I am just happier for this help and thus believe you recognize what a powerful job you have been providing training some other people via your site. Probably you’ve never come across any of us.

  3. kd shoes

    My husband and i felt really cheerful that Chris could deal with his investigations because of the ideas he had when using the web pages. It is now and again perplexing just to be giving freely techniques which the rest may have been trying to sell. So we consider we’ve got you to give thanks to for this. The type of illustrations you have made, the easy blog navigation, the relationships you will aid to promote – it’s got most exceptional, and it’s leading our son and the family feel that the topic is brilliant, which is extremely indispensable. Thank you for all the pieces!

  4. curry shoes

    I needed to send you one bit of observation so as to say thank you over again regarding the pleasing methods you’ve documented in this article. This is tremendously generous of people like you to give openly what some people could possibly have distributed as an electronic book to generate some dough for their own end, and in particular considering the fact that you might well have tried it in the event you decided. These basics in addition served to become great way to understand that some people have the same passion the same as mine to know a great deal more concerning this condition. I think there are many more fun opportunities up front for people who find out your website.

  5. curry shoes

    I and my friends were reviewing the nice guidelines found on your site while immediately developed a horrible suspicion I never expressed respect to you for those strategies. These young men were definitely warmed to learn all of them and have certainly been taking advantage of them. Appreciate your really being considerably helpful and then for going for this kind of great resources millions of individuals are really eager to discover. My very own sincere regret for not saying thanks to you sooner.

  6. kyrie spongebob

    I must convey my admiration for your kindness supporting people that need assistance with this important matter. Your special commitment to passing the message around appeared to be extremely interesting and have all the time enabled others much like me to arrive at their endeavors. Your personal useful suggestions denotes so much to me and much more to my mates. Best wishes; from all of us.

  7. off white clothing

    I am glad for commenting to make you understand of the beneficial discovery my cousin’s daughter obtained browsing the blog. She learned some pieces, which include what it is like to have an awesome teaching nature to make other individuals completely master chosen tricky subject matter. You undoubtedly exceeded people’s desires. Thanks for imparting such priceless, healthy, educational and in addition unique tips on your topic to Jane.

  8. kyrie irving

    Needed to compose you a tiny word just to thank you so much again considering the fantastic techniques you have contributed at this time. It’s really surprisingly open-handed with you in giving easily what exactly a few people would have offered as an electronic book to make some dough on their own, most notably given that you could have done it if you wanted. Those tactics also served like the fantastic way to fully grasp that other people online have a similar passion similar to my own to find out way more with regards to this problem. I think there are thousands of more enjoyable sessions up front for many who view your blog.

  9. off white

    I precisely had to thank you very much once more. I do not know what I would have sorted out without the entire tricks shared by you regarding such area. It has been the traumatic case in my circumstances, nevertheless observing a expert approach you processed that took me to cry for gladness. I will be happier for your support as well as hope that you recognize what an amazing job you have been undertaking teaching some other people through the use of your site. I am certain you haven’t encountered any of us.

  10. supreme clothing

    I wanted to write you one bit of observation in order to say thanks yet again for your fantastic advice you’ve documented on this site. It’s wonderfully generous with you to make unhampered all a lot of people would’ve offered as an ebook in making some profit for their own end, mostly considering that you might well have tried it if you decided. These principles as well served to provide a good way to realize that other individuals have the identical passion like mine to find out very much more with regards to this issue. Certainly there are lots of more enjoyable instances ahead for individuals that scan your blog.

  11. yeezy 350

    I would like to voice my admiration for your generosity supporting people who absolutely need help with your niche. Your very own commitment to passing the message all over turned out to be certainly useful and has usually empowered folks like me to achieve their goals. Your amazing valuable hints and tips signifies a whole lot to me and much more to my office colleagues. Best wishes; from all of us.

  12. kyrie 7 shoes

    I want to voice my gratitude for your generosity supporting all those that really need help with the matter. Your real commitment to getting the message all over appears to be extraordinarily insightful and has all the time allowed others just like me to attain their pursuits. Your amazing insightful instruction entails a great deal a person like me and further more to my peers. Warm regards; from everyone of us.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *