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
merge(Document[] inputDocuments, int mergeFormatMode)
public static Document merge(Document[] inputDocuments, int mergeFormatMode)
Parameters:
Parameter | Type | Description |
---|---|---|
inputDocuments | Document[] | |
mergeFormatMode | int |
Returns: Document
merge(InputStream[] inputStreams, LoadOptions[] loadOptions, int mergeFormatMode)
public static Document merge(InputStream[] inputStreams, LoadOptions[] loadOptions, int mergeFormatMode)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStreams | java.io.InputStream[] | |
loadOptions | LoadOptions[] | |
mergeFormatMode | int |
Returns: Document
merge(InputStream[] inputStreams, int mergeFormatMode)
public static Document merge(InputStream[] inputStreams, int mergeFormatMode)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStreams | java.io.InputStream[] | |
mergeFormatMode | int |
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:
Parameter | Type | Description |
---|---|---|
outputStream | java.io.OutputStream | |
inputStreams | java.io.InputStream[] | |
loadOptions | LoadOptions[] | |
saveOptions | SaveOptions | |
mergeFormatMode | int |
merge(OutputStream outputStream, InputStream[] inputStreams, SaveOptions saveOptions, int mergeFormatMode)
public static void merge(OutputStream outputStream, InputStream[] inputStreams, SaveOptions saveOptions, int mergeFormatMode)
Parameters:
Parameter | Type | Description |
---|---|---|
outputStream | java.io.OutputStream | |
inputStreams | java.io.InputStream[] | |
saveOptions | SaveOptions | |
mergeFormatMode | int |
merge(OutputStream outputStream, InputStream[] inputStreams, int saveFormat)
public static void merge(OutputStream outputStream, InputStream[] inputStreams, int saveFormat)
Parameters:
Parameter | Type | Description |
---|---|---|
outputStream | java.io.OutputStream | |
inputStreams | java.io.InputStream[] | |
saveFormat | int |
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:
Parameter | Type | Description |
---|---|---|
outputFile | java.lang.String | The output file name. |
inputFiles | java.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:
Parameter | Type | Description |
---|---|---|
outputFile | java.lang.String | |
inputFiles | java.lang.String[] | |
loadOptions | LoadOptions[] | |
saveOptions | SaveOptions | |
mergeFormatMode | int |
merge(String outputFile, String[] inputFiles, SaveOptions saveOptions, int mergeFormatMode)
public static void merge(String outputFile, String[] inputFiles, SaveOptions saveOptions, int mergeFormatMode)
Parameters:
Parameter | Type | Description |
---|---|---|
outputFile | java.lang.String | |
inputFiles | java.lang.String[] | |
saveOptions | SaveOptions | |
mergeFormatMode | int |
merge(String outputFile, String[] inputFiles, int saveFormat, int mergeFormatMode)
public static void merge(String outputFile, String[] inputFiles, int saveFormat, int mergeFormatMode)
Parameters:
Parameter | Type | Description |
---|---|---|
outputFile | java.lang.String | |
inputFiles | java.lang.String[] | |
saveFormat | int | |
mergeFormatMode | int |
merge(String[] inputFiles, LoadOptions[] loadOptions, int mergeFormatMode)
public static Document merge(String[] inputFiles, LoadOptions[] loadOptions, int mergeFormatMode)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFiles | java.lang.String[] | |
loadOptions | LoadOptions[] | |
mergeFormatMode | int |
Returns: Document
merge(String[] inputFiles, int mergeFormatMode)
public static Document merge(String[] inputFiles, int mergeFormatMode)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFiles | java.lang.String[] | |
mergeFormatMode | int |
Returns: Document