http://www.fpdf.org/

https://github.com/Setasign/FPDF

https://www.ntaso.com/fpdf-and-chinese-characters/

<?php
// 1.8.1
//define("FPDF_FONTPATH","font/"); try
{
require("../fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont("Arial","B",16);
$pdf->Cell(40,10,"Hello World! 涂聚文"); //中文乱码
$pdf->Output();
}
catch(Exception $ex)
{
echo($ex->getMessage());
} ?>

  

https://www.phpbook.jp/fpdf/japan/index2.html

解决中文问题:

http://www.fpdf.org/en/script/script92.php

把中文后缀为.tff字体文件放入至:tfpdf\font\unifont 的文夹下即可。参考 http://www.fpdf.org/en/script/script92.php

下载: http://www.fpdf.org/en/script/dl.php?id=92&f=zip

https://dejavu-fonts.github.io/Download.html

<?php

// Optionally define the filesystem path to your system fonts
// otherwise tFPDF will use [path to tFPDF]/font/unifont/ directory
// define("_SYSTEM_TTFONTS", "C:/Windows/Fonts/"); tFPDF
//http://www.fpdf.org/en/script/script92.php require('tfpdf/tfpdf.php'); $pdf = new tFPDF();
$pdf->AddPage(); // Add a Unicode font (uses UTF-8)
//tfpdf\font\unifont 把中文的字体文件放入其内则可。
$pdf->AddFont('DejaVu','','3pdwg6wqe1jpcgh.ttf',true); //msyh.ttf 设置字体即可,字体名称不可以定义为中文 简体篆体 :3pdwg6wqe1jpcgh.ttf
$pdf->SetFont('DejaVu','',14); // Load a UTF-8 string from a file and print it
// 在操作系统下可以选择的字体可以显示,则也可以生成
$txt ="English: Hello World
Greek: Γειά σου κόσμος
Polish: Witaj świecie
Portuguese: Olá mundo
Russian: Здравствулте мир
Vietnamese: Xin chào thế giới,中国智造0123456789 涂聚文geovindu 生命的意义,涂聚文,中华人民共和国";// file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt); // Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 13 KB.'); $pdf->Output();
?>

  

<?php

// Optionally define the filesystem path to your system fonts
// otherwise tFPDF will use [path to tFPDF]/font/unifont/ directory
// define("_SYSTEM_TTFONTS", "C:/Windows/Fonts/"); tFPDF
//http://www.fpdf.org/en/script/script92.php require('tfpdf/tfpdf.php'); $pdf = new tFPDF();
$pdf->AddPage(); // Add a Unicode font (uses UTF-8)
//tfpdf\font\unifont 把中文的字体文件放入其内则可。
$pdf->AddFont('DejaVu','','3pdwg6wqe1jpcgh.ttf',true); //msyh.ttf 设置字体即可,字体名称不可以定义为中文 简体篆体 :3pdwg6wqe1jpcgh.ttf
$pdf->SetFont('DejaVu','',14); // Load a UTF-8 string from a file and print it
// 在操作系统下可以选择的字体可以显示,则也可以生成
$txt ="English: Hello World
Greek: Γειά σου κόσμος
Polish: Witaj świecie
Portuguese: Olá mundo
Russian: Здравствулте мир
Vietnamese: Xin chào thế giới,中国智造0123456789 涂聚文geovindu 生命的意义,涂聚文,中华人民共和国";// file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt);
$pdf->Ln(16);
$sheader=array("姓名","年龄","性别","工资","学历");
$data=array();
$data[0]=array("geovindu","1","男","100","");
$data[1]=array("sibodu","2","男","200","");
$data[2]=array("涂聚文","3","女","300","");
$data[3]=array("小涂","4","女","400","");
$data[4]=array("阿文","5","男","500","");
$data[5]=array("小文","6","女","600","");
$width=array(40,40,40,40); //设置每列宽度
for($i=0;$i<count($sheader);$i++)
{
$pdf->Cell($width[$i],6,$sheader[$i],1);
}
$pdf->Ln(6);
foreach($data as $row)
{
$pdf->Cell($width[0],6,$row[0],1);
$pdf->Cell($width[1],6,$row[1],1);
$pdf->Cell($width[2],6,$row[2],1);
$pdf->Cell($width[3],6,$row[3],1);
$pdf->Cell($width[4],6,$row[4],1);
$pdf->Cell($width[5],6,$row[5],1);
$pdf->Ln(6);
}
// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 13 KB.'); $pdf->Output();
?>

  

<?php

// Optionally define the filesystem path to your system fonts
// otherwise tFPDF will use [path to tFPDF]/font/unifont/ directory
// define("_SYSTEM_TTFONTS", "C:/Windows/Fonts/"); require('tfpdf\tfpdf.php'); $pdf = new tFPDF();
$pdf->AddPage(); // Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',14); // Load a UTF-8 string from a file and print it
$txt = file_get_contents('./tfpdf/HelloWorld.txt', FALSE, NULL, 20, 1400); //
$pdf->Write(8,$txt); // Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 13 KB.'); $pdf->Output();
?>

  

PHP7.27: pdf的更多相关文章

  1. PHP7.27: object

    http://www.devshed.com/c/a/PHP/PHP-Services-Layers-Data-Mappers/ https://stackoverflow.com/questions ...

  2. PHP7.27: connect mysql 5.7 using new mysqli_connect

    <!doctype html> <html> <head> <meta name="viewport" content="wid ...

  3. PHP7.27: connect mysql 5.7 using new mysqli

    <!doctype html> <html> <head> <meta name="viewport" content="wid ...

  4. JavaScript高级程序设计27.pdf

    第11章 DOM扩展 W3C将一些已经成为事实标准的专有扩展标准化并写入规范当中.对DOM的两个主要扩展是SelectorsAPI(选择符API)和HTML5 选择符API 就是根据CSS选择符选择与 ...

  5. PHP7.27: Cookie and Session

    <?php // 有的浏览器不支持Cookie,这要考虑的 $cFile="count.txt"; $acctime=time(); if(file_exists($cFil ...

  6. PHP7.27: MySqlhelper class

    https://github.com/ThingEngineer/PHP-MySQLi-Database-Class https://github.com/wildantea/php-pdo-mysq ...

  7. php7.27: export excel from mysql

    https://stackoverflow.com/questions/15699301/export-mysql-data-to-excel-in-php https://github.com/PH ...

  8. CentOS7+ApacheServer2.4+MariaDB10.0+PHP7.0+禅道项目管理软件8.0环境部署

    CentOS7+ApacheServer2.4+MariaDB10.0+PHP7.0+禅道项目管理软件8.0环境部署 by:授客 QQ:1033553122 目录 一. 二. 三. 四. 五. 六. ...

  9. .NET平台开源项目速览(16)C#写PDF文件类库PDF File Writer介绍

    1年前,我在文章:这些.NET开源项目你知道吗?.NET平台开源文档与报表处理组件集合(三)中(第9个项目),给大家推荐了一个开源免费的PDF读写组件 PDFSharp,PDFSharp我2年前就看过 ...

随机推荐

  1. Java核心技术卷一基础知识-第6章-接口与内部类-读书笔记

    第6章 接口与内部类 本章内容: * 接口 * 对象克隆 * 接口与回调 * 内部类 * 代理 接口技术主要用来描述类具有什么功能,而并不给出每个功能的具体实现.一个类可以实现(implement)一 ...

  2. system libzip must be upgraded to version >= 0.11

    PHP当前最新版本是PHP7.3,今天在尝试安装的过程中报如下错误: system libzip must be upgraded to version >= 0.11, 根据提示我们可以清楚的 ...

  3. java中根据key获取resource下properties资源文件中对应的参数

    properties资源文件是放在resource目录下的: 新建工具类: package com.demo.utils; import java.io.InputStream; import jav ...

  4. 爬虫不过如此(python的Re 、Requests、BeautifulSoup 详细篇)

    网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本. 爬虫的本质就是一段自动抓取互联网信息的程序,从网络获取 ...

  5. linux性能优化参数小节

    总结一些和性能相关的常见参数 内核相关参数 位于/etc/sysctl.conf文件,向文件中添加 用sysctl -a可以查看默认配置 修改后可以通过sysctl -p执行并看看有没有错误 例如设置 ...

  6. Github page搭建博客使用自定义插件的方法

    Github page的后台程序是由Jekyll搭建,但由于Github的保护措施,非认证的plugin一般不会被Github page支持,但可以使用一些小技巧来绕过屏蔽. 以个人page为例,个人 ...

  7. 使用Docker发布DNC项目

    项目结构 可以忽略中间三个Console项目 ApiCenter 是一个WebAPI项目,引用了NLog.MQ项目 ApiCenter使用5001端口 public static IWebHost B ...

  8. bash 的配置文件加载顺序

    bash配置文件的加载顺序和登陆方式有关,下面先介绍下登陆方式. 1 登陆方式有2种 登陆式SHELL: su - oracle    su -l oracle 正常从终端登陆 非登录式SHELL: ...

  9. 解决Linux下Jexus验证码无法显示

    1:安装mono相关字体 yum install -y dejavu-fonts-common dejavu-lgc-sans-mono-fonts 2:重启jexus /usr/jexus/jws ...

  10. 1.Magicodes.NET框架之路——起航

    1.Magicodes.NET框架之路--起航 前言 从事开发也好几年了,并且最近一直在做架构搭建的工作.这些时间,最大的感悟就是: 只有自己理解了的才是自己的. 对架构这块,若欲立之,必先破之. 故 ...