新建demo.php
require_once("tcpdf/tcpdf.php");
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', true);
//设置PDF页面边距 LEFT, TOP, RIGHT
//$pdf->SetMargins(20, 20, 20);
//设置文件信息
$pdf->SetCreator(TITLE_NAME);
$pdf->SetAuthor(TITLE_NAME);
$pdf->SetTitle("这是标题");
//删除预定义的打印 页眉/页尾
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//设置默认等宽字体
$pdf->SetDefaultMonospacedFont('courier');
//设置默认字体构造子集模式,设置false将把字体嵌入到pdf中(文件会变大)
$pdf->setFontSubsetting(false);
//设置字体,字体在fonts目录中。
//有时设置字体后会发现html中不能设粗体或斜体,这和字体本身有关
//解决方法再生成粗体和斜体字体,命名为**b、**i(例如fzssjwb、fzssjwi)
//这时在css中使用、等标签就会自动加粗
//$pdf->SetFont('freemonob');
$pdf->SetFont('msungstdlight','',16);
//设置自动换页
$pdf->SetAutoPageBreak(true, 20);
$html = file_get_contents("demo.html");
//添加一个页面
$pdf->AddPage();
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->lastPage();
$pdf->Output("test001.pdf", "I");
?>
同级目录下新建demo.html
body{
width: 200mm;
height: 240mm;
margin: 15mm auto;
padding: 0;
font-size: 10.5pt;
border: black 1px solid;
}
.container {
height: 180mm;
width: 155mm;
margin: 100px auto;
}
table{
letter-spacing: 2px;
line-height: 30px;
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.content {
margin-top: 40px;
}
.between {
margin-left: 30px;
margin-top: 20px;
}
.between input{
width: 300px;
margin: 3mm 0;
}
.foot {
margin-top: 100px;
}
.foot table {
letter-spacing: 3.5px;
}
.qz {
margin-top: 30px;
}
.qz table {
line-height: 40px;
}
.table {
float: right;
}
.foot span {
text-decoration: black solid ;
border-bottom: 1px black solid;
}
h1{
text-align:center;
}
授权委托书
| 现本人不可撤销的向 ******* 银行 |
| 授权: |
| 本人因办理 *********** 业务,已经 |
| 向 0000000 公司支付首付款,现委托贵 |
| 行将本人的信用卡(卡号 234234234342) |
| 进行启用,并将其余款项 **** 元, |
| 以透支形式扣收后支付给该公司,入账账户信息如下: |
| 账户名称: | ||||
| 账 号: | ||||
| 开户行: | ********** | |||
| 本人在签署此授权委托书之前,已认真仔细阅读上述内容,清 |
| 楚知晓并自愿承担由此引发的相关法律责任。 |
| 授权人: | ||||||||
| 2019年04月01日 | ||||||||
运行demo.php 如果提示字体错误,未找到字体,去官网下载完整版fonts



