Class Watermarker
- java.lang.Object
-
- com.lowagie.toolbox.plugins.watermarker.Watermarker
-
public class Watermarker extends java.lang.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 Summary
Constructors Constructor Description Watermarker(byte[] input, java.lang.String text, int fontsize, float opacity)
The main constructor with all mandatory arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Watermarker
withColor(java.awt.Color color)
To change the default black color by a new one.Watermarker
withFont(BaseFont font)
byte[]
write()
Write the watermark to the pdf given in entry.
-
-
-
Field Detail
-
reader
private final PdfReader reader
-
outputStream
private final java.io.ByteArrayOutputStream outputStream
-
stamp
private final PdfStamper stamp
-
text
private final java.lang.String text
-
fontsize
private final int fontsize
-
opacity
private final float opacity
-
color
private java.awt.Color color
-
font
private BaseFont font
-
-
Constructor Detail
-
Watermarker
public Watermarker(byte[] input, java.lang.String text, int fontsize, float opacity) throws java.io.IOException, 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 watermarkfontsize
- the fontsize of the watermarkopacity
- the opacity of the watermark- Throws:
java.io.IOException
- on errorDocumentException
- on error
-
-
Method Detail
-
withColor
public Watermarker withColor(java.awt.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(BaseFont font)
-
write
public byte[] write() throws java.io.IOException, DocumentException
Write the watermark to the pdf given in entry.- Returns:
- a brand new byte[] without modifying the original one.
- Throws:
java.io.IOException
- on errorDocumentException
- on error
-
-