←Select platform

CompareText(IList<string>) Method

Summary

Compares two strings

Syntax
C#
C++/CLI
Python
public IList<TextDifference> CompareText( 
   IList<string> texts 
) 
public:  
   IList<TextDifference^>^ CompareText( 
      IList<String^>^ texts 
   ) 
def CompareText(self,texts): 

Parameters

texts

List of strings to compare.

Return Value

A list of TextDifferences.

Remarks

Exactly two strings must be provided to this method.

Example
C#
Java
using Leadtools.Document; 
using Leadtools.Document.Compare; 
using Leadtools; 
 
 
public void CompareTextStringExample() 
{ 
   var stringList = new List<string>() 
   { 
      "Hello World", 
      "Goodbye World" 
   }; 
 
   var comparer = new DocumentComparer(); 
   var diffs = comparer.CompareText(stringList); 
 
   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 compareTextStringExample() { 
   String[] stringList = { "Hello World", "Goodbye World" }; 
 
   DocumentComparer comparer = new DocumentComparer(); 
   List<TextDifference> diffs = comparer.compareText(stringList); 
 
   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.