Table of Contents

Class Image

Namespace
iTextSharp.text
Assembly
iTextSharp.LGPLv2.Core.dll

An Image is the representation of a graphic element (JPEG, PNG or GIF) that has to be inserted into the document

public abstract class Image : Rectangle, IElement
Inheritance
Image
Implements
Derived
Inherited Members

Constructors

Image(Uri)

constructors

protected Image(Uri url)

Parameters

url Uri

the URL where the image can be found.

Image(Image)

Constructs an Image object duplicate.

protected Image(Image image)

Parameters

image Image

another Image object.

Fields

AX

static membervariables (concerning the presence of borders)

public const int AX = 0

Field Value

int

AY

This represents a coordinate in the transformation matrix.

public const int AY = 1

Field Value

int

BX

This represents a coordinate in the transformation matrix.

public const int BX = 2

Field Value

int

BY

This represents a coordinate in the transformation matrix.

public const int BY = 3

Field Value

int

CX

This represents a coordinate in the transformation matrix.

public const int CX = 4

Field Value

int

CY

This represents a coordinate in the transformation matrix.

public const int CY = 5

Field Value

int

DEFAULT

this is a kind of image Element.

public const int DEFAULT = 0

Field Value

int

DX

This represents a coordinate in the transformation matrix.

public const int DX = 6

Field Value

int

DY

This represents a coordinate in the transformation matrix.

public const int DY = 7

Field Value

int

Invert

Image color inversion

protected bool Invert

Field Value

bool

LEFT_ALIGN

this is a kind of image Element.

public const int LEFT_ALIGN = 0

Field Value

int

MIDDLE_ALIGN

this is a kind of image Element.

public const int MIDDLE_ALIGN = 1

Field Value

int

Mask

protected bool Mask

Field Value

bool

ORIGINAL_BMP

type of image

public const int ORIGINAL_BMP = 4

Field Value

int

ORIGINAL_GIF

type of image

public const int ORIGINAL_GIF = 3

Field Value

int

ORIGINAL_JBIG2

type of image @since 2.1.5

public const int ORIGINAL_JBIG2 = 9

Field Value

int

ORIGINAL_JPEG

type of image

public const int ORIGINAL_JPEG = 1

Field Value

int

ORIGINAL_JPEG2000

type of image

public const int ORIGINAL_JPEG2000 = 8

Field Value

int

ORIGINAL_NONE

type of image

public const int ORIGINAL_NONE = 0

Field Value

int

ORIGINAL_PNG

type of image

public const int ORIGINAL_PNG = 2

Field Value

int

ORIGINAL_TIFF

type of image

public const int ORIGINAL_TIFF = 5

Field Value

int

ORIGINAL_WMF

type of image

public const int ORIGINAL_WMF = 6

Field Value

int

Profile

ICC Profile attached

protected IccProfile Profile

Field Value

IccProfile

RIGHT_ALIGN

this is a kind of image Element.

public const int RIGHT_ALIGN = 2

Field Value

int

RotationRadians

This is the rotation of the image.

protected float RotationRadians

Field Value

float

TEXTWRAP

this is a kind of image Element.

public const int TEXTWRAP = 4

Field Value

int

Template

The template to be treated as an image.

protected PdfTemplate[] Template

Field Value

PdfTemplate[]

UNDERLYING

this is a kind of image Element.

public const int UNDERLYING = 8

Field Value

int

absoluteX

This is the absolute X-position of the image.

protected float absoluteX

Field Value

float

absoluteY

This is the absolute Y-position of the image.

protected float absoluteY

Field Value

float

alignment

The alignment of the Image.

protected int alignment

Field Value

int

alt

Text that can be shown instead of the image.

protected string alt

Field Value

string

annotation

if the annotation is not null the image will be clickable.

protected Annotation annotation

Field Value

Annotation

bpc

this is the bits per component of the raw image. It also flags a CCITT image.

protected int bpc

Field Value

int

colorspace

this is the colorspace of a jpeg-image.

protected int colorspace

Field Value

int

compressionLevel

The compression level of the content streams. @since 2.1.3

protected int compressionLevel

Field Value

int

deflated

Holds value of property deflated.

protected bool deflated

Field Value

bool

dpiX

Holds value of property dpiX.

protected int dpiX

Field Value

int

dpiY

Holds value of property dpiY.

protected int dpiY

Field Value

int

imageMask

protected Image imageMask

Field Value

Image

indentationLeft

for the moment these variables are only used for Images in class Table

protected float indentationLeft

Field Value

float

indentationRight

