w oparciu o klasę FPDF stworzyłem skrypt generujący PDF z danych, pobieranych z bazy PostgreSQL. Mam jednak problem z wyświetlaniem polskich fontów. Przygotowałem zatem odpowiednią czcionkę. Jednak nie przyniosło to oczekiwanych zmian. Sądzę więc, że problem leży w kodowaniu znaków. W bazie mam UTF-8 (nie mogę zmienić), natomiast FPDF koduje w ISO.
Poniżej zamieszczam kod klasy, w której użyłem funkcji iconv(). Z nie wiadomych mi przyczyn, zwraca mi jednak błąd informujący o niewłaściwym kodowaniu wyjściowym.
Gdybym mógł prosić o poradę, jak rozwiązać ten problem, byłbym wdzięczny.
<?php require('fpdf/fpdf.php'); //odniesienie do skryptu komponentu include ("./aktualnoscibd.php"); class mPDF extends FPDF { private $binShowHeader = true; private $binShowFooter = true; private $strHeader = ''; { if ($this->binShowHeader) { $this-> Image('/pdf_logo.jpg', 40, 10, 125, 55); } } public function Footer() { if ($this->binShowFooter) { $this->AliasNbPages(); $this-> SetTextColor(189,189,189); $this-> AddFont('arialpl', '', 'arialpl.php'); $this->SetFont('arialpl', '', 8); $this-> SetFontSize(8); $this->SetXY(45, -20); $this->Cell(20, 8, '"Promyczek"'); $this->Ln(20); } } public function setHeader($strHeader) { $this->strHeader = $strHeader; } public function enableHeader() { $this->blnShowHeader = true; } public function disableHeader() { $this->blnShowHeader = false; } public function enableFooter() { $this->blnShowFooter = true; } public function disableFooter() { $this->blnShowFooter = false; } } $pdf = new FPDF(); $pdf = new mPDF(); $pdf->Open(); $pdf->AddPage(); $pdf->SetTitle('Aktualnosci'); $pdf-> AddFont('arialpl', '', 'arialpl.php'); $pdf->SetFont('arialpl', '', 36); $pdf->SetTextColor(4, 4, 180); $pdf-> SetFillColor(4, 4, 180); $pdf-> SetDrawColor(4,4,180); $pdf-> SetXY(50, 45); $pdf-> Cell(120, 36, 'Aktualności', 0, 0, 'C'); $pdf-> SetLineWidth(0.1); $pdf-> Line(10, 68, 200, 68); $uchwyt_polaczenia='host = *** port = 5433 dbname = *** user = *** password = ***'; //table $fill=0; $i=0; while($i < $numregs) { $tekst = iconv('iso-8859-2', 'windows-1250', $tekst); $pdf->SetFont('arialpl', '', 10); $pdf->SetTextColor(4,4,180); $pdf-> SetXY(10, 70); $pdf-> Cell(90, 5, $tytul, 0, 0, 'L', $fill, '\n'); $pdf->SetFont('arialpl', '', 5); $pdf->SetTextColor(189,189,189); $pdf-> SetXY(10, 75); $pdf-> Cell(30, 5, $data, 0, 0, 'L', $fill); $pdf->SetFont('arialpl', '', 10); $pdf-> SetTextColor(0,0,0); $pdf-> SetXY(10, 80); $pdf-> MultiCell(190, 5, $tekst, 0, 'L', $fill); $fill=!$fill; $i++; } $pdf-> Output(); ?>