Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This Gist contains code snippets related to splitting Word document into individual page documents using Aspose.Words Cloud SDK for Python
This Gist contains code snippets related to splitting Word document into individual page documents using Aspose.Words Cloud SDK for Python
try:
# create an instance of WordsApi
words_api = WordsApi("88d1cda8-b12c-4a80-b1ad-c85ac483c5c5","406b404b2df649611e508bbcfcd2a77f")
# Name of input word document
inputFileName = 'source.doc'
# resultant file format
resultantFormat = 'DOCX'
# Name of resultant document after the operation. If this parameter is omitted
# then resultant file will be saved with the name of input document
resultantFile = 'SplitOutput'
# The flag indicating output shall be in ZIP archive.
zipOutput = 'false'
# Upload source Word document to Cloud Storage
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open('C:\\Users\\Downloads\\'+inputFileName, 'rb'), "", None))
# Create an object to Split Document
request = asposewordscloud.models.requests.SplitDocumentRequest(inputFileName, resultantFormat, None, None, None,
None, resultantFile,pageFrom, pageTo, zipOutput, None)
# initiate Word Split operation
result = words_api.split_document(request)
# print message in console (optional)
print('Document Split process completed successfully !')
except ApiException as e:
print("Exception while calling WordsApi: {0}".format(e))
try:
# create an instance of WordsApi
words_api = WordsApi("88d1cda8-b12c-4a80-b1ad-c85ac483c5c5","406b404b2df649611e508bbcfcd2a77f")
# Name of input word document
inputFileName = 'source.doc'
# resultant file format
resultantFormat = 'DOCX'
# Name of resultant document after the operation. If this parameter is omitted
# then resultant file will be saved with the name of input document
resultantFile = 'Split-File'
# The flag indicating whether to ZIP the output.
zipOutput = 'false'
# Upload source Word document to Cloud Storage
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open('C:\\Users\\Downloads\\'+inputFileName, 'rb'), "", None))
# Create an object to Split Document
request = asposewordscloud.models.requests.SplitDocumentRequest(inputFileName, resultantFormat, None, None, None,
None, resultantFile,None, None, zipOutput, None)
# initiate Word Split operation
result = words_api.split_document(request)
# print message in console (optional)
print('Document Split process completed successfully !')
except ApiException as e:
print("Exception while calling WordsApi: {0}".format(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment