Skip to main content

BackgroundImage

Version: 7.0

cete.dynamicpdf.pageelements.backgroundimage

BackgroundImage​

Represents a background image.

public class BackgroundImage : TaggablePageElement, ISerializable
Public Class BackgroundImage
Inherits TaggablePageElement
Implements ISerializable

Inheritance: Object → PageElement → TaggablePageElement → BackgroundImage

Implements: ISerializable

Licensing​

This class is a DynamicPDF Generator Professional Edition feature, except for the use of 64 bit PNG images (in this case see below). One of the following licenses is required for non-evaluation usage:

  • DynamicPDF Generator for .NET Professional Edition
  • DynamicPDF Generator for .NET Enterprise Edition
  • DynamicPDF Merger for .NET Professional Edition
  • DynamicPDF Merger for .NET Enterprise Edition
  • DynamicPDF ReportWriter for .NET Professional Edition
  • DynamicPDF ReportWriter for .NET Enterprise Edition
  • DynamicPDF Core Suite for .NET Professional Edition
  • DynamicPDF Core Suite for .NET Enterprise Edition

Use of 64 bit PNG images with this class is an Enterprise Edition feature. One of the following licenses is required for non-evaluation usage:

  • DynamicPDF Generator for .NET Enterprise Edition
  • DynamicPDF Merger for .NET Enterprise Edition
  • DynamicPDF ReportWriter for .NET Enterprise Edition
  • DynamicPDF Core Suite for .NET Enterprise Edition

Examples​

The following example will place an image on the page making it the background for that 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 a background image
Dim MyBackgroundImage As BackgroundImage = New BackgroundImage("C:\MyImage.jpg")

' Place the image with in the page margins
MyBackgroundImage.UseMargins = True

' Add the background image to the page
MyPage.Elements.Add(MyBackgroundImage)

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

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

class MyClass
{
static void Main()
{
// 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 a background image
BackgroundImage backgroundImage = new BackgroundImage( @"C:\MyImage.jpg" );

// Place the image with in the page margins
backgroundImage.UseMargins = true;
// Add the background image to the page
page.Elements.Add( backgroundImage );

//Save the PDF
document.Draw( @"C:\MyDocument.pdf" );
}
}

Remarks​

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

Constructors​

BackgroundImage(ImageData)​

Initializes a new instance of the BackgroundImage class.

public BackgroundImage(ImageData imageData)
Public Sub New (imageData As ImageData)

Parameters​

ImageData object containing the image data.

BackgroundImage(Stream)​

Initializes a new instance of the BackgroundImage class.

public BackgroundImage(Stream stream)
Public Sub New (stream As Stream)

Parameters​

Stream object containing the image data.

BackgroundImage(String)​

Initializes a new instance of the BackgroundImage class.

public BackgroundImage(string filePath)
Public Sub New (filePath As String)

Parameters​

The physical file path to the background image.

Properties​

BottomPadding​

Get or set the bottom padding of the background image.

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

Property Value​

Int32

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

ImageData​

Get the background image's ImageData object.

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

Property Value​

ImageData

LeftPadding​

Get or set the left padding of the background image.

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

Property Value​

Int32

RightPadding​

Get or set the right padding of the background image.

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

Property Value​

Int32

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​

This property is a DynamicPDF Generator Enterprise Edition feature. One of the following licenses is required for non-evaluation usage:

  • DynamicPDF Generator for .NET Enterprise Edition
  • DynamicPDF Merger for .NET Enterprise Edition
  • DynamicPDF ReportWriter for .NET Enterprise Edition
  • DynamicPDF Core Suite for .NET Enterprise Edition

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

TopPadding​

Get or set the top padding of the background image.

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

Property Value​

Int32

UseMargins​

Get or set a value indicating if the pages margins should be used when calculating the placement of the background image.

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

Property Value​

Boolean

Methods​

Draw(PageWriter)​

Draws the background image to the given PageWriter object.

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

Parameters​

PageWriter object to receive the background image's output.

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.

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 .

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.

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 .

See Also​

ceTe.DynamicPDF.PageElements