WatermarkableImage
Inheritance: java.lang.Object, com.groupdocs.watermark.contents.ContentPart
public abstract class WatermarkableImage extends ContentPart
Represents an image inside a document.
Learn more:
The following example demonstrates how to add watermark to all images inside a document of any supported type.
Watermarker watermarker = new Watermarker(“D:\input.doc”);
// Initialize text or image watermark. TextWatermark watermark = new TextWatermark(“DRAFT”, new Font(“Arial”, 19));
// Find all images in the content. WatermarkableImageCollection images = watermarker.getImages();
// Add watermark. for (WatermarkableImage watermarkableImage : images) { watermarkableImage.add(watermark); }
// Save changes. watermarker.save(“D:\output.doc”); watermarker.close();
Constructors
Constructor | Description |
---|---|
WatermarkableImage(Content content) |
Methods
Method | Description |
---|---|
getHeight() | Gets the height of this [WatermarkableImage](../../com.groupdocs.watermark.contents/watermarkableimage) in pixels. |
getWidth() | Gets the width of this [WatermarkableImage](../../com.groupdocs.watermark.contents/watermarkableimage) in pixels. |
add(Watermark watermark) | Adds a watermark to this [WatermarkableImage](../../com.groupdocs.watermark.contents/watermarkableimage) . |
getBytes() | Gets the image as byte array. |
updateDocumentReference(Content parentContent) |
WatermarkableImage(Content content)
public WatermarkableImage(Content content)
Parameters:
Parameter | Type | Description |
---|---|---|
content | Content |
getHeight()
public final int getHeight()
Gets the height of this [WatermarkableImage](../../com.groupdocs.watermark.contents/watermarkableimage)
in pixels.
Returns:
int - The height of this [WatermarkableImage](../../com.groupdocs.watermark.contents/watermarkableimage)
in pixels.
getWidth()
public final int getWidth()
Gets the width of this [WatermarkableImage](../../com.groupdocs.watermark.contents/watermarkableimage)
in pixels.
Returns:
int - The width of this [WatermarkableImage](../../com.groupdocs.watermark.contents/watermarkableimage)
in pixels.
add(Watermark watermark)
public final void add(Watermark watermark)
Adds a watermark to this [WatermarkableImage](../../com.groupdocs.watermark.contents/watermarkableimage)
.
This method assumes that watermark offset and size are measured in pixels (if they are assigned).
Parameters:
Parameter | Type | Description |
---|---|---|
watermark | Watermark | The watermark to add to the image. |
getBytes()
public final byte[] getBytes()
Gets the image as byte array.
Returns: byte[] - The image data.
updateDocumentReference(Content parentContent)
public final void updateDocumentReference(Content parentContent)
Parameters:
Parameter | Type | Description |
---|---|---|
parentContent | Content |