the indentation to the right.

protected float indentationRight

Field Value

float

interpolation

Holds value of property interpolation.

protected bool interpolation

Field Value

bool

layer

protected IPdfOcg layer

Field Value

IPdfOcg

mySerialId

protected long mySerialId

Field Value

long

originalData

Holds value of property originalData.

protected byte[] originalData

Field Value

byte[]

originalType

Holds value of property originalType.

protected int originalType

Field Value

int

plainHeight

This is the width of the image without rotation.

protected float plainHeight

Field Value

float

plainWidth

This is the width of the image without rotation.

protected float plainWidth

Field Value

float

rawData

The raw data of the image.

protected byte[] rawData

Field Value

byte[]

scaledHeight

This is the original height of the image taking rotation into account.

protected float scaledHeight

Field Value

float

scaledWidth

This is the scaled width of the image taking rotation into account.

protected float scaledWidth

Field Value

float

spacingAfter

The spacing after the image.

protected float spacingAfter

Field Value

float

spacingBefore

The spacing before the image.

protected float spacingBefore

Field Value

float

transparency

this is the transparency information of the raw image

protected int[] transparency

Field Value

int[]

type

The imagetype.

protected int type

Field Value

int

url

The URL of the image.

protected Uri url

Field Value

Uri

Properties

AbsoluteX

Returns the absolute X position.

public float AbsoluteX { get; }

Property Value

float

a position

AbsoluteY

Returns the absolute Y position.

public float AbsoluteY { get; }

Property Value

float

a position

Additional

public PdfDictionary Additional { get; set; }

Property Value

PdfDictionary

Alignment

Get/set the alignment for the image.

public int Alignment { get; set; }

Property Value

int

a value

Alt

Get/set the alternative text for the image.

public string Alt { get; set; }

Property Value

string

a string

Annotation

Get/set the annotation.

public Annotation Annotation { get; set; }

Property Value

Annotation

the Annotation

Bpc

Gets the bpc for the image.

public int Bpc { get; }

Property Value

int

a bpc value

Remarks

this only makes sense for Images of the type RawImage.

Colorspace

Gets the colorspace for the image.

public int Colorspace { get; }

Property Value

int

a colorspace value

Remarks

this only makes sense for Images of the type Jpeg.

CompressionLevel

Sets the compression level to be used if the image is written as a compressed stream. @since 2.1.3

public int CompressionLevel { get; set; }

Property Value

int

Deflated

public bool Deflated { get; set; }

Property Value

bool

DirectReference

public PdfIndirectReference DirectReference { get; set; }

Property Value

PdfIndirectReference

DpiX

Gets the dots-per-inch in the X direction. Returns 0 if not available.

public int DpiX { get; }

Property Value

int

the dots-per-inch in the X direction

DpiY

Gets the dots-per-inch in the Y direction. Returns 0 if not available.

public int DpiY { get; }

Property Value

int

the dots-per-inch in the Y direction

ImageMask

Get/set the explicit masking.

public Image ImageMask { get; set; }

Property Value

Image

the explicit masking

IndentationLeft

public float IndentationLeft { get; set; }

Property Value

float

IndentationRight

public float IndentationRight { get; set; }

Property Value

float

InitialRotation

Some image formats, like TIFF may present the images rotated that have to be compensated.

public float InitialRotation { get; set; }

Property Value

float

Interpolation

Sets the image interpolation. Image interpolation attempts to produce a smooth transition between adjacent sample values.

public bool Interpolation { get; set; }

Property Value

bool

New value of property interpolation.

Inverted

Inverts the meaning of the bits of a mask.

public bool Inverted { get; set; }

Property Value

bool

true to invert the meaning of the bits of a mask

Layer

public IPdfOcg Layer { get; set; }

Property Value

IPdfOcg

Matrix

Returns the transformation matrix of the image.

public float[] Matrix { get; }

Property Value

float[]

an array [AX, AY, BX, BY, CX, CY, DX, DY]

MySerialId

returns serial id for this object

public long MySerialId { get; }

Property Value

long

OriginalData

public byte[] OriginalData { get; set; }

Property Value

byte[]

OriginalType

public int OriginalType { get; set; }

Property Value

int

PlainHeight

Gets the plain height of the image.

public float PlainHeight { get; }

Property Value

float

a value

PlainWidth

Gets the plain width of the image.

public float PlainWidth { get; }

Property Value

float

a value

RawData

methods to retrieve information

public byte[] RawData { get; }

Property Value

byte[]

the raw data

Remarks

