0

I am trying to create a pdf receipt in marathi but certain words are not displaying correctly such as श्री is displaying as 2 seperate characters which is incorrect. I have checked all other answers available but nothing seems to help such as using different fonts.

Below is my code

// Include the main TCPDF library (search for installation path).
require_once('tcpdf.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

//remove default header and footer
$pdf -> setPrintHeader(false);
$pdf -> setPrintFooter(false);

//add page
$pdf->AddPage();
$hypen = str_pad($hypen, 156, "-", STR_PAD_BOTH);
//add content here

$pdf->SetFont('freesans', '', 16);
$pdf->cell(30, 5, "॥ श्री मल्लिकार्जुन प्रसन्न ॥ ", 0, 1);


$pdf->cell(10, 5, " ", 0, 0);
$pdf->cell(130, 5, "नंबर: ".$_POST['id'], 0, 0);
$pdf->cell(40, 5, "दिनांक: ".$today_date, 0, 1);
$pdf->MultiCell(180, 5, "श्री__________________________________________________", 0, 'L');

$pdf->MultiCell(180, 5, "मु़._________________________यांनी___________________बद्दल दिले.", 0, 'L');
$pdf-> ln(4);
$pdf->Cell(180, 4, $hypen, 0, 1, 'L'); 
$pdf->cell(10, 5, "क्र ", 0, 0);

$pdf->cell(50, 5, "देवक्रत्य  ", 0, 0,'C');
$pdf->cell(120, 5, "रु.    ", 0, 1,'R');
$pdf->Cell(180, 4, $hypen, 0, 1, 'L'); 
sahilver
  • 7
  • 8
  • Use a custom font able to display hindi please . You may refer to this [link](https://queirozf.com/entries/adding-a-custom-font-to-tcpdf) and this [link](https://stackoverflow.com/questions/5263588/how-to-implement-custom-fonts-in-tcpdf) – Ken Lee Nov 28 '21 at 14:40
  • i have checked various custom fonts for hindi but getting the same issue. I have done like below $fontname = TCPDF_FONTS::addTTFfont('unicode/Kruti_Dev_010.ttf', 'TrueTypeUnicode', '', 96); $pdf->SetFont($fontname, '', 14, '', false); – sahilver Nov 28 '21 at 16:55
  • As of now, this is not possible with tcpdf even with custom fonts...I had to use mpdf. Also never use cell method in mpdf or else you will still face issue. Use the WriteCell() and WriteText() methods instead. – sahilver Dec 16 '21 at 07:18
  • I have made a test for you (using TCPDF) - please see whether it works for you (but since I don't understand the hindi characters I don't know the meaning of the characters) . Please test this link (you need to use a **new browser window to paste this link and test**) : http://www.createchhk.com/SO/testcert1_SO17Dec2021.php – Ken Lee Dec 16 '21 at 17:42
  • It seems to work like, but I have already shifted to mpdf and have got desired output. maybe you can post the code, it might help someone else. Thanks alot for trying. – sahilver Dec 17 '21 at 06:50

0 Answers0