Merger

Inheritance: java.lang.Object

public class Merger

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

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(getArtifactsDir() + "LowCode.MergeDocument.SimpleMerge.docx", new String[] { getMyDir() + "Big document.docx", getMyDir() + "Tables.docx" });

 OoxmlSaveOptions ooxmlSaveOptions = new OoxmlSaveOptions();
 ooxmlSaveOptions.setPassword("Aspose.Words");
 Merger.merge(getArtifactsDir() + "LowCode.MergeDocument.SaveOptions.docx", new String[] { getMyDir() + "Big document.docx", getMyDir() + "Tables.docx" }, ooxmlSaveOptions, MergeFormatMode.KEEP_SOURCE_FORMATTING);

 Merger.merge(getArtifactsDir() + "LowCode.MergeDocument.SaveFormat.pdf", new String[] { getMyDir() + "Big document.docx", getMyDir() + "Tables.docx" }, SaveFormat.PDF, MergeFormatMode.KEEP_SOURCE_LAYOUT);

 Document doc = Merger.merge(new String[] { getMyDir() + "Big document.docx", getMyDir() + "Tables.docx" }, MergeFormatMode.MERGE_FORMATTING);
 doc.save(getArtifactsDir() + "LowCode.MergeDocument.DocumentInstance.docx");
 

Methods

MethodDescription
merge(Document[] inputDocuments, int mergeFormatMode)
merge(InputStream[] inputStreams, LoadOptions[] loadOptions, int mergeFormatMode)
merge(InputStream[] inputStreams, int mergeFormatMode)
merge(OutputStream outputStream, InputStream[] inputStreams, LoadOptions[] loadOptions, SaveOptions saveOptions, int mergeFormatMode)
merge(OutputStream outputStream, InputStream[] inputStreams, SaveOptions saveOptions, int mergeFormatMode)
merge(OutputStream outputStream, InputStream[] inputStreams, int saveFormat)
merge(String outputFile, String[] inputFiles)Merges the given input documents into a single output document using specified input and output file names.
merge(String outputFile, String[] inputFiles, LoadOptions[] loadOptions, SaveOptions saveOptions, int mergeFormatMode)
merge(String outputFile, String[] inputFiles, SaveOptions saveOptions, int mergeFormatMode)
merge(String outputFile, String[] inputFiles, int saveFormat, int mergeFormatMode)
merge(String[] inputFiles, LoadOptions[] loadOptions, int mergeFormatMode)
merge(String[] inputFiles, int mergeFormatMode)

merge(Document[] inputDocuments, int mergeFormatMode)

public static Document merge(Document[] inputDocuments, int mergeFormatMode)

Parameters:

ParameterTypeDescription
inputDocumentsDocument[]
mergeFormatModeint

Returns: Document

merge(InputStream[] inputStreams, LoadOptions[] loadOptions, int mergeFormatMode)

public static Document merge(InputStream[] inputStreams, LoadOptions[] loadOptions, int mergeFormatMode)

Parameters:

ParameterTypeDescription
inputStreamsjava.io.InputStream[]
loadOptionsLoadOptions[]
mergeFormatModeint

Returns: Document

merge(InputStream[] inputStreams, int mergeFormatMode)

public static Document merge(InputStream[] inputStreams, int mergeFormatMode)

Parameters:

ParameterTypeDescription
inputStreamsjava.io.InputStream[]
mergeFormatModeint

Returns: Document

merge(OutputStream outputStream, InputStream[] inputStreams, LoadOptions[] loadOptions, SaveOptions saveOptions, int mergeFormatMode)

public static void merge(OutputStream outputStream, InputStream[] inputStreams, LoadOptions[] loadOptions, SaveOptions saveOptions, int mergeFormatMode)

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStream
inputStreamsjava.io.InputStream[]
loadOptionsLoadOptions[]
saveOptionsSaveOptions
mergeFormatModeint

merge(OutputStream outputStream, InputStream[] inputStreams, SaveOptions saveOptions, int mergeFormatMode)

