java.lang.Object
com.aspose.words.Merger
public abstract class Merger
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. Example:
//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");
| Method Summary | ||
|---|---|---|
static Document | merge(Document[] inputDocuments, int mergeFormatMode) | |
|
Merges the given input documents into a single document and returns |
||
static void | merge(java.lang.String outputFile, java.lang.String[] inputFiles) | |
| Merges the given input documents into a single output document using specified input and output file names. | ||
static void | merge(java.lang.String outputFile, java.lang.String[] inputFiles, SaveOptions saveOptions, int mergeFormatMode) | |
| Merges the given input documents into a single output document using specified input output file names and save options. | ||
static void | merge(java.lang.String outputFile, java.lang.String[] inputFiles, int saveFormat, int mergeFormatMode) | |
| Merges the given input documents into a single output document using specified input output file names and the final document format. | ||
static Document | merge(java.lang.String[] inputFiles, int mergeFormatMode) | |
|
Merges the given input documents into a single document and returns |
||
| Method Detail |
|---|
merge | |
public static Document merge(Document[] inputDocuments, int mergeFormatMode) throws java.lang.Exception | |
inputDocuments - The input documents.mergeFormatMode - A Example:
Shows how to merge input documents to a single document instance.
DocumentBuilder firstDoc = new DocumentBuilder();
firstDoc.getFont().setSize(16.0);
firstDoc.getFont().setColor(Color.BLUE);
firstDoc.write("Hello first word!");
DocumentBuilder secondDoc = new DocumentBuilder();
secondDoc.write("Hello second word!");
Document mergedDoc = Merger.merge(new Document[] { firstDoc.getDocument(), secondDoc.getDocument() }, MergeFormatMode.KEEP_SOURCE_LAYOUT);
Assert.assertEquals("Hello first word!\fHello second word!\f", mergedDoc.getText());merge | |
public static void merge(java.lang.String outputFile, java.lang.String[] inputFiles)
throws java.lang.Exception | |
By default
outputFile - The output file name.inputFiles - The input file names.Example:
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");merge | |
public static void merge(java.lang.String outputFile, java.lang.String[] inputFiles, SaveOptions saveOptions, int mergeFormatMode) throws java.lang.Exception | |
outputFile - The output file name.inputFiles - The input file names.saveOptions - The save options.mergeFormatMode - A Example:
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");merge | |
public static void merge(java.lang.String outputFile, java.lang.String[] inputFiles, int saveFormat, int mergeFormatMode)
throws java.lang.Exception | |
outputFile - The output file name.inputFiles - The input file names.saveFormat - A mergeFormatMode - A Example:
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");merge | |
public static Document merge(java.lang.String[] inputFiles, int mergeFormatMode) throws java.lang.Exception | |
inputFiles - The input file names.mergeFormatMode - A Example:
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");