ThinkPHP3.2.3 expanded PDF file (MPDF)

Source: Internet
Author: User

PHP is now the best plugin to generate PDF files, today introduced in the ThinkPHP3.2.3 how to use.

First, the path is set.

Here's how to use

  1. Public function PDF() {
  2. //Introduction of Class library
  3. Vendor(' mpdf.mpdf ');
  4. //Set Chinese encoding
  5. $mpdf=new \mpdf(' ZH-CN ',' A4 ', 0, ' Arial ', 0 , 0);
  6. //html Content
  7. $html=' ;
  8. $mpdf-writehtml($html);
  9. $mpdf, Output();
  10. exit;
  11. }
Copy

Enter in the browser

    1. XXX/index. PHP? s=/home/Index/PDF //Replace with your URL path
Copy

The effect is as follows

Here are some advanced ways to use it:

  1. Public function PDF() {
  2. //Introduction of Class library
  3. Vendor(' mpdf.mpdf ');
  4. //Set Chinese encoding
  5. $mpdf=new \mpdf(' ZH-CN ',' A4 ', 0, ' Arial ', 0 , 0);
  6. $mpdf-setwatermarktext(' China watermark ',0.1);
  7. $strContent = ' I am a PDF file with watermarks ';
  8. $mpdf-showwatermarktext = true;
  9. $mpdf-Sethtmlheader( ' head ' );
  10. $mpdf-sethtmlfooter( ' bottom ' );
  11. //$stylesheet =file_get_contents (' themes/wei/css/bootstrap.min.css ');
  12. //$mpdf->writehtml ($stylesheet, 1);
  13. $mpdf-writehtml($strContent);
  14. //Save Ss.pdf file
  15. $mpdf, Output(' ss.pdf ');
  16. //Direct browser output PDF
  17. $mpdf, Output(' tmp.pdf ',true);
  18. $mpdf, Output(' tmp.pdf ',' d ');
  19. $mpdf, Output();
  20. exit;
  21. }
Copy

Mpdf download can be downloaded to the official website http://www.mpdf1.com or in the following Baidu cloud download

ThinkPHP3.2.3 expanded PDF file (MPDF)

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.