require_once('tcpdf/tcpdf.php'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('John Doe'); $pdf->SetTitle('Invoice #001'); $pdf->SetSubject('Invoice for goods purchased'); $pdf->SetFont('helvetica', '', 11); $pdf->AddPage(); $html = 'Invoice #001
'; $html .= 'Date: 21/06/2021
'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
Product | Description | Price |
Shirt | Blue size L | $25.00 |
Trousers | Khaki size M | $35.00 |
Total: $60.00
'; $pdf->writeHTML($html, true, false, true, false, ''); $pdf->Output('invoice.pdf', 'D'); In the above code, TCPDF is used to create a new PDF document, set its metadata, and define the font to be used. HTML code is then generated to display an invoice that includes product details and their respective prices. The resulting PDF is then downloaded (D) as "invoice.pdf". Other libraries that can be used for generating PDF output in PHP include FPDF, mPDF, and Dompdf. Each of these libraries has its own set of features and capabilities, and the choice of which one to use depends on the specific requirements of the project.