Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active November 17, 2021 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/48ab872d69e0e18ad37c5cce66e4e05e to your computer and use it in GitHub Desktop.
Save aspose-cloud/48ab872d69e0e18ad37c5cce66e4e05e to your computer and use it in GitHub Desktop.
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