$pdf = new FPDI(); // initializing FPDI $pdf->SetTitle('Sample PDF Document'); // setting the document title $pdf->AddPage(); // adding a new page $pdf->SetFont('Helvetica', '', 12); // setting the font $pdf->MultiCell(0, 5, 'This is a sample PDF document.', 0, 'L'); // adding text to the document $pdf->Output(); // outputting the PDF document
require('fpdf/fpdf.php'); // requiring the FPDF library $pdf = new FPDF(); // initializing FPDF $pdf->SetTitle('Hello World!'); // setting the document title $pdf->AddPage(); // adding a new page $pdf->SetFont('Arial', 'B', 16); // setting the font and style $pdf->Cell(40, 10, 'Hello World!'); // adding text to the document $pdf->Output(); // outputting the PDF documentIn this example, the SetTitle function is used to set the title of the PDF document to "Hello World!". The FPDF library is used to create the PDF document, and other functions are used to add text and formatting. Package/Library: FPDF and/or FPDI.