我有一个包含以下代码的PHP页面。
<?php
$filepath = '../../../user_uploads/'.$_path['uploads']
.'prtl_icons/mod_icons_1438512347.jpg';
require('../../../fpdf/fpdf.php');
class PDF extends FPDF
{
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$pdf = new PDF('P','mm','A4');
$pdf->Image('http://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World',60,30,90,0,'PNG');
//$pdf->Image($filepath);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','B',11);
$pdf->Cell(40,10,'Family: ['.$_SESSION['UserID'].'] - '.$_SESSION['FirstName']);
$pdf->Output();
?>
当我运行该页面时,我收到以下错误。
Fatal error: Uncaught exception 'Exception' with message 'FPDF error: No page has been added yet' in /var/www/vhosts/portal.dev/fpdf/fpdf.php:271
Stack trace: #0 /var/www/vhosts/portal.dev/fpdf/fpdf.php(1450): FPDF->Error('No page has bee...') #1 /var/www/vhosts/portal.dev/fpdf/fpdf.php
(924): FPDF->_out('q 255.12 0 0 10...') #2 /var/www/vhosts/portal.dev/module/parents/calendar/pdf_loader.php(25):
FPDF->Image('http://chart.go...', 60, 30, 90, 0, 'PNG') #3 {main}
thrown in /var/www/vhosts/portal.dev/fpdf/fpdf.php on line 271.
当我使用$pdf->Image($filepath)
时,也会显示相同的错误。当我删除图像部分时,pdf正在正确加载。