0

I am getting FPDF Error while trying to OutPut

    require('cons.php');  
    $fpd = new fpdfx();
    $fpd->AddPage();
    $fpd->SetFont('Arial','B',16);
    $fpd->Cell(40,10,'Hello World!');
    $fpd->Output();

and i have few codes in cons.php

        error_reporting(E_ERROR | E_PARSE); //For Error Reporting        
        session_start();
        setlocale(LC_MONETARY, 'da_DK');
        set_time_limit(0);
        define("DBHOST","XXX");
        define("DBNAME","XXX");
        define("DBUSER","XXX");
        define("DBPASS","XXX");       
        define("TODAYSDATE",date('d-m-Y', strtotime("+4 months")));
        define("UPDATEDATE",date('d-m-Y', strtotime("+5 months")));       
        define("LanguageFilesURL",'XXX');   

        global $instance;
        require("inc/Email-class.php");
        require("inc/database_class.php");

email class have email functionality with some email functions

here is my Email Class details

                require("fpdf/fpdf.php");
                class fpdfx extends FPDF
                {

                }


                class Email_class
                {
                }

when i am trying to get some output its shows

FPDF error: Some data has already been output, can't send PDF file

HeartDisk
  • 47
  • 1
  • 9

1 Answers1

1

Try to comment out the $fpd->Output(); and see if you got any notice or other data sent sent to the output.

If not, dig into the Output() method and use die(); until you find what puts some data out!

Nassim
  • 240
  • 1
  • 4
  • case 'D': // Download file $this->_checkoutput(); header('Content-Type: application/x-download'); header('Content-Disposition: attachment; filename="'.$name.'"'); header('Cache-Control: private, max-age=0, must-revalidate'); header('Pragma: public'); echo $this->buffer; die(); break; Like this ?? – HeartDisk Sep 19 '13 at 12:05
  • Have you tried to just comment out the $fpd->Output(); ? And inside the Output() method, you should die; before headers are sent, and see if anything has been output already. – Nassim Sep 19 '13 at 12:21
  • yeah i tried both not working anymore, // Download file $this->_checkoutput(); //header('Content-Type: application/x-download'); //header('Content-Disposition: attachment; filename="'.$name.'"'); //header('Cache-Control: private, max-age=0, must-revalidate'); //header('Pragma: public'); die(); echo $this->buffer; – HeartDisk Sep 19 '13 at 12:37
  • i comment all headers from OutPut function – HeartDisk Sep 19 '13 at 12:40
  • You could just die(); before headers are sent. Your goal is to find out what's written to the output before FPDF headers are sent. – Nassim Sep 19 '13 at 12:49
  • after die() i got %PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream xœ3Rðâ2Ð35W(çr QÐw3T04Ó30PISp êZ*˜[š€…¤(hx¤æää+„çå¤(j*„dÔ7W endstream endobj 1 0 obj <> endobj 5 0 obj <> endobj 2 0 obj << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI] /Font << /F1 5 0 R >> – HeartDisk Sep 19 '13 at 12:56
  • 1
    Weird, the die; should prevent echoing $this->buffer... Anyway, an other thing you can try is remove all closing PHP tags from your included files. There may be a hidden character sent to the outpup when a file is included. – Nassim Sep 19 '13 at 13:08