What are some common pitfalls when using FPDF for creating PDFs in PHP?

One common pitfall when using FPDF for creating PDFs in PHP is not setting the correct content type header before outputting the PDF. This can result in the PDF file being corrupted or not displayed properly in the browser. To solve this issue, make sure to set the content type header to 'application/pdf' before outputting any PDF content.

// Set content type header
header('Content-Type: application/pdf');

// Create FPDF instance
$pdf = new FPDF();

// Add content to PDF
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');

// Output PDF
$pdf->Output();