public static void merge(OutputStream outputStream, InputStream[] inputStreams, SaveOptions saveOptions, int mergeFormatMode)

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStream
inputStreamsjava.io.InputStream[]
saveOptionsSaveOptions
mergeFormatModeint

merge(OutputStream outputStream, InputStream[] inputStreams, int saveFormat)

public static void merge(OutputStream outputStream, InputStream[] inputStreams, int saveFormat)

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStream
inputStreamsjava.io.InputStream[]
saveFormatint

merge(String outputFile, String[] inputFiles)

public static void merge(String outputFile, String[] inputFiles)

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

Remarks:

By default MergeFormatMode.KEEP_SOURCE_FORMATTING is used.

Examples:

Shows how to merge documents into a single output document.


 //There is a several ways to merge documents:
 Merger.merge(getArtifactsDir() + "LowCode.MergeDocument.SimpleMerge.docx", new String[] { getMyDir() + "Big document.docx", getMyDir() + "Tables.docx" });

 OoxmlSaveOptions ooxmlSaveOptions = new OoxmlSaveOptions();
 ooxmlSaveOptions.setPassword("Aspose.Words");
 Merger.merge(getArtifactsDir() + "LowCode.MergeDocument.SaveOptions.docx", new String[] { getMyDir() + "Big document.docx", getMyDir() + "Tables.docx" }, ooxmlSaveOptions, MergeFormatMode.KEEP_SOURCE_FORMATTING);

 Merger.merge(getArtifactsDir() + "LowCode.MergeDocument.SaveFormat.pdf", new String[] { getMyDir() + "Big document.docx", getMyDir() + "Tables.docx" }, SaveFormat.PDF, MergeFormatMode.KEEP_SOURCE_LAYOUT);

 Document doc = Merger.merge(new String[] { getMyDir() + "Big document.docx", getMyDir() + "Tables.docx" }, MergeFormatMode.MERGE_FORMATTING);
 doc.save(getArtifactsDir() + "LowCode.MergeDocument.DocumentInstance.docx");
 

Parameters:

ParameterTypeDescription
outputFilejava.lang.StringThe output file name.
inputFilesjava.lang.String[]The input file names.

merge(String outputFile, String[] inputFiles, LoadOptions[] loadOptions, SaveOptions saveOptions, int mergeFormatMode)

public static void merge(String outputFile, String[] inputFiles, LoadOptions[] loadOptions, SaveOptions saveOptions, int mergeFormatMode)

Parameters:

ParameterTypeDescription
outputFilejava.lang.String
inputFilesjava.lang.String[]
loadOptionsLoadOptions[]
saveOptionsSaveOptions
mergeFormatModeint

merge(String outputFile, String[] inputFiles, SaveOptions saveOptions, int mergeFormatMode)

public static void merge(String outputFile, String[] inputFiles, SaveOptions saveOptions, int mergeFormatMode)

Parameters:

ParameterTypeDescription
outputFilejava.lang.String
inputFilesjava.lang.String[]
saveOptionsSaveOptions
mergeFormatModeint

merge(String outputFile, String[] inputFiles, int saveFormat, int mergeFormatMode)

public static void merge(String outputFile, String[] inputFiles, int saveFormat, int mergeFormatMode)

Parameters:

ParameterTypeDescription
outputFilejava.lang.String
inputFilesjava.lang.String[]
saveFormatint
mergeFormatModeint

merge(String[] inputFiles, LoadOptions[] loadOptions, int mergeFormatMode)

public static Document merge(String[] inputFiles, LoadOptions[] loadOptions, int mergeFormatMode)

Parameters:

ParameterTypeDescription
inputFilesjava.lang.String[]
loadOptionsLoadOptions[]
mergeFormatModeint

Returns: Document

merge(String[] inputFiles, int mergeFormatMode)

public static Document merge(String[] inputFiles, int mergeFormatMode)

Parameters:

ParameterTypeDescription
inputFilesjava.lang.String[]
mergeFormatModeint

Returns: Document