Home  >  Article  >  Backend Development  >  What to do if php fpdf Chinese garbled characters

What to do if php fpdf Chinese garbled characters

藏色散人
藏色散人Original
2020-08-17 10:08:163889browse

php Solution to fpdf Chinese garbled characters: first download fpdf; then download the Chinese package, and put the file in the folder at the same level as "fpdf.php"; finally edit the content of "ex.php" Just "$pdf=new PDF_Chinese();".

What to do if php fpdf Chinese garbled characters

Recommended: "PHP Video Tutorial"

php uses fpdf garbled problem

Step 1. First download fpdf http://www.fpdf.org/en/download.php (I am using version 1.7)

Step 2. Download the Chinese package http://www .fpdf.org/download/chinese.zip After downloading, place the file in the folder of step 1 under the same directory as fpdf.php

Step 3. Edit the ex.php content as follows

<?php
require(&#39;chinese.php&#39;);
 
$pdf=new PDF_Chinese();
$pdf->AddGBFont(&#39;simsun&#39;,&#39;宋体&#39;);
$pdf->AddGBFont(&#39;simhei&#39;,&#39;黑体&#39;);
$pdf->AddGBFont(&#39;simkai&#39;,&#39;楷体_GB2312&#39;);
$pdf->AddGBFont(&#39;sinfang&#39;,&#39;仿宋_GB2312&#39;);
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont(&#39;simsun&#39;,&#39;&#39;,20);
$pdf->Write(10,&#39;简体中文汉字&#39;);
$pdf->SetFont(&#39;simhei&#39;,&#39;&#39;,20);
$pdf->Write(10,&#39;简体中文汉字&#39;);
$pdf->SetFont(&#39;simkai&#39;,&#39;&#39;,20);
$pdf->Write(10,&#39;简体中文汉字&#39;);
$pdf->Write(10,&#39;简体中文汉字&#39;);
$pdf->Output();
?>

You can see Chinese by previewing directly.

The above is the detailed content of What to do if php fpdf Chinese garbled characters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn