PdfImageOccurrence Class

An image painted by the content of a page (PdfPage.GetImages): an image XObject painted by Do, directly or by a form, or an inline image (ISO 32000-2, 8.9). An image XObject painted several times is an occurrence each time, with the same PdfImageOccurrence.Reference.

public sealed class PdfImageOccurrence

Properties

NameDescription
BitsPerComponentGets the number of bits of each component of a sample, or 0 when the filter of the image gives it (JPXDecode).
BoundsGets the bounding box of the image on the page, in default user space: the unit square transformed by PdfImageOccurrence.Matrix.
ColorSpaceGets the color space of the image (/ColorSpace), resolved in the resources when it is a name, or null (an image mask, a JPXDecode image).
DictionaryGets the image dictionary: the dictionary of the stream, or the dictionary of an inline image with its abbreviated keys expanded (/W is /Width...). Its color space can be the name of a resource.
EncodedDataGets the data of the image, encoded with its filters (PdfImageOccurrence.Filters).
FiltersGets the filters of the data, such as DCTDecode for a JPEG image.
HeightGets the height of the image, in samples.
IsImageMaskGets a value indicating whether the image is a stencil mask, painted with the fill color (8.9.6.2).
IsInlineGets a value indicating whether the image is an inline image (BI ... ID ... EI).
MatrixGets the matrix from the unit square of the image to the default user space of the page: the transformation matrix when the image is painted (8.9.4).
NameGets the name of the image XObject in the resources it was painted from, or null for an inline image.
PageGets the page.
ReferenceGets the reference to the image XObject, or null for an inline image or a direct stream.
SoftMaskGets the soft mask of the image (/SMask, 11.6.5.3), or null.
WidthGets the width of the image, in samples.

BitsPerComponent

PdfImageOccurrence.cs

Gets the number of bits of each component of a sample, or 0 when the filter of the image gives it (JPXDecode).

public int BitsPerComponent { get; }

Property value

int

Gets the bounding box of the image on the page, in default user space: the unit square transformed by PdfImageOccurrence.Matrix.

public PdfRectangle Bounds { get; }

Property value

PdfRectangle

Gets the color space of the image (/ColorSpace), resolved in the resources when it is a name, or null (an image mask, a JPXDecode image).

public PdfObject? ColorSpace { get; }

Property value

PdfObject?

Gets the image dictionary: the dictionary of the stream, or the dictionary of an inline image with its abbreviated keys expanded (/W is /Width...). Its color space can be the name of a resource.

public PdfDictionary Dictionary { get; }

Property value

PdfDictionary

Gets the data of the image, encoded with its filters (PdfImageOccurrence.Filters).

public ReadOnlyMemory<byte> EncodedData { get; }

Property value

ReadOnlyMemory<byte>

Gets the filters of the data, such as DCTDecode for a JPEG image.

public IReadOnlyList<PdfName> Filters { get; }

Gets the height of the image, in samples.

public int Height { get; }

Property value

int

Gets a value indicating whether the image is a stencil mask, painted with the fill color (8.9.6.2).

public bool IsImageMask { get; }

Property value

bool

Gets a value indicating whether the image is an inline image (BI ... ID ... EI).

public bool IsInline { get; }

Property value

bool

Gets the matrix from the unit square of the image to the default user space of the page: the transformation matrix when the image is painted (8.9.4).

public PdfMatrix Matrix { get; }

Property value

PdfMatrix

Gets the name of the image XObject in the resources it was painted from, or null for an inline image.

public string? Name { get; }

Property value

string?

Gets the page.

public PdfPage Page { get; }

Property value

PdfPage

Gets the reference to the image XObject, or null for an inline image or a direct stream.

public PdfReference? Reference { get; }

Property value

PdfReference?

Gets the soft mask of the image (/SMask, 11.6.5.3), or null.

public PdfStream? SoftMask { get; }

Property value

PdfStream?

Gets the width of the image, in samples.

public int Width { get; }

Property value

int

Methods

NameDescription
Decode()Decodes the image to RGBA pixels: its color space converted to sRGB, its decode array, its mask or soft mask applied as the alpha channel, within the limits of the read options of the document. A stencil mask is black where it paints.

Decodes the image to RGBA pixels: its color space converted to sRGB, its decode array, its mask or soft mask applied as the alpha channel, within the limits of the read options of the document. A stencil mask is black where it paints.

public Image<Rgba32>? Decode()

Returns

Image<Rgba32>? The image, which the caller disposes, or null when the image has no pixels.

Exceptions

InvalidPdfContentException
The data of the image cannot be decoded.
UnsupportedPdfFeatureException
The image uses a feature the library does not support.
PdfResourceLimitException
The image exceeds a limit of the read options.