https://blog.csdn.net/beyond__devil/art ... s/62230610
安裝 mpdf 用他的字形
composer require mpdf/mpdf
https://laravel-china.org/topics/13642/ ... -solutions
uft8 轉 unicode
代碼: 選擇全部
function to_unicode($string)
{
$str = mb_convert_encoding($string, 'UCS-2', 'UTF-8');
$arrstr = str_split($str, 2);
$unistr = '';
foreach ($arrstr as $n) {
$dec = hexdec(bin2hex($n));
$unistr .= '&#' . $dec . ';';
}
return $unistr;
}
產生gif圖片
代碼: 選擇全部
$img = Image::canvas(128, 32, '#FFFFFF');
$img->text(self::to_unicode($id), 64, 0, function ($font) {
$font->file(base_path('vendor/mpdf/mpdf/ttfonts/Sun-ExtA.ttf'));
$font->size(32);
$font->color('#000000');
$font->align('center');
$font->valign('top');
$font->angle(0);
});
return $img->response('gif');