What are common pitfalls when using FPDF for PDF generation in PHP?
One common pitfall when using FPDF for PDF generation in PHP is not setting the appropriate content-type header before outputting the PDF. This can result in corrupted or unreadable PDF files. To solve this issue, make sure to set the content-type header to "application/pdf" before outputting the PDF.
// Set content-type header
header('Content-type: application/pdf');
// Create a new PDF instance
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();