Class Merger

Class Merger

Namespace: Aspose.Words.LowCode
Assembly: Aspose.Words.dll (26.2.0)

Represents a group of methods intended to merge a variety of different types of documents into a single output document.

public class Merger : Processor

Inheritance

object Processor Merger

Inherited Members

Processor.mResultDocument , Processor.From(string) , Processor.From(string, LoadOptions) , Processor.From(Stream) , Processor.From(Stream, LoadOptions) , Processor.To(string) , Processor.To(string, SaveOptions) , Processor.To(string, SaveFormat) , Processor.To(Stream, SaveOptions) , Processor.To(Stream, SaveFormat) , Processor.To(List<Stream>, SaveOptions) , Processor.To(List<Stream>, SaveFormat) , Processor.Execute() , Processor.Execute(CancellationToken) , Processor.ExecuteCore() , Processor.CheckArgumentsSet() , Processor.GetPartFileName(string, int, SaveFormat) , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Shows how to merge documents into a single output document.

//There is a several ways to merge documents:
                                                                      string inputDoc1 = MyDir + "Big document.docx";
                                                                      string inputDoc2 = MyDir + "Tables.docx";

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.1.docx", new[] { inputDoc1, inputDoc2 });

                                                                      OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.2.docx", new[] { inputDoc1, inputDoc2 }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.3.pdf", new[] { inputDoc1, inputDoc2 }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

                                                                      LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                      LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.4.docx", new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Document doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.5.docx");

                                                                      doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.6.docx");

Remarks

The specified input and output files or streams, along with the desired merge and save options, are used to merge the given input documents into a single output document.

The merging functionality supports over 35 different file formats.

Methods

Create()

Creates new instance of the mail merger processor.

public static Merger Create()

Returns

Merger

Create(MergerContext)

Creates new instance of the mail merger processor.

public static Merger Create(MergerContext context)

Parameters

context MergerContext

Returns

Merger

Examples

Shows how to merge documents into a single output document using context.

//There is a several ways to merge documents:
                                                                                    string inputDoc1 = MyDir + "Big document.docx";
                                                                                    string inputDoc2 = MyDir + "Tables.docx";

                                                                                    Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
                                                                                        .From(inputDoc1)
                                                                                        .From(inputDoc2)
                                                                                        .To(ArtifactsDir + "LowCode.MergeContextDocuments.1.docx")
                                                                                        .Execute();

                                                                                    LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                                    LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                                    Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
                                                                                        .From(inputDoc1, firstLoadOptions)
                                                                                        .From(inputDoc2, secondLoadOptions)
                                                                                        .To(ArtifactsDir + "LowCode.MergeContextDocuments.2.docx", SaveFormat.Docx)
                                                                                        .Execute();

                                                                                    OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                                    Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
                                                                                        .From(inputDoc1)
                                                                                        .From(inputDoc2)
                                                                                        .To(ArtifactsDir + "LowCode.MergeContextDocuments.3.docx", saveOptions)
                                                                                        .Execute();

Shows how to merge documents from stream into a single output document using context.

//There is a several ways to merge documents:
                                                                                                string inputDoc1 = MyDir + "Big document.docx";
                                                                                                string inputDoc2 = MyDir + "Tables.docx";

                                                                                                using (FileStream firstStreamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
                                                                                                {
                                                                                                    using (FileStream secondStreamIn = new FileStream(MyDir + "Tables.docx", FileMode.Open, FileAccess.Read))
                                                                                                    {
                                                                                                        OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                                                        using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamContextDocuments.1.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                                            Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
                                                                                                            .From(firstStreamIn)
                                                                                                            .From(secondStreamIn)
                                                                                                            .To(streamOut, saveOptions)
                                                                                                            .Execute();

                                                                                                        LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                                                        LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                                                        using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamContextDocuments.2.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                                            Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
                                                                                                            .From(firstStreamIn, firstLoadOptions)
                                                                                                            .From(secondStreamIn, secondLoadOptions)
                                                                                                            .To(streamOut, SaveFormat.Docx)
                                                                                                            .Execute();
                                                                                                    }
                                                                                                }

ExecuteCore()

protected override void ExecuteCore()

Merge(string, string[])

Merges the given input documents into a single output document using specified input and output file names using Aspose.Words.LowCode.MergeFormatMode.KeepSourceFormatting.

public static void Merge(string outputFile, string[] inputFiles)

Parameters

outputFile string

The output file name.

inputFiles string []

The input file names.

Examples

Shows how to merge documents into a single output document.

//There is a several ways to merge documents:
                                                                      string inputDoc1 = MyDir + "Big document.docx";
                                                                      string inputDoc2 = MyDir + "Tables.docx";

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.1.docx", new[] { inputDoc1, inputDoc2 });

                                                                      OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.2.docx", new[] { inputDoc1, inputDoc2 }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.3.pdf", new[] { inputDoc1, inputDoc2 }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

                                                                      LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                      LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.4.docx", new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Document doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.5.docx");

                                                                      doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.6.docx");

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Merge(string, string[], SaveFormat, MergeFormatMode)

