未被捕获的例外'例外'消息' FPDF错误:不是PNG文件:

时间:2016-04-26 23:40:14

标签: php png fpdf

我正在尝试从特定图像数据生成pdf文件。我收到的错误是Uncaught exception' Exception'有消息未捕获的异常'异常'消息' FPDF错误:不是PNG文件:http://apollobols.com/uploads/555_img.png' 但是,我已经知道那里存在PNG文件。该PNG文件的位置是 以下是我在FPDF中的代码

require('fpdf/fpdf.php');
define('FPDF_FONTPATH', 'font/');
SESSION_START();

//Connect to your database
include("db.php");
class PDF extends FPDF
{
// Page header
function Header()
{
    // Logo
    //$this->Image('images/gill-energy-logo.jpg',10,6,30);
    // Arial bold 15
    //$this->SetFont('Arial','B',15);
    // Move to the right
    //$this->Cell(80);
    // Title
   // $this->Cell('Showing results',0,'BOL Report');
    // Line break
    //$this->Ln(20);
}

// Page footer
function Footer()
{
    // Position at 1.5 cm from bottom
    $this->SetY(-15);
    $this->Image('images/gill-energy-logo.jpg', 1, $this->GetY(), 33.78);
    // Arial italic 8
    $this->SetFont('Arial','I',8);
    // Page number
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}


    const DPI = 96;
    const MM_IN_INCH = 25.4;
    const A4_HEIGHT = 297;
    const A4_WIDTH = 210;
    // tweak these values (in pixels)
    const MAX_WIDTH = 800;
    const MAX_HEIGHT = 500;
    function pixelsToMM($val) {
        return $val * self::MM_IN_INCH / self::DPI;
    }
    function resizeToFit($imgFilename) {
        list($width, $height) = getimagesize($imgFilename);
        $widthScale = self::MAX_WIDTH / $width;
        $heightScale = self::MAX_HEIGHT / $height;
        $scale = min($widthScale, $heightScale);
        return array(
            round($this->pixelsToMM($scale * $width)),
            round($this->pixelsToMM($scale * $height))
        );
    }
    function centreImage($img) {
        list($width, $height) = $this->resizeToFit($img);
        // you will probably want to swap the width/height
        // around depending on the page's orientation
        $this->Image(
            $img, (self::A4_HEIGHT - $width) / 2,
            (self::A4_WIDTH - $height) / 2,
            $width,
            $height
        );
    }
}
// usage:
$pdf = new PDF();
$title = 'Gill Energy BOL Report';
$pdf->SetTitle($title);
$pdf->AliasNbPages();

$result=mysql_query("select * from tbl_details where (date BETWEEN '$_SESSION[date1]' AND '$_SESSION[date2]') OR (user = '$_SESSION[username]');");

//initialize counter
//$i = 0;
//Set maximum rows per page
//$max = 25;
while($row = mysql_fetch_array($result))
{
    //If the current row is the last one, create new page and print column title
        $filename = pathinfo($row['bol_image']);
        $pdf->AddPage("P");
        $pdf->SetMargins(10, 10, 10, 10);
        $pdf->Image('http://apollobols.com/uploads/'.$row['bol_image'],5,5,0,0,strtoupper($filename[extension]));
        //echo $filename['extension']; 
}
$pdf->Output();

0 个答案:

没有答案