SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
Thread: pdf creation error
-
Jun 8, 2007, 02:25 #1
- Join Date
- Jul 2006
- Posts
- 73
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
pdf creation error
FPDF error: Some data has already been output, can't send PDF file.
how can i solve it
-
Jun 8, 2007, 03:40 #2
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.
-
Jun 8, 2007, 03:52 #3
- Join Date
- Jul 2006
- Posts
- 73
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
pdf creation error
already i wrote this function but till now show this error
-
Jun 8, 2007, 06:35 #4
do u have any white space b4 ure opening php statement ?
-
Jun 13, 2007, 04:08 #5
- Join Date
- Jun 2004
- Posts
- 417
- 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>
Thx,
M
-
Jun 13, 2007, 04:12 #6
- Join Date
- Jun 2004
- Posts
- 417
- 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>
-
Jun 13, 2007, 06:41 #7
You shount have any of the html in there at all. and ob_end_clean after the pdf output wont help.
-
Jun 13, 2007, 12:17 #8
- 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();
?>Daniel
http://www.wlscripting.com - PHP Tutorials and code snippets
Notepad++ Function List plugin tip - for PHP developers
-
Jun 14, 2007, 01:26 #9
- Join Date
- Jun 2004
- Posts
- 417
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thx for the further info :-)
M
Bookmarks