Merges the given input documents into a single output document using specified input output file names and the final document format.

public static void Merge(string outputFile, string[] inputFiles, SaveFormat saveFormat, MergeFormatMode mergeFormatMode)

Parameters

outputFile string

The output file name.

inputFiles string []

The input file names.

saveFormat SaveFormat

The save format.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Examples

Shows how to merge documents into a single output document.

//There is a several ways to merge documents:
                                                                      string inputDoc1 = MyDir + "Big document.docx";
                                                                      string inputDoc2 = MyDir + "Tables.docx";

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.1.docx", new[] { inputDoc1, inputDoc2 });

                                                                      OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.2.docx", new[] { inputDoc1, inputDoc2 }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.3.pdf", new[] { inputDoc1, inputDoc2 }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

                                                                      LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                      LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.4.docx", new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Document doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.5.docx");

                                                                      doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.6.docx");

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Merge(string, string[], SaveOptions, MergeFormatMode)

Merges the given input documents into a single output document using specified input output file names and save options.

public static void Merge(string outputFile, string[] inputFiles, SaveOptions saveOptions, MergeFormatMode mergeFormatMode)

Parameters

outputFile string

The output file name.

inputFiles string []

The input file names.

saveOptions SaveOptions

The save options.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Examples

Shows how to merge documents into a single output document.

//There is a several ways to merge documents:
                                                                      string inputDoc1 = MyDir + "Big document.docx";
                                                                      string inputDoc2 = MyDir + "Tables.docx";

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.1.docx", new[] { inputDoc1, inputDoc2 });

                                                                      OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.2.docx", new[] { inputDoc1, inputDoc2 }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.3.pdf", new[] { inputDoc1, inputDoc2 }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

                                                                      LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                      LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.4.docx", new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Document doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.5.docx");

                                                                      doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.6.docx");

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Merge(string, string[], LoadOptions[], SaveOptions, MergeFormatMode)

Merges the given input documents into a single output document using specified input output file names and save options.

public static void Merge(string outputFile, string[] inputFiles, LoadOptions[] loadOptions, SaveOptions saveOptions, MergeFormatMode mergeFormatMode)

Parameters

outputFile string

The output file name.

inputFiles string []

The input file names.

loadOptions LoadOptions []

Load options for the input files.

saveOptions SaveOptions

The save options.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Examples

Shows how to merge documents into a single output document.

//There is a several ways to merge documents:
                                                                      string inputDoc1 = MyDir + "Big document.docx";
                                                                      string inputDoc2 = MyDir + "Tables.docx";

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.1.docx", new[] { inputDoc1, inputDoc2 });

                                                                      OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.2.docx", new[] { inputDoc1, inputDoc2 }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.3.pdf", new[] { inputDoc1, inputDoc2 }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

                                                                      LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                      LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.4.docx", new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Document doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.5.docx");

                                                                      doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.6.docx");

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Merge(string[], MergeFormatMode)

Merges the given input documents into a single document and returns Aspose.Words.Document instance of the final document.

public static Document Merge(string[] inputFiles, MergeFormatMode mergeFormatMode)

Parameters

inputFiles string []

The input file names.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Returns

Document

Examples

Shows how to merge documents into a single output document.

//There is a several ways to merge documents:
                                                                      string inputDoc1 = MyDir + "Big document.docx";
                                                                      string inputDoc2 = MyDir + "Tables.docx";

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.1.docx", new[] { inputDoc1, inputDoc2 });

                                                                      OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.2.docx", new[] { inputDoc1, inputDoc2 }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.3.pdf", new[] { inputDoc1, inputDoc2 }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

                                                                      LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                      LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.4.docx", new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Document doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.5.docx");

                                                                      doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.6.docx");

