Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a large pdf, semi quickly

I need to generate a large PDF, 2480 pages to be exact. Currently I am using indesign, and while the output is exactly what I want. I would rather not be involved in the document creation process. It takes 31 minutes for indesign to execute the data merge, generate the pdf, save the pdf, and to save the pdf.indd file. (I dont really need the pdf.indd file, but I would rather not have to recreate the data merge if something were to happen to the pdf)

I am hoping for a php, or similar solution. Currently my data is stored in MySQL. The majority of the pdf is static text, with 19 dynamically driven text fields. There is one image on the pdf, 75x100px @ 72dpi.

The output needs to be exact, the pdf file is printed and cut in half at 4.25 inches.

I have tried TCPDF, while it is fast at generating upto 50 pages, after that it would rather die than give me an output. I have also played with mPDF, and found it to be, ..., not as friendly. I have also considered generating many small files and using some utility to merge the smaller pdf's into one large pdf. Though that seems like driving around the mountain.

Any thoughts would be helpful.

like image 685
mbunch Avatar asked Oct 05 '22 07:10

mbunch


2 Answers

You certainly can create documents directly with PHP, but it can be difficult. One method is to use one of the various PDF classes to create the document, as you have found. Another is to create images (using ImageMagic, GD, etc.) and convert those to PDF. (This method is less efficient, as you are creating raster graphics making the whole PDF page one giant graphic.)

However, I think you should consider simply scripting InDesign. InDesign has the capability to read data in via XML and create the document. This way, the design of your document isn't dependent on your programming abilities and you can still have the power of programmatically creating the document.

like image 77
Brad Avatar answered Oct 12 '22 00:10

Brad


When it comes to huge number of pages in PDF, LaTeX is always the best answer. Nothing can really handle huge PDF generation as fast, accurate and elegant as LaTeX. Check this question to see how to retrieve your data from the database.

like image 30
Bichoy Avatar answered Oct 11 '22 23:10

Bichoy