我一直在做一个项目,我正在尝试使用 PHP GD 库从表单创建图像文件。创建表单后,我将其转换为 pdf 文件(使用 FPDF),然后下载到本地设备。但我面临的问题是孟加拉字体无法正常工作。有什么办法可以解决这个问题吗?如果 GD 库无法做到这一点,那么还有其他方法可以解决这个问题吗?这是我想要实现的图像。
标记的单词来自表格。
这是详细代码。`<?php
// include_once 'database.php'; //$res = mysqli_query($conn, "SELECT * FROM wcertificate
WHERE status=0 limit 1");
if (isset($_POST['insert'])){
header('Content-type: image/jpeg');
//putenv('GDFONTPATH=' . realpath('.'));
$font = $font = 'C:\xampp\htdocs\joshodol\warishan\Siyamrupali.ttf';
$image = imagecreatefromjpeg('warishan.jpg');
$color = imagecolorallocate($image, 19, 21, 22);
$Date = "";
imagettftext($image, 14, 0, 510, 165, $color, $font, $_POST['Date']);
$Sharok="";
imagettftext($image, 14, 0, 80, 165, $color, $font, $_POST['Sharok']);
$name = "";
imagettftext($image, 14, 0, 280, 295, $color, $font, $_POST['name']);
$name1 = "";
imagettftext($image, 14, 0, 450, 295, $color, $font, $_POST['Fname']);
$name2 = "";
imagettftext($image, 14, 0, 80, 320, $color, $font, $_POST['Mname']);
$Village = "";
imagettftext($image, 14, 0, 250, 320, $color, $font, $_POST['Village']);
$Post = "";
imagettftext($image, 14, 0, 450, 320, $color, $font, $_POST['Post']);
$Serial1 = "";
imagettftext($image, 14, 0, 70, 587, $color, $font, $_POST['Serial1']);
$War1 = "";
imagettftext($image, 14, 0, 240, 587, $color, $font, $_POST['War1']);
$War2 = "";
imagettftext($image, 14, 0, 435, 587, $color, $font, $_POST['War2']);
$Serial2 = "";
imagettftext($image, 14, 0, 70, 605, $color, $font, $_POST['Serial2']);
$War3 = "";
imagettftext($image, 14, 0, 240, 605, $color, $font, $_POST['War3']);
$War4 = "";
imagettftext($image, 14, 0, 435, 605, $color, $font, $_POST['War4']);
$Serial3 = "";
imagettftext($image, 14, 0, 70, 623, $color, $font, $_POST['Serial3']);
$War5 = "";
imagettftext($image, 14, 0, 240, 623, $color, $font, $_POST['War5']);
$War6 = "";
imagettftext($image, 14, 0, 435, 623, $color, $font, $_POST['War6']);
$Serial4 = "";
imagettftext($image, 14, 0, 70, 641, $color, $font, $_POST['Serial4']);
$War7 = "";
imagettftext($image, 14, 0, 240, 641, $color, $font, $_POST['War7']);
$War8 = "";
imagettftext($image, 14, 0, 435, 641, $color, $font, $_POST['War8']);
$Serial5 = "";
imagettftext($image, 14, 0, 70, 659, $color, $font, $_POST['Serial5']);
$War9 = "";
imagettftext($image, 14, 0, 240, 659, $color, $font, $_POST['War9']);
$War10 = "";
imagettftext($image, 14, 0, 435, 659, $color, $font, $_POST['War10']);
imagejpeg($image,'warishancertificate.jpg' );
imagedestroy($image);
require('fpdf.php');
$pdf = new FPDF();
$pdf -> AddPage();
$pdf -> Image ('warishancertificate.jpg', 0,0,200,200);
$pdf -> Output("warishan.pdf", "F");
//重定向
header("Location: download.php");
}
?> `