Merger

Merger class

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

public class Merger : Processor

Methods

NameDescription
static Create()Creates new instance of the mail merger processor.
static Create(MergerContext)Creates new instance of the mail merger processor.
Execute()Execute the processor action.
From(Stream, LoadOptions)Specifies input document for processing.
From(string, LoadOptions)Specifies input document for processing.
To(List<Stream>, SaveFormat)Specifies output Document streams list.
To(List<Stream>, SaveOptions)Specifies output Document streams list.
To(Stream, SaveFormat)Specifies output stream for the processor.
To(Stream, SaveOptions)Specifies output stream for the processor.
To(string, SaveFormat)Specifies output file for the processor.
To(string, SaveOptions)Specifies output file for the processor.
static Merge(Document[], MergeFormatMode)Merges the given input documents into a single document and returns Document instance of the final document.
static Merge(Stream[], MergeFormatMode)Merges the given input documents into a single document and returns Document instance of the final document.
static Merge(string, string[])Merges the given input documents into a single output document using specified input and output file names using KeepSourceFormatting.
static Merge(string[], MergeFormatMode)Merges the given input documents into a single document and returns Document instance of the final document.
static Merge(Stream, Stream[], SaveFormat)Merges the given input documents into a single output document using specified input output streams and the final document format.
static Merge(Stream[], LoadOptions[], MergeFormatMode)Merges the given input documents into a single document and returns Document instance of the final document.
static Merge(string[], LoadOptions[], MergeFormatMode)Merges the given input documents into a single document and returns Document instance of the final document.
static Merge(Stream, Stream[], SaveOptionsMergeFormatMode)Merges the given input documents into a single output document using specified input output streams and save options.
static Merge(string, string[], SaveFormatMergeFormatMode)Merges the given input documents into a single output document using specified input output file names and the final document format.
static Merge(string, string[], SaveOptionsMergeFormatMode)Merges the given input documents into a single output document using specified input output file names and save options.
static Merge(Stream, Stream[], LoadOptions[], SaveOptionsMergeFormatMode)Merges the given input documents into a single output document using specified input output streams and save options.
static Merge(string, string[], LoadOptions[], SaveOptionsMergeFormatMode)Merges the given input documents into a single output document using specified input output file names and save options.
static MergeToImages(Stream[], ImageSaveOptionsMergeFormatMode)Merges the given input document streams into a single output document using specified image save options. Renders the output to images.
static MergeToImages(string[], ImageSaveOptionsMergeFormatMode)Merges the given input documents into a single output document using specified input output file names and save options. Renders the output to images.

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.

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");

See Also