Reputation: 19
I have been working on a project where I am trying to create a image file from a form using PHP GD library. After creating the form I am converting it to an pdf file (with FPDF) and then download to local device. But the problem I am facing is that bengali font is not working properly. Is there any way I can resolve this issue? If GD library is not capable of doing this then is there any other way I can solve this problem? Here is the image of what I am trying to achieve.
Marked words are coming from the form.
Here is the detail code. `<?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");
//Redirect
header("Location: download.php");
}
?> `
Upvotes: 1
Views: 251