Merge(string[], LoadOptions[], MergeFormatMode)

Merges the given input documents into a single document and returns Aspose.Words.Document instance of the final document.

public static Document Merge(string[] inputFiles, LoadOptions[] loadOptions, MergeFormatMode mergeFormatMode)

Parameters

inputFiles string []

The input file names.

loadOptions LoadOptions []

Load options for the input files.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Returns

Document

Examples

Shows how to merge documents into a single output document.

//There is a several ways to merge documents:
                                                                      string inputDoc1 = MyDir + "Big document.docx";
                                                                      string inputDoc2 = MyDir + "Tables.docx";

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.1.docx", new[] { inputDoc1, inputDoc2 });

                                                                      OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.2.docx", new[] { inputDoc1, inputDoc2 }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.3.pdf", new[] { inputDoc1, inputDoc2 }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

                                                                      LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                      LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                      Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.4.docx", new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                      Document doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.5.docx");

                                                                      doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                      doc.Save(ArtifactsDir + "LowCode.MergeDocument.6.docx");

Merge(Document[], MergeFormatMode)

Merges the given input documents into a single document and returns Aspose.Words.Document instance of the final document.

public static Document Merge(Document[] inputDocuments, MergeFormatMode mergeFormatMode)

Parameters

inputDocuments Document []

The input documents.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Returns

Document

Examples

Shows how to merge input documents to a single document instance.

DocumentBuilder firstDoc = new DocumentBuilder();
                                                                            firstDoc.Font.Size = 16;
                                                                            firstDoc.Font.Color = Color.Blue;
                                                                            firstDoc.Write("Hello first word!");

                                                                            DocumentBuilder secondDoc = new DocumentBuilder();
                                                                            secondDoc.Write("Hello second word!");

                                                                            Document mergedDoc = Merger.Merge(new Document[] { firstDoc.Document, secondDoc.Document }, MergeFormatMode.KeepSourceLayout);
                                                                            Assert.That(mergedDoc.GetText(), Is.EqualTo("Hello first word!\fHello second word!\f"));

Merge(Stream, Stream[], SaveFormat)

Merges the given input documents into a single output document using specified input output streams and the final document format.

public static void Merge(Stream outputStream, Stream[] inputStreams, SaveFormat saveFormat)

Parameters

outputStream Stream

The output stream.

inputStreams Stream []

The input streams.

saveFormat SaveFormat

The save format.

Examples

Shows how to merge documents from stream into a single output document.

//There is a several ways to merge documents from stream:
                                                                                  using (FileStream firstStreamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
                                                                                  {
                                                                                      using (FileStream secondStreamIn = new FileStream(MyDir + "Tables.docx", FileMode.Open, FileAccess.Read))
                                                                                      {
                                                                                          OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.1.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.2.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, SaveFormat.Docx);

                                                                                          LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                                          LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.3.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          Document firstDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, MergeFormatMode.MergeFormatting);
                                                                                          firstDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.4.docx");

                                                                                          Document secondDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                                          secondDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.5.docx");
                                                                                      }
                                                                                  }

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(Stream, Stream[], SaveOptions, MergeFormatMode)

Merges the given input documents into a single output document using specified input output streams and save options.

public static void Merge(Stream outputStream, Stream[] inputStreams, SaveOptions saveOptions, MergeFormatMode mergeFormatMode)

Parameters

outputStream Stream

The output stream.

inputStreams Stream []

The input streams.

saveOptions SaveOptions

The save options.

mergeFormatMode 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:
                                                                                  using (FileStream firstStreamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
                                                                                  {
                                                                                      using (FileStream secondStreamIn = new FileStream(MyDir + "Tables.docx", FileMode.Open, FileAccess.Read))
                                                                                      {
                                                                                          OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.1.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.2.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, SaveFormat.Docx);

                                                                                          LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                                          LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.3.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          Document firstDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, MergeFormatMode.MergeFormatting);
                                                                                          firstDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.4.docx");

                                                                                          Document secondDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                                          secondDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.5.docx");
                                                                                      }
                                                                                  }

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(Stream, Stream[], LoadOptions[], SaveOptions, MergeFormatMode)

