Mehedee Rahman Setu
Mehedee Rahman Setu

Reputation: 107

Generating pdf in Turkish Language fpdf

In put and out put data are getting different on pdf file generated through fpdf.

input: uçak is Turkish word
Output: uçak is Turkish word

What I am doing:

  1. Convert arial.tft to .z and define php from http://fpdf.fruit-lab.de/index.php?id=3
  2. Map: cp1254 for Turkish language.
  3. Download only .z and define php file.
  4. Both are copied in the font folder in fpdf.

I am using following code:

<?php
require('fpdf.php');

$pdf = new FPDF();
$pdf->AddFont('ArialMT','','ArialMT.php');
$pdf->AddPage();
$pdf->SetFont('ArialMT','',35);
$pdf->Write(10,'uçak is Turkish word');
$pdf->Output();
?>

which results in the following output:

uçak is Turkish word

Where am I making mistake? Do I have to do any additional task?

Upvotes: 2

Views: 3672

Answers (2)

muselbetsi2017
muselbetsi2017

Reputation: 17

This worked for Turkish language...

<?php

require('tfpdf.php');
$pdf = new tFPDF();

$pdf->AddPage();

$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);

$pdf->SetFont('DejaVu','',14);
$pdf->Cell(130 ,5,'Uçak',0,0);

$pdf->SetFont('DejaVu','',12);
$pdf->Cell(130 ,5,'Fıstıkçı Şahap',0,0);

$pdf->Output("fatura.pdf","D");
?>

Upvotes: 0

Jay Rainey
Jay Rainey

Reputation: 386

I answered this in the comments section above, but for future reference:

By default, FPDF does not support unicode characters. There are two popular extensions available, which are:

  • tFPDF - A fork of FPDF with unicode support.
  • uFPDF - A minor patch for unicode support. Contains lots of examples.

Upvotes: 6

Related Questions