Image Class Documentation

class Image : Element

Namespace:Datalogics::PDFL

Inherits from:
Element

Detailed Description

An image resource can either be an image XObject or inline image found in a page's content stream.

An Image Xobject is stored separately from the graphics content stream in a PDF, and so can be used multiple times in the document, even across pages. The image is described in the /Xobject entry in the resources dictionary on the PDF page.

Image size and resoultion: For images that are imported from raster image files, the design width and height are stored in the Image object's Matrix, in the A (width) and D (depth) Matrix members, when the image is imported. These are stored in PDF units.

To derive the effective resolution of an image imported from a raster image file:

Horizontal resolution: divide the Image Width by the Image's Matrix A member and multiply by 72 to scale to DPI (dots per inch).

Vertical resolution: divide the Image Height by the Image's Matrix D member and multiply by 72 to scale to DPI (dots per inch).

Constructor & Destructor Documentation

Image

Image(string fileName)

Parameters

fileName: string

the filename of the image file.

Create a new Image from an existing physical file. This file can be a bitmap, gif, jpeg, png, or a tiff file. An exception will be thrown if the image file is not any of the above.

NOTICE on tiff files: If the tiff file is multi-paged, then the first "page" only of the file will be converted to an Image. See ImageCollection to convert each page in a multi-page tiff file to an Image.

Image

Image(string fileName, Document document)

Parameters

fileName: string

the filename of the image file.

document: Document

the document in which the image is intended to be used.

Create a new Image from an existing physical file. This file can be a bitmap, gif, jpeg, png, or a tiff file. An exception will be thrown if the image file is not any of the above.

Specifying the document optimizes data usage for this image within that document.

NOTICE on tiff files: If the tiff file is multi-paged, then the first "page" only of the file will be converted to an Image. See ImageCollection to convert each page in a multi-page tiff file to an Image.

Image

Image(System.IO.Stream stream)

Parameters

stream: System.IO.Stream

The Stream from which to read the Image.

Create an Image from a Stream.

This allows an image to be read from a Stream object. The Stream must be seekable. Suitable examples are FileStream and MemoryStream. The Stream must contain image data in one of the supported file formats: TIFF, JPEG, BMP, PNG, or GIF.

NOTICE on tiff files: If the tiff file is multi-paged, then the first "page" only of the file will be converted to an Image. See ImageCollection to convert each page in a multi-page tiff file to an Image.

Image

Image(System.IO.Stream stream, Document document)

Parameters

stream: System.IO.Stream

The Stream from which to read the Image.

document: Document

The Document in which the Image is intended to be used.

Create an Image from a Stream.

This allows an image to be read from a Stream object. The Stream must be seekable. Suitable examples are FileStream and MemoryStream. The Stream must contain image data in one of the supported file formats: TIFF, JPEG, BMP, PNG, or GIF.

NOTICE on tiff files: If the tiff file is multi-paged, then the first "page" only of the file will be converted to an Image. See ImageCollection to convert each page in a multi-page tiff file to an Image.

Specifying the document optimizes data usage for this image within that document.

Property Documentation

Bitmap

System.Drawing.Bitmap Bitmap[get]

Return this PDF image as a System.Drawing.Bitmap.

Images in Gray or RGB color spaces are returned without conversion, while images in other spaces are first converted to RGB.

BitsPerComponent

int BitsPerComponent[get]

The number of bits per component in the image.

BoundingBox

Rect BoundingBox[get]

The bounding box for this element.

The bounding box is a rectangle that is guaranteed to encompass the element, but it is not guaranteed to be the smallest box that could contain the element. For example, if the element is a Path that contains an arc, the bounding box encompasses the bezier control points, and not just the curve itself.

Clip

Clip Clip[get, set]

Gets the current Clip for an Element.

ColorSpace

ColorSpace ColorSpace[get]

return the ColorSpace with which this Image was created.

Compression

CompressionCode Compression[get, set]

The compression filter applied to the image data.

Data

System.Byte[] Data[get]

The actual bytes that make up the image, exactly as they appear in the image data.

DidWarningsOccurDuringImport

bool DidWarningsOccurDuringImport[get]

Indicates whether warnings occurred during import of the raster image file.

GraphicState

