Skip to main content

Image

Version: 12.0

cete.dynamicpdf.pageelements.image

Image​

Represents an image.

public class Image : RotatingPageElement, IArea, ICoordinate, ISerializable
Public Class Image
Inherits RotatingPageElement
Implements IArea, ICoordinate, ISerializable

Inheritance: Object → PageElement → TaggablePageElement → RotatingPageElement → Image

Implements: IArea, ICoordinate, ISerializable

Licensing Info​

Basic usage of this class is a DynamicPDF Core Suite Essentials feature. However, some properties or methods require full licensing and are noted accordingly. One of the following is required for non-evaluation usage:

Examples​

The following example will place an image on the page.

Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements

Module MyModule

Sub Main()

' Create a PDF Document
Dim MyDocument As Document = New Document

' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)

' Create an image
Dim MyImage As Image = New Image("C:\MyImage.jpg", 0, 0)

' Add the image to the page
MyPage.Elements.Add(MyImage)

' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")

End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath, string imagePath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page);

// Create an image
Image image = new Image(imagePath, 0, 0);

// Add the image to the page
page.Elements.Add(image);

// Save the PDF
document.Draw(outputPath);
}
}

Remarks​

This class can be used to place images on a page. If an image will be used more than once, please see the Image Reuse topic.

Constructors​

Image(Byte[], Single, Single, Single?)​

Initializes a new instance of the Image class.

public Image(Byte[] imageData, float x, float y, [float? scale = null])
Public Sub New (imageData As Byte(), x As Single, y As Single, Optional scale As Single? = null)

Parameters​

Image data in bytes.

X coordinate of the image.

Y coordinate of the image.

The scale to use when rendering the image.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Image(ImageData, Single, Single)​

Initializes a new instance of the Image class.

public Image(ImageData imageData, float x, float y)
Public Sub New (imageData As ImageData, x As Single, y As Single)

Parameters​

ImageData object containing the image data.

X coordinate of the image.

Y coordinate of the image.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Image(ImageData, Single, Single, Single)​

Initializes a new instance of the Image class.

public Image(ImageData imageData, float x, float y, float scale)
Public Sub New (imageData As ImageData, x As Single, y As Single, scale As Single)

Parameters​

ImageData object containing the image data.

X coordinate of the image.

Y coordinate of the image.

The scale to use when rendering the image.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Image(Stream, Single, Single, Single)​

Initializes a new instance of the Image class.

public Image(Stream stream, float x, float y, float scale)
Public Sub New (stream As Stream, x As Single, y As Single, scale As Single)

Parameters​

Stream object containing the image data.

X coordinate of the image.

Y coordinate of the image.

The scale to use when rendering the image.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Image(String, Single, Single)​

Initializes a new instance of the Image class.

public Image(string filePath, float x, float y)
Public Sub New (filePath As String, x As Single, y As Single)

Parameters​

Physical file path of the image.

X coordinate of the image.

Y coordinate of the image.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Image(String, Single, Single, Single)​

Initializes a new instance of the Image class.

public Image(string filePath, float x, float y, float scale)
Public Sub New (filePath As String, x As Single, y As Single, scale As Single)

Parameters​

Physical file path of the image.

X coordinate of the image.

Y coordinate of the image.

The scale to use when rendering the image.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Properties​

Align​

Gets or sets the Align enumeration that specifies horizontal alignment of the image on the X coordinate.

public Align Align { get; set; }
Public Property Align As Align

Property Value​

Align

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

AlternateText​

Gets or sets the alternate text of the image.

public string AlternateText { get; set; }
Public Property AlternateText As String

Property Value​

String

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Angle​

Gets or sets the heights of the angle element. (Inherited from RotatingPageElement)

public float Angle { get; set; }
Public Property Angle As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Height​

Gets or sets the height of the image.

public float Height { get; set; }
Public Property Height As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

HorizontalDpi​

Gets or sets the horizontal dpi (also known as pixels per inch) of the image.

public float HorizontalDpi { get; set; }
Public Property HorizontalDpi As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Remarks​

Setting this value affects the ScaleX property.

ID​

Gets or sets the ID of the page element. (Inherited from PageElement)

public string ID { get; set; }
Public Property ID As String

Property Value​

String

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

IgnoreMargins​

