Table of Contents

Class Attachment

Namespace
LMKit.Data
Assembly
LM-Kit.NET.dll

Represents a file attachment with its content, name, MIME type, and size.

Supported Formats: PNG, BMP, GIF, PSD, PIC, JPEG, PNM, HDR, TGA, WEBP, TIFF, TXT, HTML, DOCX, XLSX, PPTX.

public sealed class Attachment : IDisposable
Inheritance
Attachment
Implements
Inherited Members

Constructors

Attachment(ImageBuffer, bool, string)

Initializes a new Attachment from an in-memory image buffer.

Attachment(byte[], string)

Initializes a new instance of the Attachment class with the provided data and name. The data must represent one of the supported formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT
  • DOCX
  • XLSX
  • PPTX
Attachment(Stream, string)

Initializes a new instance of the Attachment class by reading the content from the provided stream and using the given file name. The stream must contain data representing one of the supported formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT
  • DOCX
  • XLSX
  • PPTX
Attachment(string)

Initializes a new instance of the Attachment class by loading the content from the specified file path. The file must be one of the supported formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT
  • DOCX
  • XLSX
  • PPTX

Properties

HasText

Gets a value indicating whether the attachment contains extractable text.

Id

Gets the unique identifier for this attachment instance.

IsVisionRequired

Gets a value indicating whether vision processing (e.g., image analysis or OCR) is required to interpret the attachment.

Length

Gets the length of the attachment content in bytes.

Mime

Gets the MIME type of the attachment.

Name

Gets the name of the attachment file.

PageCount

Gets the number of pages represented by this attachment.

PageElements

Gets the sequence of page-level text elements extracted from the attachment.

Path

Gets the full file-system path from which this attachment was loaded.

Methods

CreateFromBase64String(string, string)

Creates a new Attachment instance from a base64-encoded string.

CreateFromText(string, string)

Creates a new Attachment from a plain-text string.

DetectMimeType(byte[], string)

Detects the MIME type of the provided byte array, using only the formats supported by the toolkit.

DetectMimeType(string)

Detects the MIME type of the file at the specified path, using only the formats supported by the toolkit.

Dispose()

Releases resources used by this instance.

GetPageHeight(int)

Gets the height of the specified page.

GetPageWidth(int)

Gets the width of the specified page.

GetText(CancellationToken)

Extracts and returns the textual content from the attachment.

GetTextAsync(CancellationToken)

Asynchronously extracts and returns the textual content from the attachment.

SetText(PageElement)

Attaches a textual representation to the attachment from a PageElement structure, overriding any previously set text elements.

SetText(string)

Attaches a textual representation to the attachment, replacing any previously extracted text.

ToString()

Returns the textual content of the attachment.