ComparerContext
Inheritance: java.lang.Object, com.aspose.words.ProcessorContext
public class ComparerContext extends ProcessorContext
Document comparer context
Examples:
Shows how to simple compare documents using context.
// There is a several ways to compare documents:
String firstDoc = getMyDir() + "Table column bookmarks.docx";
String secondDoc = getMyDir() + "Table column bookmarks.doc";
ComparerContext comparerContext = new ComparerContext();
comparerContext.getCompareOptions().setIgnoreCaseChanges(true);
comparerContext.setAuthor("Author");
comparerContext.setDateTime(new Date());
Comparer.create(comparerContext)
.from(firstDoc)
.from(secondDoc)
.to(getArtifactsDir() + "LowCode.CompareContextDocuments.docx")
.execute();
Shows how to compare documents from the stream using context.
// There is a several ways to compare documents from the stream:
try (FileInputStream firstStreamIn = new FileInputStream(getMyDir() + "Table column bookmarks.docx")) {
try (FileInputStream secondStreamIn = new FileInputStream(getMyDir() + "Table column bookmarks.doc")) {
ComparerContext comparerContext = new ComparerContext();
comparerContext.getCompareOptions().setIgnoreCaseChanges(true);
comparerContext.setAuthor("Author");
comparerContext.setDateTime(new Date());
try (FileOutputStream streamOut = new FileOutputStream(getArtifactsDir() + "LowCode.CompareContextStreamDocuments.docx")) {
Comparer.create(comparerContext)
.from(firstStreamIn)
.from(secondStreamIn)
.to(streamOut, SaveFormat.DOCX)
.execute();
}
}
}
Constructors
Constructor | Description |
---|---|
ComparerContext() | Initializes a new instance of this class. |
Methods
Method | Description |
---|---|
getAcceptRevisions() | Indicates whether to accept revisions in the documents before comparing them. |
getAuthor() | The author to be assigned to revisions created during document comparison. |
getCompareOptions() | Options used upon comparing documents. |
getDateTime() | The date and time assigned to revisions created during document comparison. |
getFontSettings() | Font settings used by the processor. |
getLayoutOptions() | Document layout options used by the processor. |
getWarningCallback() | Warning callback used by the processor. |
setAcceptRevisions(boolean value) | Indicates whether to accept revisions in the documents before comparing them. |
setAuthor(String value) | The author to be assigned to revisions created during document comparison. |
setDateTime(Date value) | The date and time assigned to revisions created during document comparison. |
setFontSettings(FontSettings value) | Font settings used by the processor. |
setWarningCallback(IWarningCallback value) | Warning callback used by the processor. |
ComparerContext()
public ComparerContext()
Initializes a new instance of this class.
getAcceptRevisions()
public boolean getAcceptRevisions()
Indicates whether to accept revisions in the documents before comparing them. If the compared documents contain revisions and this flag is set to false, the processor will reject revisions. Default is true .
Returns: boolean - The corresponding boolean value.
getAuthor()
public String getAuthor()
The author to be assigned to revisions created during document comparison.
Returns: java.lang.String - The corresponding java.lang.String value.
getCompareOptions()
public CompareOptions getCompareOptions()
Options used upon comparing documents.
Examples:
Shows how to simple compare documents using context.
// There is a several ways to compare documents:
String firstDoc = getMyDir() + "Table column bookmarks.docx";
String secondDoc = getMyDir() + "Table column bookmarks.doc";
ComparerContext comparerContext = new ComparerContext();
comparerContext.getCompareOptions().setIgnoreCaseChanges(true);
comparerContext.setAuthor("Author");
comparerContext.setDateTime(new Date());
Comparer.create(comparerContext)
.from(firstDoc)
.from(secondDoc)
.to(getArtifactsDir() + "LowCode.CompareContextDocuments.docx")
.execute();
Shows how to compare documents from the stream using context.
// There is a several ways to compare documents from the stream:
try (FileInputStream firstStreamIn = new FileInputStream(getMyDir() + "Table column bookmarks.docx")) {
try (FileInputStream secondStreamIn = new FileInputStream(getMyDir() + "Table column bookmarks.doc")) {
ComparerContext comparerContext = new ComparerContext();
comparerContext.getCompareOptions().setIgnoreCaseChanges(true);
comparerContext.setAuthor("Author");
comparerContext.setDateTime(new Date());
try (FileOutputStream streamOut = new FileOutputStream(getArtifactsDir() + "LowCode.CompareContextStreamDocuments.docx")) {
Comparer.create(comparerContext)
.from(firstStreamIn)
.from(secondStreamIn)
.to(streamOut, SaveFormat.DOCX)
.execute();
}
}
}
Returns: CompareOptions - The corresponding CompareOptions value.
getDateTime()
public Date getDateTime()
The date and time assigned to revisions created during document comparison.
Returns: java.util.Date - The corresponding java.util.Date value.
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.
getWarningCallback()
public IWarningCallback getWarningCallback()
Warning callback used by the processor.
Returns: IWarningCallback - The corresponding IWarningCallback value.
setAcceptRevisions(boolean value)
public void setAcceptRevisions(boolean value)
Indicates whether to accept revisions in the documents before comparing them. If the compared documents contain revisions and this flag is set to false, the processor will reject revisions. Default is true .
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The corresponding boolean value. |
setAuthor(String value)
public void setAuthor(String value)
The author to be assigned to revisions created during document comparison.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The corresponding java.lang.String value. |
setDateTime(Date value)
public void setDateTime(Date value)
The date and time assigned to revisions created during document comparison.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.util.Date | The corresponding java.util.Date 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. |
setWarningCallback(IWarningCallback value)
public void setWarningCallback(IWarningCallback value)
Warning callback used by the processor.
Parameters:
Parameter | Type | Description |
---|---|---|
value | IWarningCallback | The corresponding IWarningCallback value. |