public class PDFWatermark
extends java.lang.Object
PDFWatermark
provides access to PDF watermark creation and usage.
It contains: 1. Create watermark from text, image, bitmap or PDF page. 2. Insert watermark into a PDF page.
It can be constructed by the following way.
Example:
PDFWatermark watermark = PDFWatermark.createFromText(document,text,textProperty,watermarkSetting);
Modifier and Type | Class and Description |
---|---|
static class |
PDFWatermark.WatermarkSetting
WatermarkSetting class represents as watermark setting object.
|
static class |
PDFWatermark.WatermarkTextProperty
WatermarkTextProperty class represents as watermark text property object.
|
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_ASANNOT
If set, insert watermark as annotation.
|
static int |
FLAG_ASPAGECONTENTS
If set, insert watermark as page content (default).
|
static int |
FLAG_INVISIBLE
If set, do not display watermark.
|
static int |
FLAG_NOPRINT
If set, do not print watermark.
|
static int |
FLAG_ONTOP
If set, show watermark above other page contents.
|
static int |
FONTSTYLE_NORMAL
Watermark font style: normal.
|
static int |
FONTSTYLE_UNDERLINE
Watermark font style: with underline.
|
static int |
POS_BOTTOMCENTER
Watermark position: bottom center.
|
static int |
POS_BOTTOMLEFT
Watermark position: bottom left.
|
static int |
POS_BOTTOMRIGHT
Watermark position: bottom right.
|
static int |
POS_CENTER
Watermark position: center.
|
static int |
POS_CENTERLEFT
Watermark position: center left.
|
static int |
POS_CENTERRIGHT
Watermark position: center right.
|
static int |
POS_TOPCENTER
Watermark position: top center.
|
static int |
POS_TOPLEFT
Watermark position: top left.
|
static int |
POS_TOPRIGHT
Watermark position: top right.
|
static int |
TEXTALIGNMENT_CENTER
Text watermark alignment: center.
|
static int |
TEXTALIGNMENT_LEFT
Text watermark alignment: left.
|
static int |
TEXTALIGNMENT_RIGHT
Text watermark alignment: right.
|
Modifier and Type | Method and Description |
---|---|
static PDFWatermark |
create(PDFDocument document,
android.graphics.Bitmap bitmap,
PDFWatermark.WatermarkSetting settings)
Create a
PDFWatermark object from a specific Bitmap object. |
static PDFWatermark |
create(PDFDocument document,
Image image,
PDFWatermark.WatermarkSetting settings)
Create a
PDFWatermark object from a specific Image object. |
static PDFWatermark |
create(PDFDocument document,
PDFPage page,
PDFWatermark.WatermarkSetting settings)
Create a
PDFWatermark object from a specific PDFPage object. |
static PDFWatermark |
create(PDFDocument document,
java.lang.String text,
PDFWatermark.WatermarkTextProperty properties,
PDFWatermark.WatermarkSetting settings)
Create a
PDFWatermark object from a specific text string. |
long |
getHandle()
Get watermark handle
|
SizeF |
getSize()
Retrieve the size (width and height) of current watermark.
|
void |
insertToPage(PDFPage page)
Insert current watermark to a specific page.
|
void |
release()
Release current watermark object.
|
public static final int POS_TOPLEFT
public static final int POS_TOPCENTER
public static final int POS_TOPRIGHT
public static final int POS_CENTERLEFT
public static final int POS_CENTER
public static final int POS_CENTERRIGHT
public static final int POS_BOTTOMLEFT
public static final int POS_BOTTOMCENTER
public static final int POS_BOTTOMRIGHT
public static final int FLAG_ASPAGECONTENTS
public static final int FLAG_ASANNOT
public static final int FLAG_ONTOP
public static final int FLAG_NOPRINT
public static final int FLAG_INVISIBLE
public static final int FONTSTYLE_NORMAL
public static final int FONTSTYLE_UNDERLINE
public static final int TEXTALIGNMENT_LEFT
public static final int TEXTALIGNMENT_CENTER
public static final int TEXTALIGNMENT_RIGHT
public long getHandle()
public static PDFWatermark create(PDFDocument document, java.lang.String text, PDFWatermark.WatermarkTextProperty properties, PDFWatermark.WatermarkSetting settings) throws PDFException
PDFWatermark
object from a specific text string.document
- A PDFDocument
object, for which the created watermark will be used.text
- A text string, and it should be a valid String
object.
It specifies the content of watermark.properties
- A WatermarkTextProperty
object which specifies the text properties.settings
- A WatermarkSetting
object which specifies the layout settings.PDFWatermark
object that receives the watermark object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument
,
PDFWatermark.WatermarkTextProperty
,
PDFWatermark.WatermarkSetting
public static PDFWatermark create(PDFDocument document, Image image, PDFWatermark.WatermarkSetting settings) throws PDFException
PDFWatermark
object from a specific Image
object.
The Watermark
can only be set by one frame of the image,
so callers shall call
first to load a frame.
Image.loadFrame(int)
The Image
object should be released after the document is saved.
document
- A PDFDocument
object, for which the created watermark will be used.image
- A Image
object. A frame of it will be shown as a watermark.settings
- A WatermarkSetting
object which specifies the layout settings.PDFWatermark
object that receives the watermark object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument
,
Image
,
PDFWatermark.WatermarkSetting
public static PDFWatermark create(PDFDocument document, PDFPage page, PDFWatermark.WatermarkSetting settings) throws PDFException
PDFWatermark
object from a specific PDFPage
object.document
- A PDFDocument
object, for which the created watermark will be used.page
- A PDFPage
object which is to be shown as watermark.settings
- A WatermarkSetting
object which specifies the layout settings.PDFWatermark
object that receives the watermark object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument
,
PDFPage
,
PDFWatermark.WatermarkSetting
public static PDFWatermark create(PDFDocument document, android.graphics.Bitmap bitmap, PDFWatermark.WatermarkSetting settings) throws PDFException
PDFWatermark
object from a specific Bitmap
object.document
- A PDFDocument
object, for which the created watermark will be used.bitmap
- A Bitmap
object which is to be shown as watermark.settings
- A WatermarkSetting
object which specifies the layout settings.PDFWatermark
object that receives the watermark object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument
,
Bitmap
,
PDFWatermark.WatermarkSetting
public SizeF getSize() throws PDFException
SizeF
object that retrieves the size of watermark.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
SizeF
public void release() throws PDFException
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void insertToPage(PDFPage page) throws PDFException
To insert a watermark, application should ensure that current page has been parsed successfully.
page
- A PDFPage
object. Current watermark will be insert to this PDF page.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFPage