GetDeletions Method
Example
using Leadtools.Document;
using Leadtools.Document.Compare;
using Leadtools;
public void CompareDocumentExample()
{
var doc1 = DocumentFactory.LoadFromFile(pathToDocument1, new LoadDocumentOptions());
var doc2 = DocumentFactory.LoadFromFile(pathToDocument2, new LoadDocumentOptions());
var docList = new List<LEADDocument>()
{
doc1,
doc2
};
var comparer = new DocumentComparer();
var diffs = comparer.CompareDocument(docList);
Console.WriteLine($"Total number of differences: {diffs.Differences.Count}");
Console.WriteLine($"Total number of insertions: {diffs.GetInsertions().Count}");
Console.WriteLine($"Total number of deletions: {diffs.GetDeletions().Count}");
foreach (PageCharactersDifference diff in diffs.Differences)
{
Console.WriteLine($"Operations: {diff.Operation}");
Console.WriteLine($"Text: {diff.Text}");
foreach (PageCharacter pageChar in diff.Characters)
{
Console.WriteLine($" Character: {pageChar.Character}");
Console.WriteLine($" Character Index: {pageChar.CharacterIndex}");
Console.WriteLine($" Page Number: {pageChar.PageNumber}");
Console.WriteLine($" Wordmap Index: {pageChar.WordMapIndex}");
}
Console.WriteLine("--------");
}
}
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import leadtools.document.DocumentFactory;
import leadtools.document.DocumentPageText;
import leadtools.document.LEADDocument;
import leadtools.document.LoadDocumentOptions;
import leadtools.document.compare.*;
public void compareDocumentExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
String pathToDocument2 = combine(LEAD_VARS_IMAGES_DIR, "LEADTOOLSEditor.docx");
String pathToDocument1 = combine(LEAD_VARS_IMAGES_DIR, "LEADTOOLSEditor.docx");
LEADDocument doc1 = DocumentFactory.loadFromFile(pathToDocument1, new LoadDocumentOptions());
LEADDocument doc2 = DocumentFactory.loadFromFile(pathToDocument2, new LoadDocumentOptions());
List<LEADDocument> docList = new ArrayList<LEADDocument>();
docList.add(doc1);
docList.add(doc2);
DocumentComparer comparer = new DocumentComparer();
DocumentDifference diffs = comparer.compareDocument(docList);
System.out.println("Total number of differences: " + diffs.getDifferences().size());
System.out.println("Total number of insertions: " + diffs.getInsertions().size());
System.out.println("Total number of deletions:" + diffs.getDeletions().size());
for (PageCharactersDifference diff : diffs.getDifferences()) {
System.out.println("Operations: " + diff.getOperation());
assertTrue(diff.getOperation() == DifferenceOperation.equal);
System.out.println("Text: " + diff.getText());
for (PageCharacter pageChar : diff.getCharacters()) {
System.out.println(" Character: " + pageChar.getCharacter());
System.out.println(" Character Index: " + pageChar.getCharacterIndex());
System.out.println(" Page Number: " + pageChar.getPageNumber());
System.out.println(" Wordmap Index: " + pageChar.getWordmapIndex());
}
System.out.println("--------");
}
}