FPDF error: Some data has already been output, can't send PDF
Asked 07 September, 2021
Viewed 1.5K times
  • 52
Votes

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.

15 Answer