PHP7.27: pdf
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的更多相关文章
- PHP7.27: object
http://www.devshed.com/c/a/PHP/PHP-Services-Layers-Data-Mappers/ https://stackoverflow.com/questions ...
- PHP7.27: connect mysql 5.7 using new mysqli_connect
<!doctype html> <html> <head> <meta name="viewport" content="wid ...
- PHP7.27: connect mysql 5.7 using new mysqli
<!doctype html> <html> <head> <meta name="viewport" content="wid ...
- JavaScript高级程序设计27.pdf
第11章 DOM扩展 W3C将一些已经成为事实标准的专有扩展标准化并写入规范当中.对DOM的两个主要扩展是SelectorsAPI(选择符API)和HTML5 选择符API 就是根据CSS选择符选择与 ...
- PHP7.27: Cookie and Session
<?php // 有的浏览器不支持Cookie,这要考虑的 $cFile="count.txt"; $acctime=time(); if(file_exists($cFil ...
- PHP7.27: MySqlhelper class
https://github.com/ThingEngineer/PHP-MySQLi-Database-Class https://github.com/wildantea/php-pdo-mysq ...
- php7.27: export excel from mysql
https://stackoverflow.com/questions/15699301/export-mysql-data-to-excel-in-php https://github.com/PH ...
- CentOS7+ApacheServer2.4+MariaDB10.0+PHP7.0+禅道项目管理软件8.0环境部署
CentOS7+ApacheServer2.4+MariaDB10.0+PHP7.0+禅道项目管理软件8.0环境部署 by:授客 QQ:1033553122 目录 一. 二. 三. 四. 五. 六. ...
- .NET平台开源项目速览(16)C#写PDF文件类库PDF File Writer介绍
1年前,我在文章:这些.NET开源项目你知道吗?.NET平台开源文档与报表处理组件集合(三)中(第9个项目),给大家推荐了一个开源免费的PDF读写组件 PDFSharp,PDFSharp我2年前就看过 ...
随机推荐
- 3.CursorAdapter
会话页面 点击菜单时编辑的按钮显示,其余的时候gone ConversationUI public class ConversationUI extends Activity implements ...
- rem计算
//jquery实现 // $(function(){ // $(window).on("resize",function(){ // var width=$(window).wi ...
- 浅谈static关键字的四种用法
1.修饰成员变量 在一个person类中,一个成员变量例如 String name,当new2个person()对象时候,这2个对象在堆的位置是不同的,给name赋值张三.李四,这两个对象的name是 ...
- db2 报错 sqlcode=-420 自动类型转换的问题
今天在测试遇到一个问题,前台点击页面查询数据时报错: , SQLSTATE, SQLERRMC=DECFLOAT, DRIVER=4.18.60 根据sqlcode查询错误原因为:-420 22018 ...
- C++11实现一个轻量级的AOP框架
AOP介绍 AOP(Aspect-Oriented Programming,面向方面编程),可以解决面向对象编程中的一些问题,是OOP的一种有益补充.面向对象编程中的继承是一种从上而下的关系,不适合定 ...
- 解决app安装成功后,直接点击“打开”再按home返回,再次打开app会重新启动的问题
在主activity的onCreate中加入以下代码 @Override protected void onCreate(Bundle savedInstanceState) { super.onCr ...
- Java代码更改shape和selector文件的颜色值
Android里面经常会使用shape或者selector来定制一些View的背景.那么如果想要动态更改shape或者seletor文件中的颜色值,该怎么处理呢? 一.Java代码更改shape的颜色 ...
- Core2.0知识整理
概述 Commond-Line ASP.NET结构文件 Startup 配置文件 中间件和依赖注入 依赖注入原理 框架自带的依赖注入(IServiceCollection) 依赖注入生命周期 依赖注入 ...
- 【转载】LINUX 和 WINDOWS 内核的区别
LINUX 和 WINDOWS 内核的区别 [声明:欢迎转载,转载请注明出自CU ACCESSORY http://linux.chinaunix.net/bbs/thread-1153868-1-1 ...
- [CF960G] Bandit Blues
题意 给你三个正整数 \(n,a,b\),定义 \(A\) 为一个排列中是前缀最大值的数的个数,定义 \(B\) 为一个排列中是后缀最大值的数的个数,求长度为 \(n\) 的排列中满足 \(A = a ...