Images
DynamicPDF Core Suite for .NET supports nine image types and transparent images. It can read images from a file, stream, or bitmap. This section explains how to use images in a document.
Image Page Element and Background Image Page Element
Add images to a page using the Image page element or the BackgroundImage page element. The following code illustrates.
// Adds a background image and image to a page.
page.Elements.Add( new BackgroundImage( @"C:\MyBackground.gif" ) );
page.Elements.Add( new Image( @"C:\MyLogo.gif", 0, 0 ) );
' Adds a background image and image to a page.
MyPage.Elements.Add( New BackgroundImage( "C:\MyBackground.gif" ) )
MyPage.Elements.Add( New Image( "C:\MyLogo.gif", 0, 0 ) )
Adding Images From A File
Images can be created from a file as follows.
// Adds an image to a page.
page.Elements.Add( new Image( @"C:\MyLogo.gif", 0, 0 ) );
' Adds an image to a page.
MyPage.Elements.Add( New Image( "C:\MyLogo.gif", 0, 0 ) )
Adding Images From A System.IO.Stream Object
Images can be created from a stream as follows.
// Adds an image to a page.
page.Elements.Add( new Image( ImageData.GetImage( stream ), 0, 0 ) );
' Adds an image to a page.
MyPage.Elements.Add( New Image( ImageData.GetImage( MyStream ), 0, 0 ) )
Adding Images From A System.Drawing.Bitmap Object
Images can be created from a bitmap object as follows.
// Adds an image to a page.
page.Elements.Add( new Image( bitmap, 0, 0 ) );
' Adds an image to a page.
MyPage.Elements.Add( New Image( MyBitmap, 0, 0 ) )
Adding Images From A Byte Array
Images can be created from a database field or byte array as follows.
// Adds an image from a byte array to a page.
page.Elements.Add( new Image( ImageData.GetImage( byteArray ), 0, 0 ) );
' Adds an image from a byte array to a page.
MyPage.Elements.Add( New Image( ImageData.GetImage( MyByteArray ), 0, 0 ) )
Adding Images From A Database Field
Images can be created from a database field or byte array as follows.
// The "dataReader" variable is a DataReader object.
page.Elements.Add( new Image( ImageData.GetImage( (byte[])dataReader["ImageField"] ), 0, 0 ) );
' The "MyDataReader" variable is a DataReader object.
MyPage.Elements.Add( New Image( ImageData.GetImage( CType( MyDataReader("ImageField"), Byte() ) ), 0, 0 ) )
Further Information
Refer to the following topics for more information on Images.
Image Formats | Lists and Explains the different image formats that are supported. |
Image Resolution | Explains how to set and adjust the resolution and size of images. |
Tiff Images | Explains the different options for Tiff images that are supported. |
Image Reuse | Explains how to most efficiently use reuse images. |