Merges the given input documents into a single output document using specified input output streams and save options.

public static void Merge(Stream outputStream, Stream[] inputStreams, LoadOptions[] loadOptions, SaveOptions saveOptions, MergeFormatMode mergeFormatMode)

Parameters

outputStream Stream

The output stream.

inputStreams Stream []

The input streams.

loadOptions LoadOptions []

Load options for the input files.

saveOptions SaveOptions

The save options.

mergeFormatMode 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:
                                                                                  using (FileStream firstStreamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
                                                                                  {
                                                                                      using (FileStream secondStreamIn = new FileStream(MyDir + "Tables.docx", FileMode.Open, FileAccess.Read))
                                                                                      {
                                                                                          OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.1.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.2.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, SaveFormat.Docx);

                                                                                          LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                                          LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.3.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          Document firstDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, MergeFormatMode.MergeFormatting);
                                                                                          firstDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.4.docx");

                                                                                          Document secondDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                                          secondDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.5.docx");
                                                                                      }
                                                                                  }

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(Stream[], MergeFormatMode)

Merges the given input documents into a single document and returns Aspose.Words.Document instance of the final document.

public static Document Merge(Stream[] inputStreams, MergeFormatMode mergeFormatMode)

Parameters

inputStreams Stream []

The input streams.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Returns

Document

Examples

Shows how to merge documents from stream into a single output document.

//There is a several ways to merge documents from stream:
                                                                                  using (FileStream firstStreamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
                                                                                  {
                                                                                      using (FileStream secondStreamIn = new FileStream(MyDir + "Tables.docx", FileMode.Open, FileAccess.Read))
                                                                                      {
                                                                                          OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.1.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.2.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, SaveFormat.Docx);

                                                                                          LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                                          LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.3.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          Document firstDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, MergeFormatMode.MergeFormatting);
                                                                                          firstDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.4.docx");

                                                                                          Document secondDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                                          secondDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.5.docx");
                                                                                      }
                                                                                  }

Merge(Stream[], LoadOptions[], MergeFormatMode)

Merges the given input documents into a single document and returns Aspose.Words.Document instance of the final document.

public static Document Merge(Stream[] inputStreams, LoadOptions[] loadOptions, MergeFormatMode mergeFormatMode)

Parameters

inputStreams Stream []

The input streams.

loadOptions LoadOptions []

Load options for the input files.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Returns

Document

Examples

Shows how to merge documents from stream into a single output document.

//There is a several ways to merge documents from stream:
                                                                                  using (FileStream firstStreamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
                                                                                  {
                                                                                      using (FileStream secondStreamIn = new FileStream(MyDir + "Tables.docx", FileMode.Open, FileAccess.Read))
                                                                                      {
                                                                                          OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.1.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.2.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, SaveFormat.Docx);

                                                                                          LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
                                                                                          LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
                                                                                          using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamDocument.3.docx", FileMode.Create, FileAccess.ReadWrite))
                                                                                              Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

                                                                                          Document firstDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, MergeFormatMode.MergeFormatting);
                                                                                          firstDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.4.docx");

                                                                                          Document secondDoc = Merger.Merge(new[] { firstStreamIn, secondStreamIn }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
                                                                                          secondDoc.Save(ArtifactsDir + "LowCode.MergeStreamDocument.5.docx");
                                                                                      }
                                                                                  }

MergeToImages(string[], ImageSaveOptions, MergeFormatMode)

Merges the given input documents into a single output document using specified input output file names and save options. Renders the output to images.

public static Stream[] MergeToImages(string[] inputFiles, ImageSaveOptions saveOptions, MergeFormatMode mergeFormatMode)

Parameters

inputFiles string []

The input file names.

saveOptions ImageSaveOptions

The save options.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Returns

Stream []

MergeToImages(Stream[], ImageSaveOptions, MergeFormatMode)

Merges the given input document streams into a single output document using specified image save options. Renders the output to images.

public static Stream[] MergeToImages(Stream[] inputStreams, ImageSaveOptions saveOptions, MergeFormatMode mergeFormatMode)

Parameters

inputStreams Stream []

The input file streams.

saveOptions ImageSaveOptions

The save options.

mergeFormatMode MergeFormatMode

Specifies how to merge formatting that clashes.

Returns

Stream []

 English