个人意见,找个支持unicode生成的pdf类。

解决方案 »

  1.   

    问题已经解决:
    通过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;
    }