I am trying to make a pdf file using php and fpdf. Input is coming from a txt file. The txt file has UTF-8 character encoding.
Some of the characters, like quotes and dash etc, they come out all messed up in the pdf. Below is the original string, and the string that comes out in pdf.
How to fix this?
I tried the solution given in this below stackoverflow question, but it didn't work. Completely skips the line with the quotes characters. utf8 decode for fpdf in php
I tried using utf8_decode(), but that converts the quotes to question mark sign.
original text file has this line:
“The” — Adventures of
comes out as this in pdf:
â€oeThe― â€" Adventures of
This is the code I am using:
<?php
require('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$row=file('toys.txt');
$pdf->SetFont('Arial','B',12);
foreach($row as $rowValue) {
$data=explode(';',$rowValue);
foreach($data as $columnValue)
$pdf->Cell(90,12,$columnValue,1);
$pdf->SetFont('Arial','',12);
$pdf->Ln();
}
$pdf->output( "toys2.pdf", "f" );
echo "done";
?>