What are some common pitfalls when using FPDF for online PDF document generation in PHP?
One common pitfall when using FPDF for online PDF document generation in PHP is not setting the correct content type header before outputting the PDF. This can lead to unexpected behavior or errors when trying to view or download the generated PDF file. To solve this issue, make sure to set the content type header to "application/pdf" before outputting any content.
// Set content type header
header('Content-Type: application/pdf');
// Create FPDF object and output PDF
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();