merge_streams method
merge_streams(output_stream, input_streams, save_format)
Merges the given input documents into a single output document using specified input output streams and the final document format.
def merge_streams(self, output_stream: io.BytesIO, input_streams: List[io.BytesIO], save_format: aspose.words.SaveFormat):
...
| Parameter | Type | Description |
|---|---|---|
| output_stream | io.BytesIO | The output stream. |
| input_streams | List[io.BytesIO] | The input streams. |
| save_format | SaveFormat | The save format. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
merge_streams(output_stream, input_streams, save_options, merge_format_mode)
Merges the given input documents into a single output document using specified input output streams and save options.
def merge_streams(self, output_stream: io.BytesIO, input_streams: List[io.BytesIO], save_options: aspose.words.saving.SaveOptions, merge_format_mode: aspose.words.lowcode.MergeFormatMode):
...
| Parameter | Type | Description |
|---|---|---|
| output_stream | io.BytesIO | The output stream. |
| input_streams | List[io.BytesIO] | The input streams. |
| save_options | SaveOptions | The save options. |
| merge_format_mode | MergeFormatMode | Specifies how to merge formatting that clashes. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
merge_streams(output_stream, input_streams, load_options, save_options, merge_format_mode)
Merges the given input documents into a single output document using specified input output streams and save options.
def merge_streams(self, output_stream: io.BytesIO, input_streams: List[io.BytesIO], load_options: List[aspose.words.loading.LoadOptions], save_options: aspose.words.saving.SaveOptions, merge_format_mode: aspose.words.lowcode.MergeFormatMode):
...
| Parameter | Type | Description |
|---|---|---|
| output_stream | io.BytesIO | The output stream. |
| input_streams | List[io.BytesIO] | The input streams. |
| load_options | List[LoadOptions] | Load options for the input files. |
| save_options | SaveOptions | The save options. |
| merge_format_mode | MergeFormatMode | Specifies how to merge formatting that clashes. |
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
merge_streams(input_streams, merge_format_mode)
Merges the given input documents into a single document and returns Document instance of the final document.
def merge_streams(self, input_streams: List[io.BytesIO], merge_format_mode: aspose.words.lowcode.MergeFormatMode):
...
| Parameter | Type | Description |
|---|---|---|
| input_streams | List[io.BytesIO] | The input streams. |
| merge_format_mode | MergeFormatMode | Specifies how to merge formatting that clashes. |
merge_streams(input_streams, load_options, merge_format_mode)
Merges the given input documents into a single document and returns Document instance of the final document.
def merge_streams(self, input_streams: List[io.BytesIO], load_options: List[aspose.words.loading.LoadOptions], merge_format_mode: aspose.words.lowcode.MergeFormatMode):
...
| Parameter | Type | Description |
|---|---|---|
| input_streams | List[io.BytesIO] | The input streams. |
| load_options | List[LoadOptions] | Load options for the input files. |
| merge_format_mode | MergeFormatMode | Specifies how to merge formatting that clashes. |
Examples
Shows how to merge documents from stream into a single output document.
#There is a several ways to merge documents from stream:
with system_helper.io.FileStream(MY_DIR + 'Big document.docx', system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as first_stream_in:
with system_helper.io.FileStream(MY_DIR + 'Tables.docx', system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as second_stream_in:
save_options = aw.saving.OoxmlSaveOptions()
save_options.password = 'Aspose.Words'
with system_helper.io.FileStream(ARTIFACTS_DIR + 'LowCode.MergeStreamDocument.1.docx', system_helper.io.FileMode.CREATE, system_helper.io.FileAccess.READ_WRITE) as stream_out:
aw.lowcode.Merger.merge_streams(output_stream=stream_out, input_streams=[first_stream_in, second_stream_in], save_options=save_options, merge_format_mode=aw.lowcode.MergeFormatMode.KEEP_SOURCE_FORMATTING)
with system_helper.io.FileStream(ARTIFACTS_DIR + 'LowCode.MergeStreamDocument.2.docx', system_helper.io.FileMode.CREATE, system_helper.io.FileAccess.READ_WRITE) as stream_out:
aw.lowcode.Merger.merge_streams(output_stream=stream_out, input_streams=[first_stream_in, second_stream_in], save_format=aw.SaveFormat.DOCX)
first_load_options = aw.loading.LoadOptions()
first_load_options.ignore_ole_data = True
second_load_options = aw.loading.LoadOptions()
second_load_options.ignore_ole_data = False
with system_helper.io.FileStream(ARTIFACTS_DIR + 'LowCode.MergeStreamDocument.3.docx', system_helper.io.FileMode.CREATE, system_helper.io.FileAccess.READ_WRITE) as stream_out:
aw.lowcode.Merger.merge_streams(output_stream=stream_out, input_streams=[first_stream_in, second_stream_in], load_options=[first_load_options, second_load_options], save_options=save_options, merge_format_mode=aw.lowcode.MergeFormatMode.KEEP_SOURCE_FORMATTING)
first_doc = aw.lowcode.Merger.merge_streams(input_streams=[first_stream_in, second_stream_in], merge_format_mode=aw.lowcode.MergeFormatMode.MERGE_FORMATTING)
first_doc.save(file_name=ARTIFACTS_DIR + 'LowCode.MergeStreamDocument.4.docx')
second_doc = aw.lowcode.Merger.merge_streams(input_streams=[first_stream_in, second_stream_in], load_options=[first_load_options, second_load_options], merge_format_mode=aw.lowcode.MergeFormatMode.MERGE_FORMATTING)
second_doc.save(file_name=ARTIFACTS_DIR + 'LowCode.MergeStreamDocument.5.docx')
See Also
- module aspose.words.lowcode
- class Merger