Class Watermarker
java.lang.Object
com.lowagie.toolbox.plugins.watermarker.Watermarker
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Color
private BaseFont
private final int
private final float
private final ByteArrayOutputStream
private final PdfReader
private final PdfStamper
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionWatermarker
(byte[] input, String text, int fontsize, float opacity) The main constructor with all mandatory arguments. -
Method Summary
Modifier and TypeMethodDescriptionTo change the default black color by a new one.byte[]
write()
Write the watermark to the pdf given in entry.
-
Field Details
-
reader
-
outputStream
-
stamp
-
text
-
fontsize
private final int fontsize -
opacity
private final float opacity -
color
-
font
-
-
Constructor Details
-
Watermarker
public Watermarker(byte[] input, String text, int fontsize, float opacity) throws 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:
IOException
- on errorDocumentException
- on error
-
-
Method Details
-
withColor
To change the default black color by a new one.- Parameters:
color
- the new color to use- Returns:
- the current builder instance
-
withFont
-
write
Write the watermark to the pdf given in entry.- Returns:
- a brand new byte[] without modifying the original one.
- Throws:
IOException
- on errorDocumentException
- on error
-