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’);

69 comments
  1. off white outlet

    I want to convey my passion for your kind-heartedness in support of those people that absolutely need help with this one situation. Your real commitment to passing the solution throughout ended up being rather interesting and has always allowed workers just like me to reach their objectives. Your own interesting suggestions can mean so much to me and much more to my peers. Best wishes; from all of us.

  2. kobe sneakers

    Thank you for all your valuable work on this site. Gloria take interest in making time for internet research and it’s simple to grasp why. I learn all regarding the dynamic medium you render very important techniques by means of your website and as well welcome contribution from people on this area of interest and our favorite simple princess has always been discovering so much. Have fun with the rest of the year. You’re performing a powerful job.

  3. kyrie shoes

    I wanted to post you a bit of observation to be able to thank you so much again over the magnificent tips you’ve discussed on this page. It’s simply generous of you to supply easily exactly what many of us could have advertised as an e-book in order to make some money on their own, even more so considering that you might have tried it if you wanted. These tactics also acted to become good way to fully grasp that some people have similar interest just like my very own to understand more with reference to this matter. I believe there are lots of more enjoyable instances up front for individuals that read carefully your blog.

  4. bape outlet

    I simply desired to say thanks yet again. I am not sure what I would have worked on without these recommendations contributed by you relating to my subject. It was a real fearsome problem in my circumstances, but encountering a new professional approach you resolved that took me to weep with gladness. Now i’m happy for the advice and as well , have high hopes you are aware of a great job that you are doing teaching most people by way of your website. More than likely you haven’t got to know all of us.

  5. supreme shirt

    I have to get across my respect for your kind-heartedness giving support to individuals that require help on this important issue. Your very own commitment to passing the solution all around had become unbelievably good and have without exception made employees like me to achieve their targets. Your helpful suggestions entails a great deal to me and still more to my fellow workers. Warm regards; from each one of us.

  6. off white

    I needed to draft you this very little remark to say thanks yet again regarding the striking suggestions you’ve shown above. This has been certainly tremendously open-handed with you to supply openly what exactly a few individuals might have offered as an e-book to get some bucks for themselves, and in particular considering the fact that you might well have tried it in case you decided. These pointers as well acted to become a easy way to know that other people have similar desire just like my very own to know the truth way more with respect to this matter. I’m sure there are many more pleasant moments in the future for individuals who look over your blog.

  7. bapesta

    I want to show my gratitude for your generosity supporting those individuals that must have help on that area of interest. Your very own commitment to passing the solution all over came to be astonishingly useful and has made associates much like me to achieve their aims. Your personal useful tips and hints entails a whole lot a person like me and substantially more to my mates. Thank you; from each one of us.

  8. fear of god t shirt

    I want to point out my appreciation for your kind-heartedness giving support to all those that actually need assistance with that area. Your real commitment to getting the solution all over appears to be extremely informative and has in every case enabled employees just like me to attain their dreams. Your personal warm and friendly facts denotes a whole lot to me and much more to my mates. With thanks; from each one of us.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.