java.lang.Object
com.lowagie.toolbox.plugins.watermarker.Watermarker

public class Watermarker extends Object
This class is the API equivalent of the WatermarkerTool. It lets you add a text watermark to all pages of a document given in input.
  • Constructor Details

    • Watermarker

      public Watermarker(byte[] input, String text, int fontsize, float opacity) throws IOException, com.lowagie.text.DocumentException
      The main constructor with all mandatory arguments. By default, the color stays black.
      Parameters:
      input - the pdf content as a byte[]
      text - the text to write as watermark
      fontsize - the fontsize of the watermark
      opacity - the opacity of the watermark
      Throws:
      IOException - on error
      com.lowagie.text.DocumentException - on error
  • Method Details

    • withColor

      public Watermarker withColor(Color color)
      To change the default black color by a new one.
      Parameters:
      color - the new color to use
      Returns:
      the current builder instance
    • withFont

      public Watermarker withFont(com.lowagie.text.pdf.BaseFont font)
    • write

      public byte[] write() throws IOException, com.lowagie.text.DocumentException
      Write the watermark to the pdf given in entry.
      Returns:
      a brand new byte[] without modifying the original one.
      Throws:
      IOException - on error
      com.lowagie.text.DocumentException - on error