Concatenate PDF files

The concatenation or merging of PDF files is among the popular operations where we combine multiple PDF files 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 with more than one person or team may 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 them 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 we do not specify the startPage and endPage information, the whole file is combined. At the end of the operation, the input file is a merged document.

curl -X POST "https://api.aspose.cloud/v3.0/pdf/Aspose_Words_Assembly.pdf/appendDocument?appendFile=sample.pdf&startPage=2&endPage=2" -H "accept: application/json" -H "authorization: Bearer <JWT token>"

PHP code snippet

Merge Multiple PDF files

Apart from PDF concatenation operation, 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

{<br>
  "List": [<br>
    "Aspose_Words_Assembly.pdf","sample.pdf","sample_assessment_test.pdf"<br>
  ]<br>
}

cURL command to Merge documents

curl -v 
-X PUT "https://api.aspose.cloud/v3.0/pdf/Resultant.pdf/merge" \
-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

Conclusion

In this article, we have discussed the steps to merge PDF files with PHP. With a few code lines, we can combine PDF files using PHP SDK. We have also seen the option to

We also recommend visiting the following links to learn more about