Class PdfImageObject
public class PdfImageObject : PdfPageObject, IDisposable
- Inheritance
-
PdfImageObject
- Implements
- Inherited Members
Methods
GetDecodedImageData()
Retrieves the decoded image data from the PDF image object.
public byte[] GetDecodedImageData()
Returns
- byte[]
A byte array containing the decoded image data. Returns an empty array if no image data is available.
Exceptions
- dotPDFiumException
Thrown if the decoded image data cannot be retrieved due to an error in the underlying PDF library.
GetIccProfileData(PdfPage)
Retrieves the ICC (International Color Consortium) profile data associated with the specified PDF page.
public byte[] GetIccProfileData(PdfPage page)
Parameters
page
PdfPageThe PdfPage object representing the PDF page from which to extract the ICC profile data.
Returns
- byte[]
A byte array containing the ICC profile data. Returns an empty array if no ICC profile data is available.
Remarks
The ICC profile data is used to define the color characteristics of the PDF content. This method first determines the required buffer size for the ICC profile data and then retrieves the data if available.
Exceptions
- dotPDFiumException
Thrown if the ICC profile data cannot be retrieved due to an error in the underlying PDF processing library.
GetImageFilter(int)
Retrieves the name of the image filter applied to the image at the specified index.
public string GetImageFilter(int index)
Parameters
index
intThe zero-based index of the image filter to retrieve.
Returns
- string
A string representing the name of the image filter. The string is encoded in ASCII and does not include a null terminator.
Remarks
The method retrieves the name of the image filter associated with an image object in a PDF. The index must correspond to a valid filter applied to the image; otherwise, an exception is thrown.
Exceptions
- dotPDFiumException
Thrown if the image filter cannot be retrieved for the specified
index
.
GetImageFilterCount()
Gets the number of image filters applied to the current image object.
public int GetImageFilterCount()
Returns
- int
The total number of image filters applied. Returns 0 if no filters are applied.
Remarks
This method retrieves the count of filters associated with the image object represented by this instance. Use this method to determine how many filters are applied before accessing individual filter details.
GetImagePixelSize()
Retrieves the pixel dimensions of the image associated with this object.
public FsSize GetImagePixelSize()
Returns
Exceptions
- dotPDFiumException
Thrown if the image pixel dimensions cannot be retrieved.
GetRawImageData()
Retrieves the raw image data from the PDF image object.
public byte[] GetRawImageData()
Returns
- byte[]
A byte array containing the raw image data. If the image object has no data, an empty array is returned.
Remarks
This method returns the raw byte data of the image associated with the PDF image object. If the image object contains no data, an empty byte array is returned.
Exceptions
- dotPDFiumException
Thrown if the raw image data cannot be retrieved due to an error in the underlying PDF library.
GetRenderedBitmap(PdfDocument, PdfPage)
Retrieves the rendered bitmap representation of the current image object on the specified PDF page.
public PdfBitmap? GetRenderedBitmap(PdfDocument doc, PdfPage page)
Parameters
doc
PdfDocumentThe PDF document containing the page and image object. Cannot be null.
page
PdfPageThe PDF page containing the image object. Cannot be null.
Returns
Remarks
The dimensions of the returned bitmap are not known and must be determined by the caller if needed.
LoadJpeg(PdfPage?, PdfFileAccess)
Loads a JPEG image into the current PDF image object.
public void LoadJpeg(PdfPage? page, PdfFileAccess access)
Parameters
page
PdfPageThe PdfPage instance representing the page where the image will be loaded. Can be null if the image is not associated with a specific page.
access
PdfFileAccessA PdfFileAccess object that provides access to the JPEG file. This object must remain valid for the duration of the operation.
Remarks
This method uses the native PDFium library to load a JPEG image into the current image
object. If a page is specified, the image will be associated with that page. Ensure that the access
object provides valid access to the JPEG file.
Exceptions
- dotPDFiumException
Thrown if the JPEG image fails to load into the PDF image object.
LoadJpegFromPath(PdfPage?, string)
Loads a JPEG image from the specified file path and associates it with the given PDF page.
public void LoadJpegFromPath(PdfPage? page, string filePath)
Parameters
page
PdfPageThe PDF page to which the JPEG image will be added. Can be null if no page is specified.
filePath
stringThe file path of the JPEG image to load. Must not be null or empty.
Remarks
This method reads the JPEG image from the provided file path and associates it with the
specified PDF page. If page
is null, the image will not be associated with
any page.
LoadJpegInline(PdfPage?, PdfFileAccess)
Loads a JPEG image into the current PDF image object inline.
public void LoadJpegInline(PdfPage? page, PdfFileAccess fileAccess)
Parameters
page
PdfPageThe PdfPage to associate with the image, or null if no specific page is associated.
fileAccess
PdfFileAccessThe FPDF_FILEACCESS structure providing access to the JPEG file.
Remarks
This method attempts to load a JPEG image directly into the PDF image object. If a page is
provided, the image is associated with that page. If no page is provided, the image is loaded without a
specific page association. Ensure that the fileAccess
parameter is properly configured to
provide access to the JPEG file.
Exceptions
- dotPDFiumException
Thrown if the JPEG image could not be loaded into the image object inline.
LoadJpegInlineFromPath(PdfPage?, string)
Loads a JPEG image from the specified file path and embeds it inline within the given PDF page.
public void LoadJpegInlineFromPath(PdfPage? page, string filePath)
Parameters
page
PdfPageThe PdfPage object where the JPEG image will be embedded. This parameter can be null if no specific page is targeted.
filePath
stringThe file path of the JPEG image to load. Must be a valid path to an existing file.
Remarks
This method reads the JPEG image from the provided file path, processes it, and embeds it
inline within the specified PDF page. If page
is null, the behavior
depends on the implementation of the underlying PDF library.
SetBitmap(PdfBitmap, PdfPage?)
Sets the specified bitmap as the content of this image object.
public void SetBitmap(PdfBitmap bitmap, PdfPage? page = null)
Parameters
bitmap
PdfBitmapThe PdfBitmap to set as the image content. Cannot be null.
page
PdfPageThe PdfPage associated with the bitmap, or null if the bitmap is not tied to a specific page.
Remarks
If a page is provided, the bitmap will be associated with that page. If no page is specified, the bitmap will be set without a specific page context.
Exceptions
- dotPDFiumException
Thrown if the operation fails due to an error in the underlying PDF library.
SetBlendMode(string)
Sets the blend mode for this page object. Valid values are "Normal" (default), "Multiply", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", "ColorBurn", "HardLight", "SoftLight", "Difference" and "Exclusion".
public void SetBlendMode(string blendMode)
Parameters
blendMode
stringThe PDF blend mode name as a string.
Exceptions
- ArgumentNullException
Thrown if blendMode is null or empty.
SetMatrix(double, double, double, double, double, double)
Sets the transformation matrix for the image object.
public void SetMatrix(double a, double b, double c, double d, double e, double f)
Parameters
a
doubleThe horizontal scaling factor.
b
doubleThe horizontal skewing factor.
c
doubleThe vertical skewing factor.
d
doubleThe vertical scaling factor.
e
doubleThe horizontal translation (x-axis offset).
f
doubleThe vertical translation (y-axis offset).
Remarks
The transformation matrix defines how the image object is scaled, skewed, rotated, and translated within the PDF. Ensure that the provided values form a valid transformation matrix.
Exceptions
- dotPDFiumException
Thrown if the operation to set the image matrix fails.