cete.dynamicpdf.pageelements.textwatermark
TextWatermark
- Namespace: ceTe.DynamicPDF.PageElements
- Assemblies: DynamicPDF.CoreSuite.dll
Represents a Text Watermark.
public class TextWatermark : Watermark, IAnnotation, ISerializable
Public Class TextWatermark
Inherits Watermark
Implements IAnnotation, ISerializable
Inheritance: Object → PageElement → TaggablePageElement → Watermark → TextWatermark
Implements: IAnnotation, ISerializable
Examples
The following example will place a Text 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 the string and Text Watermark
Dim text As string = "This is a text watermark."
Dim twm As TextWatermark= new TextWatermark(text);
' Add the TextWatermark to the page
MyPage.Elements.Add(twm);
' 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)
{
// 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 the string and Text Watermark
string text = "This is a text watermark.";
TextWatermark twm = new TextWatermark(text);
// Add the TextWatermark and the link to the page
page.Elements.Add(twm);
// Save the PDF
document.Draw(outputPath);
}
}
Remarks
This class can be used to place Text Watermark on the PDF.
Constructors
TextWatermark(String)
Initializes a new instance of the TextWatermark class.
public TextWatermark(string text)
Public Sub New (text As String)
Parameters
- text: String
Text to display in the Watermark.
TextWatermark(String, Font)
Initializes a new instance of the TextWatermark class.
public TextWatermark(string text, Font font)
Public Sub New (text As String, font As Font)
Parameters
- text: String
Text to display in the Watermark.
- font: Font
Font for the text of the Watermark.
TextWatermark(String, Font, Single)
Initializes a new instance of the TextWatermark class.
public TextWatermark(string text, Font font, float fontSize)
Public Sub New (text As String, font As Font, fontSize As Single)
Parameters
- text: String
Text to display in the Watermark.
- font: Font
Font for the text of the Watermark.
- fontSize: Single
Font size of the text of the Watermark.
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
AutoScale
Gets or sets the AutoScale Property of the WaterMark.
public bool AutoScale { get; set; }
Public Property AutoScale As Boolean
Property Value
Font
Gets or sets the Font object to use for the text of the WaterMark.
public Font Font { get; set; }
Public Property Font As Font
Property Value
FontSize
Gets or sets the font size for the text of the WaterMark.
public float FontSize { get; set; }
Public Property FontSize 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);
}
}
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);
}
}
ScalingPercentage
Gets or sets the Scale Percentage of the WaterMark.
public int ScalingPercentage { get; set; }
Public Property ScalingPercentage As Int32
Property Value
Strikethrough
Gets or sets the strike through to use for the text of the WaterMark.
public bool Strikethrough { get; set; }
Public Property Strikethrough As Boolean
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
Text
Gets or sets the Text of the WaterMark.
public string Text { get; set; }
Public Property Text As String
Property Value
TextColor
Gets or sets the Color object to use for the text of the WaterMark.
public Color TextColor { get; set; }
Public Property TextColor As Color
Property Value
TextOutlineColor
Gets or sets the Color object to use for the text outline of the WaterMark.
public Color TextOutlineColor { get; set; }
Public Property TextOutlineColor As Color
Property Value
TextOutlineWidth
Gets or sets the line width to use for the text outline of the WaterMark.
public float TextOutlineWidth { get; set; }
Public Property TextOutlineWidth As Single
Property Value
Underline
Gets or sets a value indicating if the WaterMark is underlined.
public bool Underline { get; set; }
Public Property Underline As Boolean
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 TextWatermark to the given PageWriter object.
public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)
Parameters
- writer: PageWriter
PageWriter object to receive the textWatermark's output.
DrawAnnotation(DocumentWriter)
Draws the TextWatermark 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 .