split method

split(input_file_name, output_file_name, options)

Splits a document into multiple parts based on the specified split options and saves the resulting parts to files. The output file format is determined by the extension of the output file name.

def split(self, input_file_name: str, output_file_name: str, options: aspose.words.lowcode.splitting.SplitOptions):
    ...
ParameterTypeDescription
input_file_namestrThe input file name.
output_file_namestrThe output file name used to generate file name for document parts using rule “outputFile_partIndex.extension”
optionsSplitOptionsDocument split options.

split(input_file_name, output_file_name, save_format, options)

Splits a document into multiple parts based on the specified split options and saves the resulting parts to files in the specified save format.

def split(self, input_file_name: str, output_file_name: str, save_format: aspose.words.SaveFormat, options: aspose.words.lowcode.splitting.SplitOptions):
    ...
ParameterTypeDescription
input_file_namestrThe input file name.
output_file_namestrThe output file name used to generate file name for document parts using rule “outputFile_partIndex.extension”
save_formatSaveFormatThe save format.
optionsSplitOptionsDocument split options.

split(input_stream, save_format, options)

Splits a document from an input stream into multiple parts based on the specified split options and returns the resulting parts as an array of streams in the specified save format.

def split(self, input_stream: io.BytesIO, save_format: aspose.words.SaveFormat, options: aspose.words.lowcode.splitting.SplitOptions):
    ...
ParameterTypeDescription
input_streamio.BytesIOThe input stream.
save_formatSaveFormatThe save format.
optionsSplitOptionsDocument split options.

Examples

Shows how to split document by pages.

doc = MY_DIR + 'Big document.docx'
options = aw.lowcode.splitting.SplitOptions()
options.split_criteria = aw.lowcode.splitting.SplitCriteria.PAGE
aw.lowcode.Splitter.split(input_file_name=doc, output_file_name=ARTIFACTS_DIR + 'LowCode.SplitDocument.1.docx', options=options)
aw.lowcode.Splitter.split(input_file_name=doc, output_file_name=ARTIFACTS_DIR + 'LowCode.SplitDocument.2.docx', save_format=aw.SaveFormat.DOCX, options=options)

Shows how to split document from the stream by pages.

with system_helper.io.FileStream(MY_DIR + 'Big document.docx', system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as stream_in:
    options = aw.lowcode.splitting.SplitOptions()
    options.split_criteria = aw.lowcode.splitting.SplitCriteria.PAGE
    stream = aw.lowcode.Splitter.split(input_stream=stream_in, save_format=aw.SaveFormat.DOCX, options=options)

See Also