I wanted to add TCPDF to codeigniter so i downloaded TCPDF from [TCPDF Download](http://sourceforge.net/projects/tcpdf/files/) and created a file in /libraries/Pdf.php as such 

```
require_once dirname(__FILE__) . '/tcpdf/tcpdf.php';

class Pdf extends TCPDF
{
    function __construct()
    {
        parent::__construct();
    }
}

```

and used it as such in controller

```
function pdfTest(){

        $this->load->library("Pdf");
        $pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
        $pdf->SetCreator(PDF_CREATOR);
            // Add a page
            $pdf->AddPage();
            $html = "<h1>Test Page</h1>";
            $pdf->writeHTML($html, true, false, true, false, '');
            $pdf->Output();
        }

```

But it gives me below error

```
TCPDF ERROR: Some data has already been output, can't send PDF file

```

What could be the reason of the error and how can I solve it? I have searched allot but couldn't find a solution. 
Thank you guys in advance.