Расширение класса FPDF не работает

У меня проблема с FPDF, потому что расширение моего класса не работает.

Я создаю класс для моего нижнего колонтитула и затем вызываю его с помощью:

$pdf = new PDF2();

У меня есть код во внешнем файле с включенным выше всего кода, например:

include"fpdf.php";

class PDF2 extends TFPDF
{
// Page footer
function Footer()
{
// MB LOGO 30cm before the end of the page
$Y = $this->SetY(-65);
// Arial italic 8
$this->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$this->SetFont('DejaVu','',10);
//MB LOGO
$this->Image('img/multibanco.jpg',20,$Y,30);
}
}

//pdf begins
// Cliente info encomenda
$pdf = new tFPDF();
$pdf = new PDF();
$pdf = new PDF2();
$pdf->addPage();

// Arial bold 15
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',11);

// Title
$pdf->Cell(190,10,'Ordem Nº '.$maxi.'',0,0,'C');

// Line break
$pdf->Ln(20);

// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',10);

// Cliente nome/email
$pdf->Cell(150,10,'Cliente: '.$enc['nome'].' '.$enc['apelido'].' ',0,1);
$pdf->Cell(150,10,'Email: '.$enc['email'].'',0,1);
$pdf->setFillColor(232, 232, 232);

//Messagem
$pdf->RoundedRect(10, 50, 190, 10, 3.5,TRUE);
$pdf->Cell(190,10,'Mensagem',0,1,'L'); //header
$pdf->setFillColor(255, 255, 255); // background
$pdf->MultiCell(180,5,'Text',0,'J',0); // MENSAGEM

//TABELA
$html ='';
$html='<table border="0">
<tr>
<td width="230" height="40" bgcolor="#e6e6e6">Tipo</td>
<td width="88" height="40" bgcolor="#e6e6e6">Formato</td>
<td width="88" height="40" bgcolor="#e6e6e6">Nº Interno</td>
<td width="88" height="40" bgcolor="#e6e6e6">Revelar</td>
<td width="88" height="40" bgcolor="#e6e6e6">Digitalizar</td>
<td width="88" height="40" bgcolor="#e6e6e6">Edição</td>
<td width="88" height="40" bgcolor="#e6e6e6">Impressão</td>
</tr>';

while($pdf_info2 = $smth->fetch(PDO::FETCH_ASSOC)) {
$html .= '
<tr>
<td width="230" height="40" bgcolor="#f7f7f7">'.$pdf_info2['Tipo'].'</td>
<td width="88" height="40" bgcolor="#f7f7f7">'.$pdf_info2['Formato'].'</td>
<td width="88" height="40" bgcolor="#f7f7f7">&nbsp;</td>
<td width="88" height="40" bgcolor="#f7f7f7">'.$pdf_info2['Revelar'].'</td>
<td width="88" height="40" bgcolor="#f7f7f7">'.$pdf_info2['Digitalizar'].'</td>
<td width="88" height="40" bgcolor="#f7f7f7">'.$pdf_info2['Edicao'].'</td>
<td width="88" height="40" bgcolor="#f7f7f7">'.$pdf_info2['Impressao'].'</td>
</tr>';
}

$pdf->WriteHTML($html);

//OUTPUT + LN
$pdf->Ln(10);
$pdf->Output();

Любые ошибки класса не отображаются, по крайней мере, я не вижу их даже без комментария error_reporting (0).

0

Решение

Вы не должны объявлять объект $pdf не раз нужно вызывать файл tfpdf.php, там встроен класс tFPDF(),

пример

<?php

// Optionally define the filesystem path to your system fonts
// otherwise tFPDF will use [path to tFPDF]/font/unifont/ directory
// define("_SYSTEM_TTFONTS", "C:/Windows/Fonts/");

require('tfpdf.php');

$pdf = new tFPDF();
$pdf->AddPage();

// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',14);

// Load a UTF-8 string from a file and print it
$txt = file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt);

// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 12 KB.');

$pdf->Output();
?>

Загрузите класс tFPDF () в http://www.fpdf.org

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector