This article mainly introduces PHP to generate PDF file method, interested in the friend's reference, I hope to be helpful to everyone.
The code is as follows:
The first step must be to introduce Tcpdf's entry file require_once '/var/www/tcpdf/tcpdf.php ';//Instantiate $pdf = new Tcpdf (' P ', ' mm ', ' A4 ', true, ' UTF-8 ', false );//Set Document Information $pdf->setcreator (' Lane '); $pdf->setauthor (' Lane '); $pdf->settitle (' PHP generated pdf '); $pdf Setsubject (' PHP dynamically generated PDF file '); $pdf->setkeywords (' php pdf TCPDF ');//Set Header information parameters are logo address, logo size, two lines of title, title color, split line color. The color is rgb$pdf->setheaderdata ('/var/www/tcpdf/examples/images/tcpdf_logo.jpg ', ' php generate PDF ', ' php how to generate PDF file ', Array (0,0,0), Array (0,0,0)),//Set footer information $pdf->setfooterdata (Array (0,0,0), Array (0,0,0)),//Set header and footer font $pdf-> Setheaderfont (Array (' stsongstdlight ', ' ', ' ') '), $pdf->setfooterfont (Array (' Helvetica ', ', ' 8 '));//Set default equal-width font $ Pdf->setdefaultmonospacedfont (' Courier ');//Set Spacing $pdf->setmargins (5); $pdf->setheadermargin Pdf->setfootermargin (10);//Set Paging $pdf->setautopagebreak (TRUE, 15);//Set Picture scale $pdf->setimagescale (1.25);// Output the header footer information. $pdf->addpage ();//Set the font-the body title of the Oh. B is bold, 15 is the size of $pdf->setfont (' Stsongstdlight ', ' B ', n); $pdf->write(C, ' How does PHP dynamically generate PDF ', ' ', 0, ' C. ', true, 0, False, False, 0);//Set the font-the body content of the OH. B is bold, 15 is size $pdf->setfont (' stsongstdlight ', ', '),//l is left-aligned, R is right-aligned, and C is center-aligned. $pdf->write (0, $content, ', 0, ' L ', True, 0, False, False, 0);//output PDF. The second parameter defaults to I, which is the browser preview. D is to download $pdf->output (' php_to_pdf.pdf ', ' I ');