scanbotsdk
    Preparing search index...

    Class RandomAccessSource

    RandomAccessSource is a wrapper around a native memory-mapped file or byte array. It is used to provide a random access interface to the underlying data.

    Since the instance of the class is backed by native resources and implements AsyncDisposable it's highly recommended to use the await using syntax when an instance is created or is received from an API:

    await using instance = await RandomAccessSource.fromPath('path/to/file.pdf');
    

    Alternatively, one can explicitly call dispose method to release the native resources. If neither is used, the resource will be released when the instance is garbage collected which is not recommended.

    Implements

    Index

    Methods

    • Returns Promise<void>

    • Releases the native resources associated with this instance.

      Returns Promise<void>

    • Constructs RandomAccessSource from the given byte array.

      Parameters

      • buffer: Uint8Array

        The byte array to use as the source.

      Returns Promise<RandomAccessSource>

      RandomAccessSource instance that provides random access to the byte array data.

    • Constructs RandomAccessSource from the given file effectively creating a memory-mapping.

      Parameters

      • path: string

        Path to the file.

      Returns Promise<RandomAccessSource>

      RandomAccessSource instance that provides random access to the file data.