Merger.Merge

Merger Merge method. Merges the given input documents into a single output document using specified input and output file names.

Merge(string, string[])

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

public static void Merge(string outputFile, string[] inputFiles)
ParameterTypeDescription
outputFileStringThe output file name.
inputFilesString[]The input file names.

Remarks

By default KeepSourceFormatting is used.

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.

Examples

Shows how to merge several PDF document into one document keeping original document layout.

string outputFileName = ArtifactsDir + "Merger.Merge.pdf";
string[] inputFiles = new string[] { MyDir + "Merger.pdf", MyDir + "Merger1.pdf", MyDir + "Merger2.pdf" };

Merger.Merge(outputFileName, inputFiles);

See Also


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.

public static void Merge(string outputFile, string[] inputFiles, SaveFormat saveFormat, 
    MergeFormatMode mergeFormatMode)
ParameterTypeDescription
outputFileStringThe output file name.
inputFilesString[]The input file names.
saveFormatSaveFormatThe save format.
mergeFormatModeMergeFormatModeSpecifies how to merge formatting that clashes.

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.

Examples

Shows how to merge several document into one document with specified merge format mode.

string outputFileName = ArtifactsDir + "Merger.Merge.docx";
string[] inputFiles = new string[] { MyDir + "Merger.docx", MyDir + "Merger.doc", MyDir + "Merger.rtf" };

Merger.Merge(outputFileName, inputFiles, SaveFormat.Docx, MergeFormatMode.KeepSourceLayout);

See Also


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)
ParameterTypeDescription
outputStreamStreamThe output stream.
inputStreamsStream[]The input streams.
saveFormatSaveFormatThe 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.

Examples

Shows how to merge several document into one document using streams.

Stream[] inputStreams = new Stream[]
{
    new MemoryStream(File.ReadAllBytes(MyDir + "Merger.docx")),
    new MemoryStream(File.ReadAllBytes(MyDir + "Merger.doc")),
    new MemoryStream(File.ReadAllBytes(MyDir + "Merger.rtf"))
};

using (Stream output = File.Create(ArtifactsDir + "Merger.MergeStreams.docx"))
    Merger.Merge(output, inputStreams, SaveFormat.Docx);

See Also


Merge(Stream, Stream[], SaveFormatMergeFormatMode)

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, 
    MergeFormatMode mergeFormatMode)
ParameterTypeDescription
outputStreamStreamThe output stream.
inputStreamsStream[]The input streams.
saveFormatSaveFormatThe save format.
mergeFormatModeMergeFormatModeSpecifies 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.

Examples

Shows how to merge several document into one document using streams with specifying merge format mode.

Stream[] inputStreams = new Stream[]
{
    new MemoryStream(File.ReadAllBytes(MyDir + "Merger.docx")),
    new MemoryStream(File.ReadAllBytes(MyDir + "Merger.doc")),
    new MemoryStream(File.ReadAllBytes(MyDir + "Merger.rtf"))
};

using (Stream output = File.Create(ArtifactsDir + "Merger.MergeStreams.Mode.docx"))
    Merger.Merge(output, inputStreams, SaveFormat.Docx, MergeFormatMode.MergeFormatting);

See Also