Click or drag to resize
Pdf Library for .NET

PdfImageElement Class

Represents an image that can be added to a pdf document.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfPageElement
    SelectPdf.UniversalPdfElement
      SelectPdf.UniversalPdfImageElement

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public class PdfImageElement : PdfElement

The PdfImageElement type exposes the following members.

Constructors
 NameDescription
Public methodPdfImageElement(Single, Single, Byte) Creates an image element at (x, y) from an in-memory byte array. Width fits the client area; height preserves aspect ratio.
Public methodPdfImageElement(Single, Single, Stream) Creates an image element at (x, y) from a stream. Width fits the client area; height preserves aspect ratio.
Public methodPdfImageElement(Single, Single, String) Creates an image element at (x, y) from a file. Width fits the client area (capped at the image's natural width in points); height preserves aspect ratio.
Public methodPdfImageElement(Single, Single, Single, Byte) Creates an image element at (x, y) from an in-memory byte array with the specified destination width. Height preserves aspect ratio.
Public methodPdfImageElement(Single, Single, Single, Stream) Creates an image element at (x, y) from a stream with the specified destination width. Height preserves aspect ratio.
Public methodPdfImageElement(Single, Single, Single, String) Creates an image element at (x, y) from a file with the specified destination width. Height preserves aspect ratio.
Public methodPdfImageElement(Single, Single, Single, Single, Byte) Creates an image element at (x, y) from an in-memory byte array with the specified destination size.
Public methodPdfImageElement(Single, Single, Single, Single, Stream) Creates an image element at (x, y) from a stream with the specified destination size.
Public methodPdfImageElement(Single, Single, Single, Single, String) Creates an image element at (x, y) from a file with the specified destination size.
Top
Properties
 NameDescription
Public propertyActualText Gets or sets the exact text represented by this element (the structure element's /ActualText entry), used when the drawn glyphs do not map to readable text.
(Inherited from PdfPageElement)
Public propertyAlternateText Gets or sets the alternate text describing this element for assistive technology (the structure element's /Alt entry). Required on figures for PDF/UA conformance.
(Inherited from PdfPageElement)
Public propertyArtifact Gets or sets a value indicating whether this element is an artifact — decorative or layout content that carries no meaning and is excluded from the logical structure (backgrounds, rules, running headers). Takes precedence over TagType.
(Inherited from PdfPageElement)
Public propertyBackColor Gets or sets the background fill color.
(Inherited from PdfElement)
Public propertyBlending Gets or sets the blending mode.
(Inherited from PdfElement)
Public propertyColorSpace Gets or sets the color space for the pdf element rendering.
(Inherited from PdfElement)
Public propertyForeColor Gets or sets the foreground color used for drawing outlines and text.
(Inherited from PdfElement)
Public propertyGradient Gets or sets the gradient fill. When set, overrides BackColor for fills.
(Inherited from PdfElement)
Public propertyHeight Gets or sets the image height in the destination pdf page. A value of -1 (the default) auto-computes the height from Width preserving the original aspect ratio.
Public propertyImage Gets the image rendered by this element, as the bytes of the source image.
Public propertyLineStyle Gets or sets the line style for outline drawing.
(Inherited from PdfElement)
Public propertyMultiFrameRendering Enables or disables multi-frame rendering. When true (the default), each frame of a multi-page TIFF or animated GIF is rendered on its own page. When false, only the first frame is rendered.
Public propertyRotated Gets a value indicating whether a rotation has been applied.
(Inherited from PdfElement)
Public propertyScaled Gets a value indicating whether a scale has been applied.
(Inherited from PdfElement)
Public propertySkewed Gets a value indicating whether a skew has been applied.
(Inherited from PdfElement)
Public propertyTagType Gets or sets the structure type used to tag this element in a tagged (accessible) document. Ignored unless the document's tagged mode (PdfDocument.Tagged) is enabled. Null (default) leaves the element untagged unless Artifact is set.
(Inherited from PdfPageElement)
Public propertyTranslated Gets a value indicating whether a translation has been applied.
(Inherited from PdfElement)
Public propertyTransparency Gets or sets the transparency level (0 = completely transparent, 100 = completely opaque).
(Inherited from PdfElement)
Public propertyTransparentRendering Indicates if the image's transparency (alpha channel) should be honored when rendering. Default: true. Set to false for legacy workflows that need alpha flattened.
Public propertyWidth Gets or sets the image width in the destination pdf page. A value of -1 (the default) fits the image to the available client width, capped at the image's natural width in points.
Public propertyXGets or sets the image position on the X axis, in client-area coordinates.
Public propertyYGets or sets the image position on the Y axis, in client-area coordinates.
Top
Methods
 NameDescription
Public methodRotate Applies a rotation transformation.
(Inherited from PdfElement)
Public methodScale Applies a scale transformation.
(Inherited from PdfElement)
Public methodSkew Applies a skew transformation.
(Inherited from PdfElement)
Public methodTranslate Applies a translation transformation.
(Inherited from PdfElement)
Top
Remarks

Coordinates (X, Y) and Width / Height are expressed in the page's client-area coordinate system — relative to the top-left corner of the writable area inside the page margins. On a page with Margins = 40, X = 0 places the image flush against the left margin (absolute MediaBox x = 40), and Width = ClientSize.Width fills the full writable width.

Auto-size: When Width is -1 (the default), the image is fitted to the available client width minus X, but never upscaled past its natural pixel dimensions (converted to points via its horizontal resolution). When Height is -1, it is computed from Width preserving the original aspect ratio.

Pagination: When the image is taller than the remaining client height, it is split across additional pages automatically. The returned PdfPageLastIndex is the final page.

Multi-frame images: When MultiFrameRendering is true (the default) and the source contains multiple frames (animated GIF / WebP, multi-page TIFF), each frame is rendered on its own page with new pages appended as needed.

Supported input formats: PNG, JPEG, GIF (incl. animated), BMP, WebP (incl. animated), and TIFF (incl. multi-page).

Example
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
// Auto-fit width, aspect-ratio-preserving height.
PdfImageElement image = new PdfImageElement(0, 0, "logo.png");
page.Add(image);
document.Save("out.pdf");
document.Close();
See Also