The PDF split and merge operations are typically offered only in paid software, and most free PDF viewers lack these capabilities. If you need to merge PDF documents, you often must install, configure, and purchase a full license—even when you only require basic merging. Additionally, some platforms may not have suitable software available. To avoid these issues, we recommend using the Aspose.PDF Cloud API to merge PDF files online. No download or installation is needed; all operations run in the cloud.
PDF processing API in Python
Aspose.PDF Cloud SDK for Python wraps the Aspose.PDF Cloud API, giving Python developers full PDF processing power. The SDK also includes a feature to merge multiple PDF files into a single document with just a few lines of code.
Installation
First, install the SDK from PIP or the GitHub repository. This article covers installation via PIP. Run the following command in your terminal or command prompt to install the latest SDK version.
pip install asposepdfcloud
Installation in Pycharm
PyCharm is a popular IDE for Python development. To add the SDK directly in PyCharm, follow these steps.
Click Preferences under the PyCharm menu.
From the left tree, select Python Interpreter under the Project section.
Click the + (plus) sign on the right, type asposepdfcloud in the search field, and choose it from the available packages dialog.
Press Install Package. After installation, a success message appears.
Merge PDF files in Python
Aspose.PDF Cloud stores documents in cloud storage, ensuring data integrity and privacy. Only authorized users can access the APIs. Begin by creating an account on the Aspose.Cloud dashboard. Sign up with a GitHub or Google account, or use the Create a new Account button and provide the required details. After logging in, expand the Applications section and locate the Client Credentials area to retrieve your Client ID and Client Secret.
Follow these steps to merge PDF documents:
- Create an ApiClient object using your Client ID and Client Secret.
- Instantiate a PdfApi object with the ApiClient.
- Build an Opts object to specify the target PDF, start page, and end page.
- Call post_append_document(…) to execute the merge.
Merge PDF files using the cURL command
cURL provides a convenient way to call REST APIs from any command‑line terminal, without installing the SDK. First, generate a JSON Web Token (JWT) to authenticate API calls. Use the same JWT for subsequent cURL requests.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=a41d01ef-dfd5-4e02-ad29-bd85fe41e3e4&client_secret=d87269aade6a46cdc295b711e26809af" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Then run the following command to merge a target PDF into the source PDF using the PostAppendDocument API. The merged result is saved to cloud storage.
curl -X POST "https://api.aspose.cloud/v3.0/pdf/PdfWithAnnotations.pdf/appendDocument?appendFile=PdfWithTable.pdf&startPage=2&endPage=3" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
Conclusion
This article outlined how to perform PDF merge operations with the Python REST API. Because the SDK is open source, you can download the full source code from the GitHub repository.
For more details about SDK capabilities, visit the Aspose.PDF Cloud Features documentation. If you encounter any issues, feel free to reach out via our free technical support forum.
Related Articles
We also recommend the following articles: