Reputation: 2832
I want to generate a PDF file in my web app. I am using php and I tried fpdf library
I tried to create pdf
by using following code:
<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Привет мир!');
$pdf->Output();
?>
It works when we use english characters inside file, but file encoding is ANSI
and inside writen russian characters I get that error:
if I change file encoding to utf-8
get error:
FPDF error: Some data has already been output, can't send PDF file (output started at Z:\home\fpdf\www\tutorial\tuto1.php:1)
Who knows how to resolve the problem, please help me !
Upvotes: 1
Views: 435
Reputation: 12040
$pdf->Cell(40,10, iconv('UTF-8', 'CP-1251', $str) );
Make sure you're saving your document as UTF8
Upvotes: 1