Skip to content

Screenshot

Namespace: TrganReport.Core

Represents a screenshot artifact that can be embedded in the report. Supports multiple input formats including Base64 strings, byte arrays, and file paths. Provides validation and conversion utilities for consistent rendering.

public class Screenshot

Inheritance ObjectScreenshot

Properties

Title

Gets the optional description associated with the screenshot. Used for labeling or annotating the image in the report.

public string Title { get; private set; }

Property Value

String

Base64Content

Gets the screenshot content as a Base64-encoded string, if provided directly.

public string Base64Content { get; set; }

Property Value

String

FilePath

Gets the file path to the screenshot image, if loaded from disk.

public string FilePath { get; set; }

Property Value

String

ByteArray

Gets the screenshot content as a byte array, if provided directly.

public Byte[] ByteArray { get; set; }

Property Value

Byte[]

Methods

FromBase64(String, String)

Creates a screenshot from a Base64 string.

public static Screenshot FromBase64(string base64, string description)

Parameters

base64 String
The Base64-encoded image content.

description String
Optional description for the screenshot.

Returns

Screenshot
A valid Screenshot instance.

Exceptions

ScreenshotException
Thrown if the Base64 content is null or whitespace.

FromBytes(Byte[], String)

Creates a screenshot from a byte array.

public static Screenshot FromBytes(Byte[] bytes, string description)

Parameters

bytes Byte[]
The raw image bytes.

description String
Optional description for the screenshot.

Returns

Screenshot
A valid Screenshot instance.

Exceptions

ScreenshotException
Thrown if the byte array is null or empty.

FromFile(String, String)

Creates a screenshot from a file path.

public static Screenshot FromFile(string path, string description)

Parameters

path String
The path to the image file.

description String
Optional description for the screenshot.

Returns

Screenshot
A valid Screenshot instance.

Exceptions

FileNotFoundException
Thrown if the file does not exist.