Today we will learn about generating the invoice in PDF using FPDF library. FPDF provides the PHP classes to generate PDF. It may be useful for generate the invoice in PDF, download product description in PDF etc. for e-commerce websites.
First we download the FPDF zip file from the http://www.fpdf.org/ and upload it on server at root directory.
Then set the PDF generator button at your page as per your requirement. In this case we set the invoice button at order history information for particular order to generate invoice for particular order.
Then after getting the order details we added the PDF generator code in invoice controller by including the FPDF class file and using it’s function.
Then for iterating the products and total of the order we can iterate the cell of document.
Output will be :