ScanText Class
class ScanText : ScanningSdkLibrary.Instance, Parcelable
The text recognised on a page, together with where each piece of it sits on the image.
Produced by ScanPicture.read and reachable afterwards as ScanPicture.scanText. Positions are reported in the coordinates of the image the text was recognised from, so they line up with the page you displayed even when recognition ran on a downscaled copy internally.
Holds its recognition result in native memory. Call close — or use Kotlin’s use { } — when done to release it immediately; an unclosed instance is only reclaimed when garbage collection happens to run. Confine an instance to one thread, as with every SDK native handle.
See also
Constructors
ScanText
constructor()
Creates an empty result, for a page nothing has been recognised on yet.
constructor(source: ScanText?)
Copies another result, or creates an empty one when given null.
constructor(text: CharSequence)
Restores a result from text previously produced by buildCharSequence.
constructor(parcel: Parcel)
Restores a result from a parcel.
constructor(bytes: ByteArray)
Restores a result previously serialised by writeBytes.
Types
CREATOR
object CREATOR : Parcelable.Creator<ScanText>
Restores a ScanText from a parcel, as android.os.Parcelable requires.
Flag
enum Flag : Enum<ScanText.Flag>
Options controlling how recognised text is rendered into a string.
Properties
isReady
val isReady: Boolean
Whether recognition finished rather than being cancelled.
isTextEmpty
val isTextEmpty: Boolean
Whether recognition finished but found no text on the page.
isTextReady
val isTextReady: Boolean
Whether recognition finished and found text.
languages
val languages: String
The languages this text was recognised with.
text
val text: String
Retrieve the text part of ScanText Don’t use toString to get the text.
Functions
buildCharSequence
@JvmOverloads external fun buildCharSequence(flags: EnumSet<ScanText.Flag> = defaultFlags, suggestionColor: Int = Color.RED): CharSequence?
Renders the recognised text into a CharSequence, with styling controlled by the given flags.
checkLanguages
external fun checkLanguages(languages: String): Boolean
Whether a language string matches the one this text was recognised with.
close
@Synchronized open override fun close()
Releases the native memory held by this instance immediately instead of waiting for the garbage collector.
contentEquals
external fun contentEquals(text: String): Boolean
Internal purpose only! Fast compare text only without whitespaces.
describeContents
open override fun describeContents(): Int
No special parcelling behaviour is needed.
equals
open operator override fun equals(other: Any?): Boolean
Two results are equal when they hold the same text and layout.
filterInwardIds
external fun filterInwardIds(ids: IntArray, lookup: IntArray?): IntArray
Internal purpose only! Remove tags which completely placed in others. E.g. all words in a paragraph.
hashCode
open override fun hashCode(): Int
Consistent with equals.
toString
open external override fun toString(): String
Returns partial internal representation of the object. To get text value use the property text.
writeBytes
external fun writeBytes(packed: Boolean): ByteArray
Serialises this text so it can be stored or passed between processes.
writeToParcel
open override fun writeToParcel(parcel: Parcel, flags: Int)
Writes this ScanText into a parcel.