public abstract class WatermarkableImage extends ContentPart
Represents an image inside a document.
This 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();
Modifier and Type | Method and Description |
---|---|
void |
add(Watermark watermark)
Adds a watermark to this
WatermarkableImage . |
byte[] |
getBytes()
Gets the image as byte array.
|
int |
getHeight()
Gets the height of this
WatermarkableImage in pixels. |
int |
getWidth()
Gets the width of this
WatermarkableImage in pixels. |
findImages, findImages, search, search
public final int getHeight()
Gets the height of this WatermarkableImage
in pixels.
WatermarkableImage
in pixels.public final int getWidth()
Gets the width of this WatermarkableImage
in pixels.
WatermarkableImage
in pixels.public final void add(Watermark watermark)
Adds a watermark to this WatermarkableImage
.
This method assumes that watermark offset and size are measured in pixels (if they are assigned).
watermark
- The watermark to add to the image.public final byte[] getBytes()
Gets the image as byte array.
Copyright © 2020. All rights reserved.