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

150 comments
  1. curry 8

    Thank you so much for providing individuals with such a spectacular possiblity to read articles and blog posts from here. It’s always very kind and full of a great time for me and my office peers to visit the blog really thrice in 7 days to learn the new guides you have. And indeed, I’m certainly contented with the dazzling suggestions you give. Selected 3 areas in this post are truly the most beneficial I have ever had.

  2. a bathing ape

    I must express my passion for your kind-heartedness for individuals who really need guidance on this particular niche. Your real dedication to passing the solution along turned out to be especially functional and have enabled employees like me to arrive at their desired goals. The interesting facts can mean so much to me and far more to my peers. Many thanks; from everyone of us.

  3. OFF-White

    I must point out my affection for your kind-heartedness giving support to men who must have guidance on this situation. Your personal dedication to getting the message along appears to be extraordinarily advantageous and has in every case allowed guys much like me to realize their dreams. Your informative report entails a lot a person like me and even more to my office workers. With thanks; from all of us.

Laisser un commentaire

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