MergerContext
Inheritance: java.lang.Object, com.aspose.words.ProcessorContext
public class MergerContext extends ProcessorContext
Document merger context.
Examples:
Shows how to merge documents into a single output document using context.
//There is a several ways to merge documents:
String inputDoc1 = getMyDir() + "Big document.docx";
String inputDoc2 = getMyDir() + "Tables.docx";
MergerContext mergerContext = new MergerContext();
mergerContext.setMergeFormatMode(MergeFormatMode.KEEP_SOURCE_FORMATTING);
Merger.create(mergerContext)
.from(inputDoc1)
.from(inputDoc2)
.to(getArtifactsDir() + "LowCode.MergeContextDocuments.1.docx")
.execute();
LoadOptions firstLoadOptions = new LoadOptions();
{
firstLoadOptions.setIgnoreOleData(true);
}
LoadOptions secondLoadOptions = new LoadOptions();
{
secondLoadOptions.setIgnoreOleData(false);
}
Merger.create(mergerContext)
.from(inputDoc1, firstLoadOptions)
.from(inputDoc2, secondLoadOptions)
.to(getArtifactsDir() + "LowCode.MergeContextDocuments.2.docx", SaveFormat.DOCX)
.execute();
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
{
saveOptions.setPassword("Aspose.Words");
}
Merger.create(mergerContext)
.from(inputDoc1)
.from(inputDoc2)
.to(getArtifactsDir() + "LowCode.MergeContextDocuments.3.docx", saveOptions)
.execute();
Shows how to merge documents from stream into a single output document using context.
//There is a several ways to merge documents:
String inputDoc1 = getMyDir() + "Big document.docx";
String inputDoc2 = getMyDir() + "Tables.docx";
MergerContext mergerContext = new MergerContext();
mergerContext.setMergeFormatMode(MergeFormatMode.KEEP_SOURCE_FORMATTING);
try (FileInputStream firstStreamIn = new FileInputStream(inputDoc1)) {
try (FileInputStream secondStreamIn = new FileInputStream(inputDoc2)) {
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
{
saveOptions.setPassword("Aspose.Words");
}
try (FileOutputStream streamOut = new FileOutputStream(getArtifactsDir() + "LowCode.MergeStreamContextDocuments.1.docx")) {
Merger.create(mergerContext)
.from(firstStreamIn)
.from(secondStreamIn)
.to(streamOut, saveOptions)
.execute();
}
LoadOptions firstLoadOptions = new LoadOptions();
{
firstLoadOptions.setIgnoreOleData(true);
}
LoadOptions secondLoadOptions = new LoadOptions();
{
secondLoadOptions.setIgnoreOleData(false);
}
try (FileOutputStream streamOut1 = new FileOutputStream(getArtifactsDir() + "LowCode.MergeStreamContextDocuments.2.docx")) {
Merger.create(mergerContext)
.from(firstStreamIn, firstLoadOptions)
.from(secondStreamIn, secondLoadOptions)
.to(streamOut1, SaveFormat.DOCX)
.execute();
}
}
}
Methods
Method | Description |
---|---|
getFontSettings() | Font settings used by the processor. |
getLayoutOptions() | Document layout options used by the processor. |
getMergeFormatMode() | Specifies how to merge formatting that clashes. |
getWarningCallback() | Warning callback used by the processor. |
setFontSettings(FontSettings value) | Font settings used by the processor. |
setMergeFormatMode(int value) | Specifies how to merge formatting that clashes. |
setWarningCallback(IWarningCallback value) | Warning callback used by the processor. |
getFontSettings()
public FontSettings getFontSettings()
Font settings used by the processor.
Returns: FontSettings - The corresponding FontSettings value.
getLayoutOptions()
public LayoutOptions getLayoutOptions()
Document layout options used by the processor.
Returns: LayoutOptions - The corresponding LayoutOptions value.
getMergeFormatMode()
public int getMergeFormatMode()
Specifies how to merge formatting that clashes.
Returns: int - The corresponding int value. The returned value is one of MergeFormatMode constants.
getWarningCallback()
public IWarningCallback getWarningCallback()
Warning callback used by the processor.
Returns: IWarningCallback - The corresponding IWarningCallback value.
setFontSettings(FontSettings value)
public void setFontSettings(FontSettings value)
Font settings used by the processor.
Parameters:
Parameter | Type | Description |
---|---|---|
value | FontSettings | The corresponding FontSettings value. |
setMergeFormatMode(int value)
public void setMergeFormatMode(int value)
Specifies how to merge formatting that clashes.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The corresponding int value. The value must be one of MergeFormatMode constants. |
setWarningCallback(IWarningCallback value)
public void setWarningCallback(IWarningCallback value)
Warning callback used by the processor.
Parameters:
Parameter | Type | Description |
---|---|---|
value | IWarningCallback | The corresponding IWarningCallback value. |