Class Watermarker
java.lang.Object
org.openpdf.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 Colorprivate BaseFontprivate final intprivate final floatprivate final ByteArrayOutputStreamprivate final PdfReaderprivate final PdfStamperprivate 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
-