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

22 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.

Laisser un commentaire

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