PHP code example of hanhan / fpdf
1. Go to this page and download the library: Download hanhan/fpdf library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hanhan / fpdf example snippets
use hanhan\fpdi\Fpdi;
define('FPDF_FONTPATH', '/font/'); # 字体路径,这里主要是针对中文字体
$pdf = new Fpdi();
$pdf->AddGBFont('simhei', '黑体');
$pdf->AddPage();
$pdf->SetFont('simhei', '', 16);
$pdf->Cell(80, 20, iconv("utf-8", "gbk", "测试中文")); # 注意这里的转码
$pdf->Output('example.pdf', 'F');