composer安装
composer require tecnickcom/tcpdf
示例
php
use TCPDF;
public function info($university='',$performance='',$grade='',$major=''){
//获取到当前域名
$domain = request()->domain();
//实例化
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
// 设置文档信息
$pdf->SetCreator('xxx系統');
$pdf->SetAuthor('001');
$pdf->SetTitle("Welcome to $domain!");
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, PHP');
// 设置页眉和页脚信息
$pdf->SetHeaderData('favicon.ico', 30, $domain, '这是页眉信息',
array(0,64,255), array(0,64,128));
$pdf->setFooterData(array(0,64,0), array(0,64,128));
// 设置页眉和页脚字体
$pdf->setHeaderFont(Array('stsongstdlight', '', '10'));
$pdf->setFooterFont(Array('helvetica', '', '8'));
// 设置默认等宽字体
$pdf->SetDefaultMonospacedFont('courier');
// 设置间距
$pdf->SetMargins(15, 27, 15);
$pdf->SetHeaderMargin(5);
$pdf->SetFooterMargin(10);
// 设置分页
$pdf->SetAutoPageBreak(TRUE, 25);
// set image scale factor
$pdf->setImageScale(1.25);
// set default font subsetting mode
$pdf->setFontSubsetting(true);
//设置字体
$pdf->SetFont('stsongstdlight', '', 14);
$pdf->AddPage();
$str1 ="这是要主题内容";
$pdf->Write(0,$str1,'', 0, 'L', true, 0, false, false, 0);
//输出PDF
$pdf->Output('下载的文件名.pdf', 'D');
}