Class PdfImage
- Namespace
- SoftZenPdf
- Assembly
- SoftZenPdf.dll
An image that can be drawn on pages with DrawImage(PdfImage, double, double, double, double), placed on a page of its own with AddImagePage(PdfImage, ImagePageOptions?), or used as a Watermark. Each image is embedded once per document, however many times it is drawn.
public sealed class PdfImage
- Inheritance
-
PdfImage
- Inherited Members
Remarks
JPEG: baseline and progressive, 8 bits per component, greyscale, RGB or CMYK; the data is embedded as-is and EXIF orientation is honoured. Lossless, hierarchical, arithmetic-coded and 12-bit JPEGs are not supported.
PNG: every standard colour type and bit depth, including palettes, interlacing and transparency (alpha channel or tRNS). Pixels are stored at 8 bits per component, so 16-bit images lose precision.
BMP: 1 to 32 bits per pixel, RLE4 and RLE8 compression and bit-field masks. GIF: the first frame, with transparency. TIFF: every page (see AllFromFile(string)), with no compression, CCITT Group 3 and Group 4 fax, LZW, PackBits, Deflate, or single-strip JPEG compression; greyscale, bilevel, RGB, palette and CMYK images with or without alpha, and the TIFF orientation tag. WebP, HEIC and other formats are not supported.
Properties
- AspectRatio
Width divided by height as displayed, taking the orientation into account.
- BitsPerComponent
Bits per colour component in the PDF: 1 for bilevel (black and white) images, otherwise 8.
- ColorSpace
The PDF colour space of the pixel data:
DeviceGray,DeviceRGBorDeviceCMYK.
- Format
The format the image was loaded from.
- HasTransparency
Whether the image has transparency, embedded as a soft mask.
- HorizontalResolution
The horizontal resolution stored in the file, in pixels per inch, or null if it has none.
- IsProgressive
Whether the image is a progressive JPEG.
- Orientation
The EXIF or TIFF orientation (1–8) applied when drawing; 1 when the file has none.
- PixelHeight
Height of the stored pixel data.
- PixelWidth
Width of the stored pixel data. For images with an orientation (EXIF or TIFF) this is the stored, not the displayed, width.
- VerticalResolution
The vertical resolution stored in the file, in pixels per inch, or null if it has none.
Methods
- AllFromBytes(byte[])
Loads every page of a multi-page TIFF, or the single image of any other format, from memory.
- AllFromFile(string)
Loads every page of a multi-page TIFF, or the single image of any other format.
- FromBytes(byte[])
Loads an image from memory (the first page of a TIFF); the format is detected from the content.
- FromFile(string)
Loads an image file (the first page of a TIFF); the format is detected from the content, not the extension.
- SizeInPoints(double)
The displayed size in points (1/72 inch) at the image's own resolution, taking the orientation into account. Images without a stored resolution are measured at
defaultResolutionpixels per inch.