MergeFormatMode

Inheritance: java.lang.Object

public class MergeFormatMode

Specifies how formatting is merged when combining multiple documents.

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");
 

Fields

FieldDescription
KEEP_SOURCE_FORMATTINGMeans that the source document will retain its original formatting, such as font styles, sizes, colors, indents, and any other formatting elements applied to its content.
KEEP_SOURCE_LAYOUTPreserve the layout of the original documents in the final document.
MERGE_FORMATTINGCombine the formatting of the merged documents.
length

Methods

MethodDescription
fromName(String mergeFormatModeName)
getName(int mergeFormatMode)
getValues()
toString(int mergeFormatMode)

KEEP_SOURCE_FORMATTING

public static int KEEP_SOURCE_FORMATTING

Means that the source document will retain its original formatting, such as font styles, sizes, colors, indents, and any other formatting elements applied to its content.

Remarks:

By using this option, you ensure that the copied content appears as it did in the original source, regardless of the formatting settings of the first document in merge queue.

This option does not have any affect when the input and the output formats are PDF.

KEEP_SOURCE_LAYOUT

public static int KEEP_SOURCE_LAYOUT

Preserve the layout of the original documents in the final document.

Remarks:

In general, it looks like you print out the original documents and manually adhere them together using glue.

MERGE_FORMATTING

public static int MERGE_FORMATTING

Combine the formatting of the merged documents.

Remarks:

By using this option, Aspose.Words adapts the formatting of the first document to match the structure and appearance of the second document, but keeps some of the original formatting intact. This option is useful when you want to maintain the overall look and feel of the destination document but still retain certain formatting aspects from the original document.

This option does not have any affect when the input and the output formats are PDF.

length

public static int length

fromName(String mergeFormatModeName)

public static int fromName(String mergeFormatModeName)

Parameters:

ParameterTypeDescription
mergeFormatModeNamejava.lang.String

Returns: int

getName(int mergeFormatMode)

public static String getName(int mergeFormatMode)

Parameters:

ParameterTypeDescription
mergeFormatModeint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int mergeFormatMode)

public static String toString(int mergeFormatMode)

Parameters:

ParameterTypeDescription
mergeFormatModeint

Returns: java.lang.String