this only makes sense for Images of the type RawImage.

Rotation

Sets the rotation of the image in radians.

public float Rotation { set; }

Property Value

float

RotationDegrees

Sets the rotation of the image in degrees.

public float RotationDegrees { set; }

Property Value

float

ScaledHeight

Gets the scaled height of the image.

public float ScaledHeight { get; }

Property Value

float

a value

ScaledWidth

Gets the scaled width of the image.

public float ScaledWidth { get; }

Property Value

float

a value

Smask

Holds value of property smask.

public bool Smask { get; set; }

Property Value

bool

SpacingAfter

public float SpacingAfter { get; set; }

Property Value

float

SpacingBefore

public float SpacingBefore { get; set; }

Property Value

float

TagIcc

Tags this image with an ICC profile.

public IccProfile TagIcc { get; set; }

Property Value

IccProfile

TemplateData

Get/set the template to be used as an image.

public PdfTemplate TemplateData { get; set; }

Property Value

PdfTemplate

the template

Remarks

this only makes sense for Images of the type ImgTemplate.

Transparency

Returns the transparency.

public int[] Transparency { get; set; }

Property Value

int[]

the transparency

Type

Returns the type.

public override int Type { get; }

Property Value

int

a type

Url

Gets the string-representation of the reference to the image.

public Uri Url { get; set; }

Property Value

Uri

a string

WidthPercentage

Holds value of property widthPercentage.

public float WidthPercentage { get; set; }

Property Value

float

XyRatio

Holds value of property XYRatio.

public float XyRatio { get; set; }

Property Value

float

Methods

GetImageRotation()

methods to set information

public float GetImageRotation()

Returns

float

the current image rotation in radians

GetInstance(SKBitmap, SKEncodedImageFormat, int)

Converts a .NET image to a Native(PNG, JPG, GIF, WMF) image

public static Image GetInstance(SKBitmap image, SKEncodedImageFormat format, int quality = 100)

Parameters

image SKBitmap
format SKEncodedImageFormat
quality int

Returns

Image

GetInstance(SKBitmap, BaseColor)

Gets an instance of an Image from a System.Drawing.Image.

public static Image GetInstance(SKBitmap image, BaseColor color)

Parameters

image SKBitmap

the System.Drawing.Image to convert

color BaseColor

if different from null the transparency pixels are replaced by this color

Returns

Image

an object of type ImgRaw

GetInstance(SKBitmap, BaseColor, bool)

Gets an instance of an Image from a SkiaSharp.SKBitmap.

public static Image GetInstance(SKBitmap image, BaseColor color, bool forceBw)

Parameters

image SKBitmap

the System.Drawing.Image to convert

color BaseColor

if different from null the transparency pixels are replaced by this color

forceBw bool

if true the image is treated as black and white

Returns

Image

an object of type ImgRaw

GetInstance(byte[])

Gets an instance of an Image.

public static Image GetInstance(byte[] imgb)

Parameters

imgb byte[]

a byte array

Returns

Image

an object of type Gif, Jpeg or Png

GetInstance(Stream)

public static Image GetInstance(Stream s)

Parameters

s Stream

Returns

Image

GetInstance(int, int, bool, int, int, byte[])

Gets an instance of an Image in raw mode.

public static Image GetInstance(int width, int height, bool reverseBits, int typeCcitt, int parameters, byte[] data)

Parameters

width int

the width of the image in pixels

height int

the height of the image in pixels

reverseBits bool
typeCcitt int
parameters int
data byte[]

Returns

Image

GetInstance(int, int, bool, int, int, byte[], int[])

public static Image GetInstance(int width, int height, bool reverseBits, int typeCcitt, int parameters, byte[] data, int[] transparency)

Parameters

width int
height int
reverseBits bool
typeCcitt int
parameters int
data byte[]
transparency int[]

Returns

Image

GetInstance(int, int, byte[], byte[])

Creates a JBIG2 Image. @since 2.1.5

public static Image GetInstance(int width, int height, byte[] data, byte[] globals)

Parameters

width int

the width of the image

height int

the height of the image

data byte[]

the raw image data

globals byte[]

JBIG2 globals

Returns

Image

GetInstance(int, int, int, int, byte[])

Gets an instance of an Image in raw mode.

public static Image GetInstance(int width, int height, int components, int bpc, byte[] data)

Parameters

width int

the width of the image in pixels

height int

the height of the image in pixels

components int

1,3 or 4 for GrayScale, RGB and CMYK

bpc int

bits per component

data byte[]

the image data

Returns

Image

