←Select platform

TextDifference Class

Summary

Object for holding text-comparison information.

Syntax
C#
C++/CLI
Python
[SerializableAttribute()] 
[DataContractAttribute()] 
public class TextDifference : Difference 
public: 
   [SerializableAttribute,  
   DataContractAttribute] 
   ref class TextDifference : Difference 
class TextDifference(Difference): 
Example
C#
Java
using Leadtools.Document; 
using Leadtools.Document.Compare; 
using Leadtools; 
 
 
public void CompareTextDocumentPageTextExample() 
{ 
   var doc1 = DocumentFactory.LoadFromFile(pathToDocument1, new LoadDocumentOptions()); 
   var doc2 = DocumentFactory.LoadFromFile(pathToDocument2, new LoadDocumentOptions()); 
 
   var textList = new List<DocumentPageText>() 
   { 
      doc1.Pages.First().GetText(), 
      doc2.Pages.First().GetText() 
   }; 
 
   var comparer = new DocumentComparer(); 
   var diffs = comparer.CompareText(textList); 
 
   foreach (TextDifference diff in diffs) 
   { 
      Console.WriteLine($"Operations: {diff.Operation}"); 
      Console.WriteLine($"Text: {diff.Text}"); 
      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 compareTextDocumentPageTextExample() { 
   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()); 
 
   DocumentPageText[] textList = { doc1.getPages().get(0).getText(), 
         doc2.getPages().get(0).getText() }; 
 
   DocumentComparer comparer = new DocumentComparer(); 
   List<TextDifference> diffs = comparer.compareText(textList); 
 
   for (TextDifference diff : diffs) { 
 
      System.out.println("Operations: " + diff.getOperation()); 
      System.out.println("Text: " + diff.getText()); 
      System.out.println("--------"); 
   } 
   assertTrue(diffs.size() > 0); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Compare Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.