php生成PDF最好的类MPDF,php生成pdfmpdf
mpdf的官方下载地址:http://www.mpdf1.com/mpdf/download
下载后里面有实例,可以参照着做一个就知道了.当然官方网站也有实例,网址:http://mpdf1.com/common/mpdf/examples/
官方提供的文档:http://mpdf1.com/manual/
<?php /* *功能:生成用户诊断报告PDF文件 *创建时间:2013-09-12 */ //phpinfo();exit; //引入MPDF类文件 set_time_limit(0); include '/include/MPDF57/mpdf.php'; //实例化mpdf $mpdf=new mPDF('utf-8','A4','','宋体',0,0,20,10); //设置字体,解决中文乱码 $mpdf->useAdobeCJK = true; $mpdf->SetAutoFont(AUTOFONT_ALL); //获取要生成的静态文件 $html=file_get_contents('template.html'); echo $html;exit; //设置PDF页眉内容 $header='<table width="95%" style="margin:0 auto;border-bottom: 1px solid #4F81BD; vertical-align: middle; font-family: serif; font-size: 9pt; color: #000088;"><tr> <td width="10%"></td> <td width="80%" align="center" style="font-size:16px;color:#A0A0A0">页眉</td> <td width="10%" style="text-align: right;"></td> </tr></table>'; //设置PDF页脚内容 $footer='<table width="100%" style=" vertical-align: bottom; font-family: serif; font-size: 9pt; color: #000088;"><tr style="height:30px"></tr><tr> <td width="10%"></td> <td width="80%" align="center" style="font-size:14px;color:#A0A0A0">页脚</td> <td width="10%" style="text-align: left;">页码:{PAGENO}/{nb}</td> </tr></table>'; //添加页眉和页脚到pdf中 $mpdf->SetHTMLHeader($header); $mpdf->SetHTMLFooter($footer); //设置pdf显示方式 $mpdf->SetDisplayMode('fullpage'); //设置pdf的尺寸为270mm*397mm //$mpdf->WriteHTML('<pagebreak sheet-size="270mm 397mm" />'); //创建pdf文件 $mpdf->WriteHTML($html); //删除pdf第一页(由于设置pdf尺寸导致多出了一页) //$mpdf->DeletePages(1,1); //输出pdf $mpdf->Output(); exit; ?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.