@filiberto
To create a PDF file using native PHP, you can use the TCPDF library. Here are the steps to follow:
- Download and install TCPDF library:
Visit the TCPDF official website (https://tcpdf.org/).
Download the latest version of TCPDF library.
Extract the downloaded zip file and move the "tcpdf" folder to your project directory.
- Include the TCPDF library in your PHP file:
require_once('tcpdf/tcpdf.php');
- Create a PDF object:
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8');
- Set document information:
$pdf->SetCreator('Your Name');
$pdf->SetAuthor('Your Name');
$pdf->SetTitle('My PDF');
$pdf->SetSubject('Creating PDF with PHP');
$pdf->SetKeywords('PDF, PHP, TCPDF');
- Set default font:
$pdf->SetFont('Helvetica', '', 12);
- Add a page:
$pdf->AddPage();
- Write content to the PDF:
$pdf->Cell(0, 10, 'Hello World!', 0, 1);
- Output the PDF to a file or the browser:
To save the PDF to a file:
$pdf->Output('path/to/output.pdf', 'F');
To display the PDF in the browser:
$pdf->Output('output.pdf', 'I');
That's it! You have created a PDF file using native PHP with the help of the TCPDF library.