I am using the fpdf library for my project, and I'm using this to extend one of the drupal module. These lines
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
give me an error: FPDF error: Some data has already been output, can't send PDF
I tried creating this in a separate file outside the drupal area name test.php and when viewed it worked. Anyone here know why this don't work? Or anyone here can point me a right pdf library which I can use in drupal to view HTML to PDF format.
You need to call the library
http://www.fpdf.org/
http://www.fpdf.org/es/tutorial/tuto1.htm
if you're code outputs notices/warnings before the PDF generation, try turning them off.
error_reporting(0)
. Then work on the warnings there-afterFor fpdf to work properly, there cannot be any output at all beside what fpdf generates. For example, this will work:
While this will not (note the leading space before the opening
<?
tag)Also, this will not work either (the
echo
will break it):I'm not sure about the drupal side of things, but I know that absolutely zero non-fpdf output is a requirement for fpdf to work.
Hi do you have a session header on the top of your page. or any includes If you have then try to add this codes on top pf your page it should works fine.
cheers :-)
In my case i had set:
When i made the request to generate the report, some warnings were displayed in the browser (like the usage of deprecated functions).
Turning
off
thedisplay_errors
option, the report was generated successfully.