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 中的锁机制

    多个进程或线程同时(或着说在同一段时间内)访问同一资源会产生并发(线程安全)问题.解决并发问题可以用锁. java的内置锁: 每个java对象都可以用做一个实现同步的锁,这些锁称为内置锁.线程进入同步 ...

  2. Redis之分布式锁

    目录 一.加锁原因 二.原子操作 三.分布式锁 四.分布式锁常见问题 一.加锁原因 在一些比较高并发的业务场景,经常听到通过加锁的方法实现线程安全. 下面简单介绍一下 1.1 加锁方式 数据库锁 数据 ...

  3. Python 音视频方面资源大全

    自然语言处理 用来处理人类语言的库. NLTK:一个先进的平台,用以构建处理人类语言数据的 Python 程序.官网 jieba:中文分词工具.官网 langid.py:独立的语言识别系统.官网 Pa ...

  4. Python - 使用Pylint检查分析代码

    1-简介 Home Page : https://www.pylint.org/ 检查语法错误,是否遵守编码风格标准.潜在的问题等: 支持自定义配置:例如显示或隐藏特定的警告,并且可以通过编写插件来添 ...

  5. 【app】自动化必备之adb使用

    1.1 Adb介绍 adb(android debug bridge)是android sdk自带的一个工具 Adb是用来连接android设备和PC端的桥梁,通过adb工具,用户可以在PC端对手机进 ...

  6. VueJs(11)---vue-router(命名路由,命名视图,重定向别名,路由组件传参)

    vue-router 上篇文章讲了第一篇vue-router相关文章,文章地址:VueJs(10)---vue-router(进阶1) 一.命名路由 有时候,通过一个名称来标识一个路由显得更方便一些, ...

  7. Redis主从+KeepAlived实现高可用

    Redis是我们当下比较流行使用的非关系数据库,可支持多样化的数据类型,多线程高并发支持,redis运行在内存拥有更快的读写.因为redis的表现如此出色,如何能保障redis在运行中能够应对宕机故障 ...

  8. HashMap在JDK1.7中可能出现的并发问题

    在JDK1.7及以前中,如果在并发环境中使用HashMap保存数据,有可能会产生死循环的问题,造成cpu的使用率飙升.之所以会发生该问题,实际上就是因为HashMap中的扩容问题. HashMap的实 ...

  9. 微信小程序使用wxParse解析html

    最近项目上遇到在微信小程序里需要显示新闻内容,新闻内容是通过接口读取的服务器中的富文本内容,是html格式的,小程序默认是不支持html格式的内容显示的,那我们需要显示html内容的时候,就可以通过w ...

  10. 翻译:select into outfile(已提交到MariaDB官方手册)

    本文为mariadb官方手册:SELECT INTO OUTFILE的译文. 原文:https://mariadb.com/kb/en/select-into-outfile/ 我提交到MariaDB ...