Aspose::Words::Watermark Class Referencefinal

Detailed Description

Represents class to work with document watermark.

#include <Aspose.Words.Cpp/Watermark.h>

+ Inheritance diagram for Aspose::Words::Watermark:

Public Member Functions

WatermarkType get_Type ()
 Gets the watermark type. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void Remove ()
 Removes the watermark. More...
 
void SetImage (const SharedPtr< Image > &image)
 Adds Image watermark into the document. More...
 
void SetImage (const SharedPtr< Image > &image, const SharedPtr< ImageWatermarkOptions > &options)
 Adds Image watermark into the document. More...
 
void SetImage (const String &imagePath, const SharedPtr< ImageWatermarkOptions > &options)
 Adds Image watermark into the document. More...
 
void SetText (const String &text)
 Adds Text watermark into the document. More...
 
void SetText (const String &text, const SharedPtr< TextWatermarkOptions > &options)
 Adds Text watermark into the document. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ get_Type()

Aspose::Words::WatermarkType Aspose::Words::Watermark::get_Type ( )

Gets the watermark type.

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Watermark::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ Is()

virtual bool Aspose::Words::Watermark::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ Remove()

void Aspose::Words::Watermark::Remove ( )

Removes the watermark.

Examples

Shows how to create a text watermark.

auto doc = MakeObject<Document>();
// Add a plain text watermark.
doc->get_Watermark()->SetText(u"Aspose Watermark");
// If we wish to edit the text formatting using it as a watermark,
// we can do so by passing a TextWatermarkOptions object when creating the watermark.
auto textWatermarkOptions = MakeObject<TextWatermarkOptions>();
textWatermarkOptions->set_FontFamily(u"Arial");
textWatermarkOptions->set_FontSize(36.0f);
textWatermarkOptions->set_Color(System::Drawing::Color::get_Black());
textWatermarkOptions->set_Layout(WatermarkLayout::Diagonal);
textWatermarkOptions->set_IsSemitrasparent(false);
doc->get_Watermark()->SetText(u"Aspose Watermark", textWatermarkOptions);
doc->Save(ArtifactsDir + u"Document.TextWatermark.docx");
// We can remove a watermark from a document like this.
if (doc->get_Watermark()->get_Type() == WatermarkType::Text)
{
doc->get_Watermark()->Remove();
}

◆ SetImage() [1/3]

void Aspose::Words::Watermark::SetImage ( const System::SharedPtr< System::Drawing::Image > &  image)

Adds Image watermark into the document.

Parameters
imageImage that is displayed as a watermark.
Exceptions
System::ArgumentNullExceptionThrows when the image is null.

◆ SetImage() [2/3]

void Aspose::Words::Watermark::SetImage ( const System::SharedPtr< System::Drawing::Image > &  image,
const System::SharedPtr< Aspose::Words::ImageWatermarkOptions > &  options 
)

Adds Image watermark into the document.

Parameters
imageImage that is displayed as a watermark.
optionsDefines additional options for the image watermark.
Exceptions
System::ArgumentNullExceptionThrows when the image is null.
Examples

Shows how to create a watermark from an image in the local file system.

auto doc = MakeObject<Document>();
// Modify the image watermark's appearance with an ImageWatermarkOptions object,
// then pass it while creating a watermark from an image file.
auto imageWatermarkOptions = MakeObject<ImageWatermarkOptions>();
imageWatermarkOptions->set_Scale(5);
imageWatermarkOptions->set_IsWashout(false);
doc->get_Watermark()->SetImage(System::Drawing::Image::FromFile(ImageDir + u"Logo.jpg"), imageWatermarkOptions);
doc->Save(ArtifactsDir + u"Document.ImageWatermark.docx");

◆ SetImage() [3/3]

void Aspose::Words::Watermark::SetImage ( const System::String imagePath,
const System::SharedPtr< Aspose::Words::ImageWatermarkOptions > &  options 
)

Adds Image watermark into the document.

Parameters
imagePathPath to the image file that is displayed as a watermark.
optionsDefines additional options for the image watermark.
Exceptions
System::ArgumentNullExceptionThrows when the path is null.

◆ SetText() [1/2]

void Aspose::Words::Watermark::SetText ( const System::String text)

Adds Text watermark into the document.

Parameters
textText that is displayed as a watermark.
Exceptions
System::ArgumentOutOfRangeExceptionThrows when the text length is out of range or the text contains only whitespaces.
System::ArgumentNullExceptionThrows when the text is null.
Examples

Shows how to create a text watermark.

auto doc = MakeObject<Document>();
// Add a plain text watermark.
doc->get_Watermark()->SetText(u"Aspose Watermark");
// If we wish to edit the text formatting using it as a watermark,
// we can do so by passing a TextWatermarkOptions object when creating the watermark.
auto textWatermarkOptions = MakeObject<TextWatermarkOptions>();
textWatermarkOptions->set_FontFamily(u"Arial");
textWatermarkOptions->set_FontSize(36.0f);
textWatermarkOptions->set_Color(System::Drawing::Color::get_Black());
textWatermarkOptions->set_Layout(WatermarkLayout::Diagonal);
textWatermarkOptions->set_IsSemitrasparent(false);
doc->get_Watermark()->SetText(u"Aspose Watermark", textWatermarkOptions);
doc->Save(ArtifactsDir + u"Document.TextWatermark.docx");
// We can remove a watermark from a document like this.
if (doc->get_Watermark()->get_Type() == WatermarkType::Text)
{
doc->get_Watermark()->Remove();
}

◆ SetText() [2/2]

void Aspose::Words::Watermark::SetText ( const System::String text,
const System::SharedPtr< Aspose::Words::TextWatermarkOptions > &  options 
)

Adds Text watermark into the document.

Parameters
textText that is displayed as a watermark.
optionsDefines additional options for the text watermark.
Exceptions
System::ArgumentOutOfRangeExceptionThrows when the text length is out of range or the text contain only whitespaces.
System::ArgumentNullExceptionThrows when the text is null.
Examples

Shows how to create a text watermark.

auto doc = MakeObject<Document>();
// Add a plain text watermark.
doc->get_Watermark()->SetText(u"Aspose Watermark");
// If we wish to edit the text formatting using it as a watermark,
// we can do so by passing a TextWatermarkOptions object when creating the watermark.
auto textWatermarkOptions = MakeObject<TextWatermarkOptions>();
textWatermarkOptions->set_FontFamily(u"Arial");
textWatermarkOptions->set_FontSize(36.0f);
textWatermarkOptions->set_Color(System::Drawing::Color::get_Black());
textWatermarkOptions->set_Layout(WatermarkLayout::Diagonal);
textWatermarkOptions->set_IsSemitrasparent(false);
doc->get_Watermark()->SetText(u"Aspose Watermark", textWatermarkOptions);
doc->Save(ArtifactsDir + u"Document.TextWatermark.docx");
// We can remove a watermark from a document like this.
if (doc->get_Watermark()->get_Type() == WatermarkType::Text)
{
doc->get_Watermark()->Remove();
}

◆ Type()

static const System::TypeInfo& Aspose::Words::Watermark::Type ( )
static