/ Published in: Python
This REST example uses pycurl library to send HTTP request and handle HTTP response so you need to install it to use this example. Once input Word documents are uploaded, you can use the following URI to merge documents on Aspose for Cloud or any supported third party storage.
http://api.aspose.com/v1.1/words/MainDocument.docx/appendDocument
You can use a couple of optional parameters with the above mentioned URI. All or specific parameters can be used according to your requirement.
After building URI, you need to go through the following steps:
• Set App SID and App Key and sign URI. See section 1 of the following code and Sign URI method for more details.
• Build JSON to post in the request body. A list of input documents including their paths and import format modes should be provided. See section 2 of the following code.
• Send a POST request to Aspose for Cloud service. See section 3 of the following code and process_command method for more details.
• Download merged document file if required. See section 4 of the following code.
http://api.aspose.com/v1.1/words/MainDocument.docx/appendDocument
You can use a couple of optional parameters with the above mentioned URI. All or specific parameters can be used according to your requirement.
After building URI, you need to go through the following steps:
• Set App SID and App Key and sign URI. See section 1 of the following code and Sign URI method for more details.
• Build JSON to post in the request body. A list of input documents including their paths and import format modes should be provided. See section 2 of the following code.
• Send a POST request to Aspose for Cloud service. See section 3 of the following code and process_command method for more details.
• Download merged document file if required. See section 4 of the following code.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
####### Section 1 ###### # specify App SID AsposeApp.app_sid = '77****-****-****-****-80*********' # specify App Key AsposeApp.app_key = '******************' #build URI to merge PDFs str_uri = 'http://api.aspose.com/v1.1/words/MainDocument.docx/appendDocument' #sign URI signed_uri = Utils.sign(Utils(), str_uri) ####### End Section 1 ###### ####### Section 2 ###### #Build JSON to post json_document1 = json.dumps({'Href' : 'AppendDocument1.docx', 'ImportFormatMode' : 'KeepSourceFormatting'}) json_document2 = json.dumps({'Href' : 'AppendDocument2.docx', 'ImportFormatMode' : 'UseDestinationStyles'}) json_arr = '{\'DocumentEntries\':[' + json_document1 + ',' + json_document2 + ']}' ####### End Section 2 ###### ####### Section 3 ###### Utils.process_command(Utils(), signed_uri, 'POST', 'JSON', json_arr) ####### End Section 3 ###### ####### Section 4 ###### #build URI to download output file str_uri = 'http://api.aspose.com/v1.1/storage/file/MainDocument.docx' #sign URI signed_uri = Utils.sign(Utils(), str_uri) response_stream = Utils.process_command(Utils(),signed_uri, 'GET') Utils.save_file(Utils(),response_stream, 'MergedFile.docx') ####### End Section 4 ######