GraphicState GraphicState[get, set]

The graphic state of the current element.

Height

int Height[get]

The height of the image in pixels.

Intent

string Intent[get, set]

The color rendering intent for the image.

IsImageMask

bool IsImageMask[get]

Indicates whether this image is an image mask.

An image mask is a 1-bit-per-pixel image used to select painting in the current color rather than displaying image samples.

LargeData

System.Collections.Generic.IList< ImageData > LargeData[get]

Gets the decompressed image data from very large images.

NOTE: This function is only supported in 64-bit, only if enough contiguous memory is available. The data size must exceed nearly 2GB, otherwise an exception is thrown and you would use the Data member instead to access the image data. The first members of the list returned contain a close to 2GB chunk of the data, but the last member containing the remaining data will be smaller in size. This facilitates retrieving the data in .NET and Java which have 2GB limits on object sizes.

Matrix

Matrix Matrix[get, set]

The transformation matrix for the element.

NumberComponents

int NumberComponents[get]

The number of color components in the image.

SoftMask

Image SoftMask[get, set]

Gets, for this image, the soft mask (also an image).

Stream

PDFStream Stream[get]

The PDFStream object associated with the image.

Width

int Width[get]

The width of the image in pixels.

Member Function Documentation

ChangeResolution

Image ChangeResolution(int dpi)

Parameters

dpi: int

the new resolution

Returns:

Image

newimage - the original image modified to the new resolution.

Create a new image from an existing one modifying the resolution (dots per inch)

Clone

new Image Clone()

Returns:

new Image

The copied image.

Makes a copy of the image.

Make a copy of an image to obtain a new image that has a distinct set of attributes.

Clone

new Image Clone(ElementCloneFlags cloneFlags)

Parameters

cloneFlags: ElementCloneFlags

Flags that modify the cloning operation.

Returns:

new Image

The copied image.

Makes a copy of the image.

Make a copy of an image to obtain a new image that has a distinct set of attributes.

ColorConvert

Image ColorConvert(Document document, ColorProfile prof, RenderIntent intent, bool embed)

Parameters

document: Document

The document the element belongs to.

prof: ColorProfile

The ICC ColorProfile to be applied.

intent: RenderIntent

The ICC Rendering Intent for the ColorProfile

embed: bool

If true, embed the color space and make the object calibrated. If it is false and the target profile is CMYK, RGB, or Gray, the colors space of the resulting object, after conversion, will be DeviceCMYK, DeviceRGB, or DeviceGray, respectively.

Returns:

Image

A new Image with the applied ICC ColorProfile.

Applies the specified ICC ColorProfile to the Image

Dispose

void Dispose()

Returns:

void

Rotate

new void Rotate(double angle)

Parameters

angle: double

The rotation angle in degrees, counterclockwise.

Returns:

new void

Rotate an image on (angle) degree using the matrix [cos(a), sin(a), -sin(a), cos(a), 0, 0].

For images, this rotate is done without regard to the primary scaling of the original image.

Save

void Save(string imagefilename, ImageType imageType)

Parameters

imagefilename: string

The physical image file which will be created.

imageType: ImageType

The IMAGETYPE used for saving the image.

Returns:

void

Save an image into a particular file format with default parameters for saving.

Save

void Save(string imagefilename, ImageType imageType, ImageSaveParams saveparams)

Parameters

imagefilename: string

The physical image file which will be created.

imageType: ImageType

The ImageType used for saving the image.

saveparams: ImageSaveParams

The ImageSaveParams for saving the image.

Returns:

void

Save an image into a particular file format with the given parameters for saving.

Scale

void Scale(double sx, double sy)

Parameters

sx: double

The horizontal scale factor.

sy: double

The vertical scale factor.

Returns:

void

Scale an element by (sx,sy) units using the matrix [ sx 0 0 sy 0 0 ].

Translate

new void Translate(double tx, double ty)

Parameters

tx: double

The horizontal translation distance in user space units.

ty: double

The vertical translation distance in user space units.

Returns:

new void

Translate an image by (tx,ty) units using the matrix [ 1 0 0 1 tx ty ].

For images, this translation is done without regard to the scaling and rotation of the original image.

To ensure that this translation can be done, do the translation before any further rotation or scaling.