mindee
    Preparing search index...

    Class PathInput

    Local input source that reads a file from disk by path.

    Hierarchy

    • LocalInputSource
      • PathInput
    Index

    Constructors

    Properties

    filename: string = ""

    Original filename associated with the input.

    fileObject: Buffer = ...

    File content loaded from disk.

    filepath?: string

    Original filepath when available.

    initialized: boolean = false

    Whether the source has already been initialized.

    inputPath: string

    Path used to read the local file.

    inputType: string

    Type of local input source (path, stream, bytes, ...).

    mimeType: string = ""

    MIME type detected for the source content.

    Methods

    • Detects and validates the MIME type from the current file object.

      Returns Promise<string>

    • Compresses the file object, either as a PDF or an image.

      Parameters

      • quality: number = 85

        Quality of the compression. For images, this is the JPEG quality. For PDFs, this affects image quality within the PDF.

      • maxWidth: number | null = null

        Maximum width for image resizing. Ignored for PDFs.

      • maxHeight: number | null = null

        Maximum height for image resizing. Ignored for PDFs.

      • forceSourceText: boolean = false

        For PDFs, whether to force compression even if source text is present.

      • disableSourceText: boolean = true

        For PDFs, whether to disable source text during compression.

      Returns Promise<void>

      A Promise that resolves when the compression is complete.

    • Protected

      Returns the file object as a Buffer.

      Returns Buffer

      Buffer representation of the file object

    • Returns the number of pages in the input source. For PDFs, returns the actual page count. For images, returns 1.

      Returns Promise<number>

      Promise The number of pages

    • Returns true if the object is a PDF and has source text. False otherwise.

      Returns Promise<boolean>

      boolean

    • Reads the file from disk and validates MIME type.

      Returns Promise<void>

    • Returns whether the input source has been initialized.

      Returns boolean

    • Determines whether the current file is a PDF.

      Returns boolean

      Returns true if the file is a PDF; otherwise, returns false.