Merge PDF files using PHP Cloud SDK

Concatenate PDF files

The concatenation or merging of PDF files is among the widely used operations where multiple PDF files are combined together to create one single document. There can be several business use cases where PDF concatenation operations can be useful. Given below are some of the real-life examples where this feature becomes quite beneficial.

Geographical distant teams on single Projects – a project that has more than one person or team involved will end up with documents being submitted from every angle, especially when team members are distantly apart. For example, a proposal for new housing development will include reports from engineers, architects, environmental agencies, and builders, not to mention the original proposal documents. If these are all sent in various file formats, they can all be saved as PDF documents and then merged, so the final artifact can then be made using only one big document with all team’s input and conclusions in one place.

Document Archive System – places such as records libraries will have thousands of files saved electronically as separate documents rather than one big record. Merging these files as PDFs in groups will mean that searchers need to spend less time working through while trying to find a document.

Aspose provides a wide range of options to accomplish this requirement. If you need to fulfill the requirement using on-premise APIs, then Aspose.PDF is the right solution. Whereas if your preference is to perform the operations using a free and online cross-platform App, then try using Aspose.PDF merger APP. Nevertheless, if you prefer to programmatically accomplish the PDF concatenation functionality using Cloud API without any specific software installation, then Aspose.PDF Cloud API is a perfect choice.

cURL command for PDF merge

The cURL commands are the quickest way to accomplish the PDF merge feature through the command prompt. We need to use PostAppendDocument method to combine two PDF files. Two of the mandatory parameters include the name (the original PDF file) and, appendFile (name of PDF file to be appended). It also accepts two optional parameters startPage (start page of the file to be appended) and endPage (end page of the file to be appended). In case the startPage and endPage information are not specified, the whole file is appended. At the end of the operation, the source file is saved as a merged document.

curl -X POST "" -H "accept: application/json" -H "authorization: Bearer <JWT token>"

PHP code snippet

Merge Multiple PDF files

Apart from PDF Append operation where one file is concatenated with other documents, the API also offers another method PutMergeDocuments where a list of documents is merged together. It accepts two mandatory arguments name (resultant PDF file) and mergeDocuments (JSON list of documents to be merged). The list is specified as given below

  "List": [<br>

cURL command to Merge documents

curl -X PUT "" -H "accept: application/json" -H "authorization: Bearer <JWT Token>" -H "Content-Type: application/json" -d "{ \"List\": [ \"Aspose_Words_Assembly.pdf\",\"sample.pdf\",\"sample_assessment_test.pdf\" ]}"

PHP code snippet