an object of type ImgRaw

GetInstance(int, int, int, int, byte[], int[])

Gets an instance of an Image in raw mode.

public static Image GetInstance(int width, int height, int components, int bpc, byte[] data, int[] transparency)

Parameters

width int

the width of the image in pixels

height int

the height of the image in pixels

components int

1,3 or 4 for GrayScale, RGB and CMYK

bpc int

bits per component

data byte[]

the image data

transparency int[]

transparency information in the Mask format of the image dictionary

Returns

Image

an object of type ImgRaw

GetInstance(string)

Gets an instance of an Image.

public static Image GetInstance(string filename)

Parameters

filename string

a filename

Returns

Image

an object of type Gif, Jpeg or Png

GetInstance(Uri)

Gets an instance of an Image.

public static Image GetInstance(Uri url)

Parameters

url Uri

an URL

Returns

Image

an object of type Gif, Jpeg or Png

GetInstance(Image)

Gets an instance of an Image.

public static Image GetInstance(Image image)

Parameters

image Image

an Image

Returns

Image

an object of type Gif, Jpeg or Png

GetInstance(PdfTemplate)

Gets an instance of an Image in raw mode.

public static Image GetInstance(PdfTemplate template)

Parameters

template PdfTemplate

Returns

Image

GetInstance(PrIndirectReference)

Reuses an existing image. @throws BadElementException on error

public static Image GetInstance(PrIndirectReference iref)

Parameters

iref PrIndirectReference

the reference to the image dictionary

Returns

Image

the image

GetSerialId()

generates new serial id

protected static long GetSerialId()

Returns

long

HasAbsolutePosition()

Checks if the Images has to be added at an absolute position.

public bool HasAbsolutePosition()

Returns

bool

a bool

HasAbsoluteX()

Checks if the Images has to be added at an absolute X position.

public bool HasAbsoluteX()

Returns

bool

a bool

HasIccProfile()

Checks is the image has an ICC profile.

public bool HasIccProfile()

Returns

bool

the ICC profile or null

IsImgRaw()

Returns true if the image is a ImgRaw-object.

public bool IsImgRaw()

Returns

bool

a bool

IsImgTemplate()

Returns true if the image is an ImgTemplate-object.

public bool IsImgTemplate()

Returns

bool

a bool

IsJpeg()

Returns true if the image is a Jpeg-object.

public bool IsJpeg()

Returns

bool

a bool

IsMask()

Returns true if this Image is a mask.

public bool IsMask()

Returns

bool

true if this Image is a mask

IsMaskCandidate()

Returns true if this Image has the requisites to be a mask.

public bool IsMaskCandidate()

Returns

bool

true if this Image can be a mask

IsNestable()

@see com.lowagie.text.Element#isNestable() @since iText 2.0.8

public override bool IsNestable()

Returns

bool

MakeMask()

Make this Image a mask.

public void MakeMask()

ScaleAbsolute(float, float)

Scale the image to an absolute width and an absolute height.

public void ScaleAbsolute(float newWidth, float newHeight)

Parameters

newWidth float

the new width

newHeight float

the new height

ScaleAbsoluteHeight(float)

Scale the image to an absolute height.

public void ScaleAbsoluteHeight(float newHeight)

Parameters

newHeight float

the new height

ScaleAbsoluteWidth(float)

Scale the image to an absolute width.

public void ScaleAbsoluteWidth(float newWidth)

Parameters

newWidth float

the new width

ScalePercent(float)

Scale the image to a certain percentage.

public void ScalePercent(float percent)

Parameters

percent float

the scaling percentage

ScalePercent(float, float)

Scale the width and height of an image to a certain percentage.

public void ScalePercent(float percentX, float percentY)

Parameters

percentX float

the scaling percentage of the width

percentY float

the scaling percentage of the height

ScaleToFit(float, float)

Scales the image so that it fits a certain width and height.

public void ScaleToFit(float fitWidth, float fitHeight)

Parameters

fitWidth float

the width to fit

fitHeight float

the height to fit

SetAbsolutePosition(float, float)

Sets the absolute position of the Image.

public void SetAbsolutePosition(float absoluteX, float absoluteY)

Parameters

absoluteX float
absoluteY float

SetDpi(int, int)

Sets the dots per inch value dpi for x coordinates dpi for y coordinates

public void SetDpi(int dpiX, int dpiY)

Parameters

dpiX int
dpiY int

SimplifyColorspace()

Replaces CalRGB and CalGray colorspaces with DeviceRGB and DeviceGray.

public void SimplifyColorspace()