I'm using DOMpdf to generate PDF files, I'm able to generate 15 pages so far, however I need to be able to generate 130 pages, I know this might consume memory, so I'm looking for a way where I can generate each 10 pages in a separate process, and make all of them write to the same file. My question is, is that possible?
            Asked
            
        
        
            Active
            
        
            Viewed 101 times
        
    0
            
            
        - 
                    1Have you tried increasing execution time allowed for PHP scripts? That would allow you to create more pages. – Justin Wood Dec 21 '13 at 21:42
- 
                    Why do you want 130 pages? Are you making a book? – putvande Dec 21 '13 at 21:42
- 
                    Yes I did, but the problem is a memory problem apparently. – Mohamed Said Dec 21 '13 at 21:43
- 
                    @putvande no I'm generating a workout program for a gym web application – Mohamed Said Dec 21 '13 at 21:44
- 
                    related: http://stackoverflow.com/questions/2323045/dompdf-memory-issues – gherkins Dec 21 '13 at 21:57
1 Answers
2
            There are many tools that can join PDFs together. One that I have had a lot of luck with is PDFtk Server. If you generate many small PDFs (e.g. 001.pdf, 002.pdf, 003.pdf) you can generate a joined PDF (e.g. final.pdf) with something like
pdftk cat 001.pdf 002.pdf 003.pdf output final.pdf
The page ordering of final.pdf will respect the order of the input files.
This is a standalone Java program, not a PHP library, so you'll have to kick the tool off with something like shell_exec or any number of other options.
 
    
    
        ChrisGPT was on strike
        
- 127,765
- 105
- 273
- 257
- 
                    It seem to be a great solution, but I couldn't find a way to install it on Ubuntu, I'm running on Digital Ocean. – Mohamed Said Dec 21 '13 at 21:57
- 
                    @MohamedSaid, `pdftk` is available in the universe repository for Ubuntu 13.10. You can enable this repository as outlined at http://askubuntu.com/questions/148638/how-do-i-enable-the-universe-repository – ChrisGPT was on strike Dec 21 '13 at 21:59
