专心求教,如何创建能显示中文/unicode的PDF文件

caaclxf 2006-01-18 01:01:04
如题...
希望能得到各路英雄的答案,谢谢!
...全文
189 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
caaclxf 2006-07-06
  • 打赏
  • 举报
回复
问题已经解决:
通过GD把UNICODE转成图片,再用FPDF放到PDF内。
以下是相应的方法
/**
* 创建图片
*
* @param Unicode编码的文字 $utf_text
* @param 带完整路径的字体文件 $font
* @param Int $fontSize 字体尺寸
*/
function _createImage($utf_text,$font,$fontsize)
{
$fontsize = $fontsize*FONTPNG_MAGNIFY;
//尺寸為12字每行顯示36個字,當尺寸增大1字數減少1
$iLineSize = 36-($fontsize-12);
$aTextArr = explode(';', $utf_text);
$utf_text = '';
for ($i=0; $i<count($aTextArr)-1; $i++)
{
$utf_text .= ($i%$iLineSize==0 && $i!=0) ? $aTextArr[$i].";\n" : $aTextArr[$i].";";
}
$size = imagettfbbox($fontsize, 0, $font, $utf_text);
$width = $size[2] + $size[0] + 8 ;
$height = abs($size[1]) + abs($size[7]);
$im = imagecreate($width, $height);
$colourBlack = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im, $colourBlack);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// Add the text
imagefttext($im, $fontsize, 0, 0, abs($size[5]), $black, $font, $utf_text);
return $im;
}
gu1dai 2006-01-18
  • 打赏
  • 举报
回复
个人意见,找个支持unicode生成的pdf类。
gu1dai 2006-01-18
  • 打赏
  • 举报
回复
没弄过,友情up.
pswdf 2006-01-18
  • 打赏
  • 举报
回复
创建chm可以么?
caaclxf 2006-01-18
  • 打赏
  • 举报
回复
自己顶一下
caaclxf 2006-01-18
  • 打赏
  • 举报
回复
此问题困忧已久,希望能得到帮忙

21,890

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