com.groupdocs.watermark

Interfaces

Classes

Exceptions

com.groupdocs.watermark

Class WatermarkableImage

  • Direct Known Subclasses:
    AttachmentWatermarkableImage, CellsWatermarkableImage, DiagramWatermarkableImage, PdfWatermarkableImage, SlidesWatermarkableImage, WordsWatermarkableImage


    public abstract class WatermarkableImage
    extends DocumentPart

    Represents an image inside a document.

    This example demonstrates how to add watermark to all images inside a document of any supported type.

    Document document = Document.load("D:\\input.doc");
     // Initialize text or image watermark.
     TextWatermark watermark = new TextWatermark("DRAFT", new Font("Arial", 19));
     // Find all images in the document.
     WatermarkableImageCollection images = document.findImages();
     // Add watermark.
     for (WatermarkableImage watermarkableImage : images)
     {
         watermarkableImage.addWatermark(watermark);
     }
     // Save changes.
     document.save("D:\\output.doc");
     document.close();
     
    • Method Detail

      • getHeight

        public final int getHeight()

        Gets the height of this WatermarkableImage in pixels.

        Returns:
        The height of this WatermarkableImage in pixels.
      • getWidth

        public final int getWidth()

        Gets the width of this WatermarkableImage in pixels.

        Returns:
        The width of this WatermarkableImage in pixels.
      • addWatermark

        public void addWatermark(Watermark watermark)

        Adds a watermark to this WatermarkableImage. This method assumes that watermark offset and size are measured in pixels (if they are assigned).

        Overrides:
        addWatermark in class DocumentPart
        Parameters:
        watermark - The watermark to add to the image.
      • getBytes

        public final byte[] getBytes()

        Gets the image as byte array.

        Returns:
        The image data.