java.lang.Object
com.aspose.words.Watermark
public class Watermark
- extends java.lang.Object
Represents class to work with document watermark.
To learn more, visit the Working with Watermark documentation article.
Example:
Shows how to create a text watermark.
Document doc = new Document();
// Add a plain text watermark.
doc.getWatermark().setText("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.
TextWatermarkOptions textWatermarkOptions = new TextWatermarkOptions();
textWatermarkOptions.setFontFamily("Arial");
textWatermarkOptions.setFontSize(36f);
textWatermarkOptions.setColor(Color.BLACK);
textWatermarkOptions.setLayout(WatermarkLayout.DIAGONAL);
textWatermarkOptions.isSemitrasparent(false);
doc.getWatermark().setText("Aspose Watermark", textWatermarkOptions);
doc.save(getArtifactsDir() + "Document.TextWatermark.docx");
// We can remove a watermark from a document like this.
if (doc.getWatermark().getType() == WatermarkType.TEXT)
doc.getWatermark().remove();
|
Property Getters/Setters Summary |
int | getType() | |
|
Gets the watermark type.
The value of the property is WatermarkType integer constant. |
|
Method Summary |
void | remove() | |
|
Removes the watermark.
|
void | setImage(java.awt.image.BufferedImage image) | |
|
Adds Image watermark into the document.
|
void | setImage(java.awt.image.BufferedImage image, ImageWatermarkOptions options) | |
|
Adds Image watermark into the document.
|
void | setImage(java.lang.String imagePath, ImageWatermarkOptions options) | |
|
Adds Image watermark into the document.
|
void | setText(java.lang.String text) | |
|
Adds Text watermark into the document.
|
void | setText(java.lang.String text, TextWatermarkOptions options) | |
|
Adds Text watermark into the document.
|
|
Property Getters/Setters Detail |
getType | |
public int getType()
|
-
Gets the watermark type.
The value of the property is WatermarkType integer constant.
Example:
Shows how to create a text watermark.
Document doc = new Document();
// Add a plain text watermark.
doc.getWatermark().setText("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.
TextWatermarkOptions textWatermarkOptions = new TextWatermarkOptions();
textWatermarkOptions.setFontFamily("Arial");
textWatermarkOptions.setFontSize(36f);
textWatermarkOptions.setColor(Color.BLACK);
textWatermarkOptions.setLayout(WatermarkLayout.DIAGONAL);
textWatermarkOptions.isSemitrasparent(false);
doc.getWatermark().setText("Aspose Watermark", textWatermarkOptions);
doc.save(getArtifactsDir() + "Document.TextWatermark.docx");
// We can remove a watermark from a document like this.
if (doc.getWatermark().getType() == WatermarkType.TEXT)
doc.getWatermark().remove();
remove | |
public void remove() |
-
Removes the watermark.
Example:
Shows how to create a text watermark.
Document doc = new Document();
// Add a plain text watermark.
doc.getWatermark().setText("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.
TextWatermarkOptions textWatermarkOptions = new TextWatermarkOptions();
textWatermarkOptions.setFontFamily("Arial");
textWatermarkOptions.setFontSize(36f);
textWatermarkOptions.setColor(Color.BLACK);
textWatermarkOptions.setLayout(WatermarkLayout.DIAGONAL);
textWatermarkOptions.isSemitrasparent(false);
doc.getWatermark().setText("Aspose Watermark", textWatermarkOptions);
doc.save(getArtifactsDir() + "Document.TextWatermark.docx");
// We can remove a watermark from a document like this.
if (doc.getWatermark().getType() == WatermarkType.TEXT)
doc.getWatermark().remove();
setImage | |
public void setImage(java.awt.image.BufferedImage image)
throws java.lang.Exception |
-
Adds Image watermark into the document.
- Parameters:
image - Image that is displayed as a watermark.
Example:
Shows how to create a watermark from an image in the local file system.
Document doc = new Document();
// Modify the image watermark's appearance with an ImageWatermarkOptions object,
// then pass it while creating a watermark from an image file.
ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions();
imageWatermarkOptions.setScale(5.0);
imageWatermarkOptions.isWashout(false);
doc.getWatermark().setImage(ImageIO.read(new File(getImageDir() + "Logo.jpg")), imageWatermarkOptions);
doc.save(getArtifactsDir() + "Document.ImageWatermark.docx");
setImage | |
public void setImage(java.awt.image.BufferedImage image, ImageWatermarkOptions options)
throws java.lang.Exception |
-
Adds Image watermark into the document.
If ImageWatermarkOptions is
null, the watermark will be set with default options.- Parameters:
image - Image that is displayed as a watermark.options - Defines additional options for the image watermark.
Example:
Shows how to create a watermark from an image in the local file system.
Document doc = new Document();
// Modify the image watermark's appearance with an ImageWatermarkOptions object,
// then pass it while creating a watermark from an image file.
ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions();
imageWatermarkOptions.setScale(5.0);
imageWatermarkOptions.isWashout(false);
doc.getWatermark().setImage(ImageIO.read(new File(getImageDir() + "Logo.jpg")), imageWatermarkOptions);
doc.save(getArtifactsDir() + "Document.ImageWatermark.docx");
setImage | |
public void setImage(java.lang.String imagePath, ImageWatermarkOptions options)
throws java.lang.Exception |
-
Adds Image watermark into the document.
If ImageWatermarkOptions is
null, the watermark will be set with default options.- Parameters:
imagePath - Path to the image file that is displayed as a watermark.options - Defines additional options for the image watermark.
Example:
Shows how to create a watermark from an image in the local file system.
Document doc = new Document();
// Modify the image watermark's appearance with an ImageWatermarkOptions object,
// then pass it while creating a watermark from an image file.
ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions();
imageWatermarkOptions.setScale(5.0);
imageWatermarkOptions.isWashout(false);
doc.getWatermark().setImage(ImageIO.read(new File(getImageDir() + "Logo.jpg")), imageWatermarkOptions);
doc.save(getArtifactsDir() + "Document.ImageWatermark.docx");
setText | |
public void setText(java.lang.String text)
throws java.lang.Exception |
-
Adds Text watermark into the document.
The text length must be in the range from 1 to 200 inclusive.
The text cannot be
null or contain only whitespaces.
- Parameters:
text - Text that is displayed as a watermark.
Example:
Shows how to create a text watermark.
Document doc = new Document();
// Add a plain text watermark.
doc.getWatermark().setText("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.
TextWatermarkOptions textWatermarkOptions = new TextWatermarkOptions();
textWatermarkOptions.setFontFamily("Arial");
textWatermarkOptions.setFontSize(36f);
textWatermarkOptions.setColor(Color.BLACK);
textWatermarkOptions.setLayout(WatermarkLayout.DIAGONAL);
textWatermarkOptions.isSemitrasparent(false);
doc.getWatermark().setText("Aspose Watermark", textWatermarkOptions);
doc.save(getArtifactsDir() + "Document.TextWatermark.docx");
// We can remove a watermark from a document like this.
if (doc.getWatermark().getType() == WatermarkType.TEXT)
doc.getWatermark().remove();
setText | |
public void setText(java.lang.String text, TextWatermarkOptions options)
throws java.lang.Exception |
-
Adds Text watermark into the document.
The text length must be in the range from 1 to 200 inclusive.
The text cannot be
null or contain only whitespaces.
If TextWatermarkOptions is null, the watermark will be set with default options.- Parameters:
text - Text that is displayed as a watermark.options - Defines additional options for the text watermark.
Example:
Shows how to create a text watermark.
Document doc = new Document();
// Add a plain text watermark.
doc.getWatermark().setText("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.
TextWatermarkOptions textWatermarkOptions = new TextWatermarkOptions();
textWatermarkOptions.setFontFamily("Arial");
textWatermarkOptions.setFontSize(36f);
textWatermarkOptions.setColor(Color.BLACK);
textWatermarkOptions.setLayout(WatermarkLayout.DIAGONAL);
textWatermarkOptions.isSemitrasparent(false);
doc.getWatermark().setText("Aspose Watermark", textWatermarkOptions);
doc.save(getArtifactsDir() + "Document.TextWatermark.docx");
// We can remove a watermark from a document like this.
if (doc.getWatermark().getType() == WatermarkType.TEXT)
doc.getWatermark().remove();
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.