SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question pdf creation error

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

    how can i solve it

  2. #2
    SitePoint Enthusiast monkey56657's Avatar
    Join Date
    Jun 2007
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use ob_start(); at the very very top of ure page and ob_end_clean(); at the point just below pdf creation.

    This will stop any output between the 2 statements, but if u include this file from elsewhere, or have blank lines at the top or things like that it might not work.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question pdf creation error

    already i wrote this function but till now show this error

  4. #4
    SitePoint Enthusiast monkey56657's Avatar
    Join Date
    Jun 2007
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do u have any white space b4 ure opening php statement ?

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2004
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having the same issue. This is my code so far:

    PHP Code:
    <?php
    ob_start
    ();
    ?>
    <html>
    <head>
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    require('fpdf.php');
    $pdf=new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,10,'Hello World!');
    $pdf->Output();
    ob_end_clean();
    ?>
    </body>
    </html>
    Any ideas ?

    Thx,
    M

  6. #6
    SitePoint Evangelist
    Join Date
    Jun 2004
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, just found it. Below the correct code.

    PHP Code:
    <?php 
    ob_start
    ();
    require(
    'fpdf.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <?php
    $pdf
    =new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,10,'Hello World!');
    ob_end_clean();
    $pdf->Output();
    ?>

    </body>
    </html>
    M

  7. #7
    SitePoint Enthusiast monkey56657's Avatar
    Join Date
    Jun 2007
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You shount have any of the html in there at all. and ob_end_clean after the pdf output wont help.

  8. #8
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    In a house in the USA
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Monkey56657 is correct. When you work with the FPDF class you do not use any HTML in the php file.

    All you need is:
    PHP Code:
    <?php
    require('fpdf.php');
    $pdf=new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,10,'Hello World!');
    $pdf->Output();
    ?>
    I use this library every day and you can create some interesting PDF files with it.
    Daniel
    http://www.wlscripting.com - PHP Tutorials and code snippets
    Notepad++ Function List plugin tip - for PHP developers

  9. #9
    SitePoint Evangelist
    Join Date
    Jun 2004
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx for the further info :-)

    M


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •