Class PictureWatermark
Represents the picture that appears behind the document.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class PictureWatermark : Watermark, IXDLSSerializable, IWidget, IParagraphItem, IEntity, IOfficeRun
Examples
The following code snippet illustrates how to add a picture watermark to the Word document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add a section and a paragraph in the document
document.EnsureMinimal();
IWParagraph paragraph = document.LastParagraph;
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
//Create a new picture watermark
PictureWatermark picWatermark = new PictureWatermark();
//Set the scaling to picture
picWatermark.Scaling = 120f;
picWatermark.Washout = true;
//Set the picture watermark to document
document.Watermark = picWatermark;
//Set the image to the picture watermark
picWatermark.Picture = Image.FromFile("ImagesPath" + "Water lilies.jpg");
document.Save("PictureWatermark.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add a section and a paragraph in the document
document.EnsureMinimal()
Dim paragraph As IWParagraph = document.LastParagraph
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
'Create a new picture watermark
Dim picWatermark As New PictureWatermark()
'Set the scaling to picture
picWatermark.Scaling = 120.0F
picWatermark.Washout = True
Set the picture watermark to document
document.Watermark = picWatermark
Set the image to the picture watermark
picWatermark.Picture = Image.FromFile(ImagesPath + "Water lilies.jpg")
document.Save("PictureWatermark.docx", FormatType.Docx)
document.Close()
End Sub
Constructors
PictureWatermark()
Initializes a new instance of the PictureWatermark class.
Declaration
public PictureWatermark()
PictureWatermark(Image, Boolean)
Initializes a new instance of the PictureWatermark class with the specified System.Drawing.Image and Washout effect.
Declaration
public PictureWatermark(Image image, bool washout)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Image | image | Image that appear behind the document |
System.Boolean | washout | Washout property to set light shading effect to picture. |
Remarks
This constructor is not supported in Silverlight, WinRT, Windows Phone, Universal, Universal Windows Platform, MVC6 and Xamarin application.
Examples
The following code snippet illustrates how to add a picture watermark to the Word document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Create a new picture watermark
PictureWatermark picWatermark = new PictureWatermark(Image.FromFile("ImagesPath" + "Water lilies.jpg"), false);
//Set the picture watermark to document
document.Watermark = picWatermark;
document.Save("PictureWatermark.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Create a new picture watermark
Dim picWatermark As New PictureWatermark(Image.FromFile(ImagesPath + "Water lilies.jpg"), False)
'Set the picture watermark to document
document.Watermark = picWatermark
document.Save("PictureWatermark.docx", FormatType.Docx)
document.Close()
End Sub
Properties
Picture
Gets or sets the picture for picture watermark.
Declaration
public Image Picture { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image | The System.Drawing.Image that represents the picture. |
Remarks
This property is not supported in Silverlight, WinRT, Windows Phone, Universal, Universal Windows Platform, MVC6 and Xamarin application.
Scaling
Gets or sets the picture scaling value in percents.
Declaration
public float Scaling { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the picture scaling value. |
Washout
Gets or sets a value indicating whether the washout property is enabled for the picture watermark. The default value is true.
Declaration
public bool Washout { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to have light shading effect to picture; otherwise, false. |
Methods
CloneImpl()
Clones itself.
Declaration
protected override object CloneImpl()
Returns
Type | Description |
---|---|
System.Object | Returns cloned object. |
Overrides
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
Overrides
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |