Class PdfImage
- Namespace
- DocToolkit
- Assembly
- DocToolkit.Pdf.dll
One image drawn on a PDF page: its pixels, its size in pixels, and where it was placed.
public sealed class PdfImage
- Inheritance
-
PdfImage
- Inherited Members
Remarks
Png can be null, and that is not an error. A PDF may store an image in a colour space or filter combination that cannot be re-encoded as PNG without interpreting it. Returning null for that one image, rather than throwing, means a single exotic image does not cost the caller every other image on the page. Check it before use.
PixelWidth is not Width. The first is how many pixels the stored image has; the second is how large the page draws it, in points. A 8×8 image placed at 48×48 points is normal — that is scaling, not corruption — so effective DPI is PixelWidth ÷ (Width ÷ 72).
These bytes are a re-encoding, not the file that was embedded. They are the image's pixels rendered to PNG, so they will not be byte-identical to an original PNG or JPEG — the byte count usually differs. Anything needing the original stored stream needs a different operation than this one.
Properties
Bounds
Where the image was drawn on its page, in PDF user-space points. Unrelated to PixelWidth — see this type's remarks.
public PdfBounds Bounds { get; }
Property Value
PixelHeight
How many pixels tall the stored image is.
public int PixelHeight { get; }
Property Value
PixelWidth
How many pixels wide the stored image is.
public int PixelWidth { get; }
Property Value
Png
The image's pixels encoded as PNG, or null when they could not be re-encoded. See this type's remarks — null is a normal outcome, not a failure.
public byte[]? Png { get; }
Property Value
- byte[]
Methods
ToString()
Pixel size, placed size and whether the pixels decoded, for test failure messages.
public override string ToString()