FPDF

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

FPDF

Post by guitarlvr »

I'm fiddling around with FPDF and am running into a problem. I'm walking through the tutorials on their site, the simplest one there is. I copied and pasted it into a php file on my server and included the fpdf.php file. When i run it, it should open acrobat and display hello world however it tells me that headers have already been sent to the browser and cannot open the file. The error is that of the included file (fpdf.php) sending headers to the browser. does anyone know how to overcome this issue?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You cannot mix the two streams together.. therefore you cannot have any output prior to sending the headers. How to solve it? Do not have any output prior to creating the pdf.
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post by guitarlvr »

I'm not outputing any headers. The required file used to create the pdf is what is outputing the headers. this is my php file:

Code: Select all

<?php

require('./fpdf153/fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

There are a couple reasons you might be getting the error then.. make sure you have no whitespace outside your <?php ?> tags, secondly you can try copy+paste your script into notepad and overwritting the file since hidden characters may have crept into the file.
Post Reply