https://www.fpdf.org
Keep the fpdf.php file in your working directory, keep the font directory in the same place. <?Php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(80,10,'Hello World!');
$pdf->Output('my_file.pdf','I'); // Send to browser and display
?>
Check the output to display the string in PDF <?Php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(80,10,'Hello World!',1,0,'R',false,'https://www.plus2net.com');
$pdf->Output('my_file.pdf','I'); // send to browser and display
?>
String with border , alignment, background fill in PDF $pdf->SetFillColor(1,255,255);
$pdf->Cell(80,10,'Hello World!',1,0,'R',true,'https://www.plus2net.com');
$pdf->Output('my_file.pdf','D');
Output with background color is here <?Php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->SetFillColor(1,99,255); // input R ,G , B
$pdf->SetTextColor(255,254,254);// input R , G , B
$pdf->Cell(80,10,'Hello World!',1,0,'C',true,'https://www.plus2net.com');
$pdf->Output('my_file.pdf','I'); // Send to browser and display
?>
Output with background and Font color is here <?Php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->SetFillColor(1,99,255); // input R ,G , B
$pdf->SetTextColor(255,254,254);// input R , G , B
$pdf->SetDrawColor(255,1,1);// input R , G , B
$pdf->SetLineWidth(1);
$pdf->Cell(80,10,'Hello World!',1,0,'C',true,'https://www.plus2net.com');
$pdf->Output('my_file.pdf','I'); // Send to browser and display
?>
Output with border width and colour is here 'LRT'
, similarly we can assign border to bottom only by giving the option as 'B'
.
$pdf->Output('my_file','D');
to get output directly. This line will force download to user machine as pdf file my_file.pdf. We can change this output to save the file in local ( server ) side machine.
$pdf->Output('my_file.pdf','I'); // Send to browser and display
$pdf->Output('my_file.pdf','D'); // Force file download with name given ( name can be changed )
$pdf->Output('my_file.pdf','F'); // Saved in local computer with the file name given
$pdf->Output('my_file.pdf','S'); // Return the document as a string.
20-11-2020 | |
Excellent post. Nice work keep it up. Thanks for sharing the knowledge. |
26-11-2021 | |
Excellent post. Nice work keep it up. Thanks for sharing the knowledge. |
19-01-2023 | |
fpdf was run complatly in local host , browser but cant use in live server why? |