Joining multiple PDF files into one page PDF positioning of the connection using PHP

This is not an attempt to combine individual PDF files into a single PDF file with multiple pages. This is an attempt to create a one-page PDF file from several other PDF files that already exist. I need to do this using PHP and the server is CentOS.

I am already creating a set of one-page PDF files based on individual templates (using FPDF). The requirement is to allow the user to mix and map existing PDF files and place them together to create a single PDF file.

join multiple PDFs using dynamic positions to single page PDF

My current attempt is to convert PDF files to images (using ghostscript) and use the output jpegs to create the final PDF file using FPDF. Although it’s possible, PDF quality is slightly degraded during conversion.

I would like to know if there is a better solution we can use?

UPDATE

The solution does not have to be PHP. Most likely, this will not happen. I am definitely for any command line tool that can do the job. An example command would look like this:

$ newtool -o outfile.pdf -s WidthXHeight -i in1.pdf in2.pdf in2.pdf -g p1Xp2 p3Xp4 p5Xp6

The above is an example - not a real team - I just want it if the tool has such functionality. Indicate the set of input files and their position in the output file.

+7
source share
1 answer

I have done this in the past with a combination of Ghostscript (to place an existing PDF page on a larger, blank PDF page) and pdftk (to overlay / merge two identical PDF pages into a new one).

Take a look at these answers (@ Superuser.com) to understand how this works:

My procedure uses the command line and / or scripts. However, it could also be expanded to do this programmatically with PHP using Ghostscript.dll / .so

+1
source

All Articles