Php method for generating PDF files

Source: Internet
Author: User
Tags php pdf
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 ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.