Class Appearance
The visual appearance of signatures
A signature may have a visual appearance on a page of the document. The visual appearance is optional and has no effect on the validity of the signature. Because of this and because a visual appearance may cover important content of the page, it is recommended to create invisible signatures by default.
Typically, a visual appearance is created for forms with a dedicated area reserved for the appearance. Other transaction documents, e.g. invoices, correspondence, or bank statements, are usually signed without a visual appearance.
The appearance can be positioned on a page using getPageNumber(), getTop(), getRight(),
getBottom(), and getLeft().
It is recommended to set either getTop() or getBottom() and getRight() or getLeft().
If all are null, the default is to position the appearance in the lower right corner with 12 pt
(1/6 inch or 4.2 mm) distance to the bottom and right edge of the page,
i.e. Bottom = 12 and Right = 12.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AppearancecreateFieldBoundingBox(Size size) Create the bounding box for an unsigned signature fieldstatic AppearancecreateFromJson(Stream stream) Create an appearance with the content loaded from a JSON filestatic AppearancecreateFromXml(Stream stream) Create an appearance with the content loaded from an XML fileDistance to bottom of page (Getter)Maps the name of a custom text variable to its value.getLeft()Distance to left of page (Getter)The number of the page where the appearance is positioned (Getter)getRight()Distance to right of page (Getter)getTop()Distance to top of page (Getter)voidDistance to bottom of page (Setter)voidDistance to left of page (Setter)voidsetPageNumber(Integer value) The number of the page where the appearance is positioned (Setter)voidDistance to right of page (Setter)voidDistance to top of page (Setter)Methods inherited from class com.pdftools.internal.NativeObject
equals, hashCode
-
Method Details
-
createFromJson
public static Appearance createFromJson(Stream stream) throws NotFoundException, GenericException, CorruptException, ProcessingException Create an appearance with the content loaded from a JSON file
The format of the JSON file is described in the user manual.- Parameters:
stream- The JSON file defining the content- Returns:
- Throws:
CorruptException- The file is not a valid JSON file.NotFoundException- An image or font referenced in the JSON was not found.GenericException- The JSON file is not a valid appearance content specification.ProcessingException- Could not process content of the JSON.IllegalArgumentException- ifstreamisnull
-
createFromXml
public static Appearance createFromXml(Stream stream) throws NotFoundException, GenericException, CorruptException, ProcessingException Create an appearance with the content loaded from an XML file
The format of the XML file is described in the user manual.- Parameters:
stream- The XML file defining the content- Returns:
- Throws:
CorruptException- The file is not a valid XML file.NotFoundException- An image or font referenced in the XML was not found.GenericException- The XML file is not a valid appearance content specification.ProcessingException- Could not process content of the XML.IllegalArgumentException- ifstreamisnull
-
createFieldBoundingBox
Create the bounding box for an unsigned signature field
Unsigned signature fields can define a rectangle on a page. When the field is signed, the signer creates a visual appearance within that rectangle.- Parameters:
size- The size of the rectangle- Returns:
- Throws:
IllegalArgumentException- ifsizeisnull
-
getPageNumber
The number of the page where the appearance is positioned (Getter)
Page number must be in the range from
1topdftools.pdf.Document.getPageCount.If
null, the appearance is positioned on the last page.Default:
null -
setPageNumber
The number of the page where the appearance is positioned (Setter)
Page number must be in the range from
1topdftools.pdf.Document.getPageCount.If
null, the appearance is positioned on the last page.Default:
null -
getTop
Distance to top of page (Getter)
This property specifies the distance between appearance's top edge and the top of the page.
If
null, the distance to the top is unspecified.Default:
null -
setTop
Distance to top of page (Setter)
This property specifies the distance between appearance's top edge and the top of the page.
If
null, the distance to the top is unspecified.Default:
null- Throws:
IllegalArgumentException- If the given value is negative
-
getRight
Distance to right of page (Getter)
This property specifies the distance between appearance's right edge and the right of the page.
If
null, the distance to the right is unspecified.Default:
null -
setRight
Distance to right of page (Setter)
This property specifies the distance between appearance's right edge and the right of the page.
If
null, the distance to the right is unspecified.Default:
null- Throws:
IllegalArgumentException- If the given value is negative
-
getBottom
Distance to bottom of page (Getter)
This property specifies the distance between appearance's bottom edge and the bottom of the page.
If
null, the distance to the bottom is unspecified.Default:
null -
setBottom
Distance to bottom of page (Setter)
This property specifies the distance between appearance's bottom edge and the bottom of the page.
If
null, the distance to the bottom is unspecified.Default:
null- Throws:
IllegalArgumentException- If the given value is negative
-
getLeft
Distance to left of page (Getter)
This property specifies the distance between appearance's left edge and the left of the page.
If
null, the distance to the left is unspecified.Default:
null -
setLeft
Distance to left of page (Setter)
This property specifies the distance between appearance's left edge and the left of the page.
If
null, the distance to the left is unspecified.Default:
null- Throws:
IllegalArgumentException- If the given value is negative
-
getCustomTextVariables
Maps the name of a custom text variable to its value. These variables can parametrize the content of the text element in the appearance configuration XML and Json files. They are used by setting "[custom:‹key›]".
-