Gets or sets ignore margin property. Setting false will consider the margin while placing the page element based on the RelativeTo property. (Inherited from PageElement)

public bool IgnoreMargins { get; set; }
Public Property IgnoreMargins As Boolean

Property Value​

Boolean

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples​

The following example will place the Label in the top-left of the page with IgnoreMargin

using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page); // Create an Label and place it in page top left with margin ignored
Label label = new Label("I am placed in Page top left with margin ignored", 0, 0, 160, 30);
label.RelativeTo = RelativeTo.TopLeft;
label.IgnoreMargin=true; page.Elements.Add(label);

// Save the PDF
document.Draw(outputPath);
}
}

ImageData​

Get the image's ImageData object.

public ImageData ImageData { get; }
Public ReadOnly Property ImageData As ImageData

Property Value​

ImageData

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

RelativeTo​

Gets and sets placement of the page element on the page. (Inherited from PageElement)

public RelativeTo RelativeTo { get; set; }
Public Property RelativeTo As RelativeTo

Property Value​

RelativeTo

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples​

The following example will place the Label in the top-left of the page.

using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page); // Create an Label and place it in page top left with margin
Label label = new Label("I am placed in Page top left with margin.", 0, 0, 160, 30);
label.RelativeTo = RelativeTo.TopLeft;
page.Elements.Add(label);

// Save the PDF
document.Draw(outputPath);
}
}

ScaleX​

Gets or sets the horizontal scale of the image.

public float ScaleX { get; set; }
Public Property ScaleX As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Remarks​

Setting this value affects the HorizontalDpi property.

ScaleY​

Gets or sets the vertical scale of the image.

public float ScaleY { get; set; }
Public Property ScaleY As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Remarks​

Setting this value affects the VerticalDpi property.

Tag​

Gets or sets the tag of the taggable element. (Inherited from TaggablePageElement)

public Tag Tag { get; set; }
Public Property Tag As Tag

Property Value​

Tag

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

TagOrder​

Gets or sets the tag order of the taggable element. (Inherited from TaggablePageElement)

public int TagOrder { get; set; }
Public Property TagOrder As Int32

Property Value​

Int32

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

VAlign​

Gets or sets the VAlign enumeration that specifies vertical alignment of the image on the Y coordinate.

public VAlign VAlign { get; set; }
Public Property VAlign As VAlign

Property Value​

VAlign

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

VerticalDpi​

Gets or sets the vertical dpi (also known as pixels per inch) of the image.

public float VerticalDpi { get; set; }
Public Property VerticalDpi As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Remarks​

Setting this value affects the ScaleY property.

Width​

Gets or sets the width of the image.

public float Width { get; set; }
Public Property Width As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

X​

Gets or sets the X coordinate of the page element. (Inherited from RotatingPageElement)

public float X { get; set; }
Public Property X As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Y​

Gets or sets the Y coordinate of the page element. (Inherited from RotatingPageElement)

public float Y { get; set; }
Public Property Y As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Methods​

Draw(PageWriter)​

Draws the page element to the given PageWriter object. (Inherited from RotatingPageElement)

public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)

Parameters​

PageWriter object to receive the page element's output.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

SetBounds(Single, Single)​

Scales the image to fit in the given box keeping the X and Y scale equal.

public void SetBounds(float maximumWidth, float maximumHeight)
Sub SetBounds(maximumWidth As Single, maximumHeight As Single)

Parameters​

The maximum width.

The maximum height.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

SetDpi(Single)​

Scales the image to have the specified dpi (also known as pixels per inch).

public void SetDpi(float dpi)
Sub SetDpi(dpi As Single)

Parameters​

DPI of the image.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

SetDpi(Single, Single)​

Scales the image to have the specified dpi (also known as pixels per inch).

public void SetDpi(float horizontalDpi, float verticalDpi)
Sub SetDpi(horizontalDpi As Single, verticalDpi As Single)

Parameters​

Horizontal dpi of the image.

Horizontal dpi of the image.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

SetSize(Single, Single)​

Scales the image to fit the exact width and height given.

public void SetSize(float width, float height)
Sub SetSize(width As Single, height As Single)

Parameters​

Width of image.

Height of image.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

See Also​

ceTe.DynamicPDF.PageElements