Merge

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.

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


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.

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


Merge(string, string[], SaveOptionsMergeFormatMode)

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)
ParameterTypeDescription
outputFileStringThe output file name.
inputFilesString[]The input file names.
saveOptionsSaveOptionsThe save options.
mergeFormatModeMergeFormatModeSpecifies 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:
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


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

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)
ParameterTypeDescription
outputFileStringThe output file name.
inputFilesString[]The input file names.
loadOptionsLoadOptions[]Load options for the input files.
saveOptionsSaveOptionsThe save options.
mergeFormatModeMergeFormatModeSpecifies how to merge formatting that clashes.

See Also


Merge(string[], MergeFormatMode)

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

public static Document Merge(string[] inputFiles, MergeFormatMode mergeFormatMode)
ParameterTypeDescription
inputFilesString[]The input file names.
mergeFormatModeMergeFormatModeSpecifies 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:
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


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

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

public static Document Merge(string[] inputFiles, LoadOptions[] loadOptions, 
    MergeFormatMode mergeFormatMode)
ParameterTypeDescription
inputFilesString[]The input file names.
loadOptionsLoadOptions[]Load options for the input files.
mergeFormatModeMergeFormatModeSpecifies how to merge formatting that clashes.

See Also


Merge(Document[], MergeFormatMode)

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

public static Document Merge(Document[] inputDocuments, MergeFormatMode mergeFormatMode)
ParameterTypeDescription
inputDocumentsDocument[]The input documents.
mergeFormatModeMergeFormatModeSpecifies how to merge formatting that clashes.

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.AreEqual("Hello first word!\fHello second word!\f", mergedDoc.GetText());

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.

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.SaveOptions.docx", FileMode.Create, FileAccess.ReadWrite))
            Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, saveOptions, MergeFormatMode.KeepSourceFormatting);

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

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

See Also


Merge(Stream, Stream[], SaveOptionsMergeFormatMode)

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)
ParameterTypeDescription
outputStreamStreamThe output stream.
inputStreamsStream[]The input streams.
saveOptionsSaveOptionsThe save options.
mergeFormatModeMergeFormatModeSpecifies 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.SaveOptions.docx", FileMode.Create, FileAccess.ReadWrite))
            Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, saveOptions, MergeFormatMode.KeepSourceFormatting);

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

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

See Also


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

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)
ParameterTypeDescription
outputStreamStreamThe output stream.
inputStreamsStream[]The input streams.
loadOptionsLoadOptions[]Load options for the input files.
saveOptionsSaveOptionsThe save options.
mergeFormatModeMergeFormatModeSpecifies how to merge formatting that clashes.

See Also


Merge(Stream[], MergeFormatMode)

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

public static Document Merge(Stream[] inputStreams, MergeFormatMode mergeFormatMode)
ParameterTypeDescription
inputStreamsStream[]The input streams.
mergeFormatModeMergeFormatModeSpecifies 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.SaveOptions.docx", FileMode.Create, FileAccess.ReadWrite))
            Merger.Merge(streamOut, new[] { firstStreamIn, secondStreamIn }, saveOptions, MergeFormatMode.KeepSourceFormatting);

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

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

See Also


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

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

public static Document Merge(Stream[] inputStreams, LoadOptions[] loadOptions, 
    MergeFormatMode mergeFormatMode)
ParameterTypeDescription
inputStreamsStream[]The input streams.
loadOptionsLoadOptions[]Load options for the input files.
mergeFormatModeMergeFormatModeSpecifies how to merge formatting that clashes.

See Also