Merger

Merger class

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

public static class Merger

Methods

NameDescription
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.
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.

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:
Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.SimpleMerge.docx", new[] { MyDir + "Big document.docx", MyDir + "Tables.docx" });

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.SaveOptions.docx", new[] { MyDir + "Big document.docx", MyDir + "Tables.docx" }, saveOptions, MergeFormatMode.KeepSourceFormatting);

Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.SaveFormat.pdf", new[] { MyDir + "Big document.docx", MyDir + "Tables.docx" }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

Document doc = Merger.Merge(new[] { MyDir + "Big document.docx", MyDir + "Tables.docx" }, MergeFormatMode.MergeFormatting);
doc.Save(ArtifactsDir + "LowCode.MergeDocument.DocumentInstance.docx");

See Also