Search code examples
phpmysqldatabasefpdf

how to create invoice pdf with php and fpdf?


Here user can order their items and after confirmation of order they can download invoice file. After a quick Google I know about fpdf .but my question is how to create unique users invoice pdf through fpdf and php?
This is my cart page. When user click confirm oder they redirect into success page where they can download their invoice
cart page

[It is success page][2]error in generate unique user pdf code Part -1code part 2code part 3


Solution

  • Firstly I would suggest to use TCPDF

    You can do following steps to generate pdf:

    1. Gather all the data in session.

    2. After confirming order get all the data from the session and use that data in generating pdf file

    3. Use following link to get the example how to generate pdf. TCPDF Examples It will help you to code for generating pdf.

    4. For unique user pdf generation you can rename the file name with user_id + timestamp