A client came to me with the need to create many pdfs from data in a MySQL database. There are many ways to go about doing something like this and I decided to write a PHP script to accomplish the task. The main objective was to quickly get the data saved into PDF format. I used the free FPDF package to speed up the process of generating the pdfs. I also decided to set up this project in a way that I could easily re-use it in the future by creating an env file for storing the database credentials. You can find a simple example of my code by visiting the GitHub Repository.
Working with over 50 thousand database entries can be hard to keep track of. In order to help with this, I decided to create a log file to document all of the pdfs that were created. This way, if anything went wrong, or if any of the pdfs needed to be recreated or edited, it would be easier to find the file name, file path, etc. I also had the php script print the amount of pdfs created to the screen so I could make sure that the count matched the amount of records in the database.
Visit Site