cete.dynamicpdf.pageelements.imagewatermark
ImageWatermark
- Namespace: ceTe.DynamicPDF.PageElements
- Assemblies: DynamicPDF.CoreSuite.dll
Represents a Image Watermark.
public class ImageWatermark : Watermark, IAnnotation, ISerializable
Public Class ImageWatermark
Inherits Watermark
Implements IAnnotation, ISerializable
Inheritance: Object → PageElement → TaggablePageElement → Watermark → ImageWatermark
Implements: IAnnotation, ISerializable
Examples
The following example will place a Image Watermark 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)
' Set PDF version to 1.6
MyDocument.PdfVersion = PdfVersion.v1_6
'Create an image for the watermark
Dim imageWm As ImageWatermark = new ImageWatermark(@"test.png")
' Add the image watermark to the page
MyPage.Elements.Add(imageWm);
' 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);
//Set PDF version to 1.6
document.PdfVersion = PdfVersion.v1_6;
// Create an image for the watermark
ImageWatermark imageWm = new ImageWatermark(imagePath);
// Add the image watermark to the page
page.Elements.Add(imageWm);
// Save the PDF
document.Draw(outputPath);
}
}
Remarks
This class can be used to place Image Watermark on the PDF.
Constructors
ImageWatermark(ImageData)
Initializes a new instance of the ImageWatermark class.
public ImageWatermark(ImageData imageData)
Public Sub New (imageData As ImageData)
Parameters
- imageData: ImageData
ImageData object containing the image data.
ImageWatermark(String)
Initializes a new instance of the ImageWatermark class.
public ImageWatermark(string filePath)
Public Sub New (filePath As String)
Parameters
- filePath: String
Physical file path of the image.
Properties
AlternateName
Gets or sets the Name of the WaterMark. (Inherited from Watermark)
public string AlternateName { get; set; }
Public Property AlternateName As String
Property Value
Angle
Gets or sets the heights of the angle of the WaterMark. (Inherited from Watermark)
public float Angle { get; set; }
Public Property Angle As Single
Property Value
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
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
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
Gets or sets ImageData .
public ImageData ImageData { get; set; }
Public Property ImageData As ImageData
Property Value
Name
Gets or sets the Name of the WaterMark. (Inherited from Watermark)
public string Name { get; set; }
Public Property Name As String
Property Value
Opacity
Gets or sets the opacity of the WaterMark. (Inherited from Watermark)
public float Opacity { get; set; }
Public Property Opacity As Single
Property Value
Position
Gets or sets the Position of the WaterMark. (Inherited from Watermark)
public WatermarkPosition Position { get; set; }
Public Property Position As WatermarkPosition
Property Value
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
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
ScaleY
Gets or sets the vertical scale of the image.
public float ScaleY { get; set; }
Public Property ScaleY As Single
Property Value
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
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
XOffset
Gets or sets the Horizontal Distance of the WaterMark. (Inherited from Watermark)
public float XOffset { get; set; }
Public Property XOffset As Single
Property Value
YOffset
Gets or sets the Vertical Distance of the WaterMark. (Inherited from Watermark)
public float YOffset { get; set; }
Public Property YOffset As Single
Property Value
Methods
Draw(PageWriter)
Draws the ImageWatermark to the given PageWriter object.
public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)
Parameters
- writer: PageWriter
PageWriter object to receive the imageWatermark's output.
DrawAnnotation(DocumentWriter)
Draws the ImageWatermark to the given DocumentWriter object.
public void DrawAnnotation(DocumentWriter writer)
Sub DrawAnnotation(writer As DocumentWriter)
Parameters
- writer: DocumentWriter
DocumentWriter object to receive the textWatermark'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
- obj: Object
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 .