Class PDVisibleSignDesigner
java.lang.Object
org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSignDesigner
Class for visible signature design properties. Setters use param() instead of setParam() to allow
chaining.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AffineTransform
private int[]
private byte[]
private BufferedImage
private Float
private float
private Float
private float
private float
private int
private String
private float
private float
-
Constructor Summary
ConstructorsConstructorDescriptionPDVisibleSignDesigner
(InputStream imageStream) Constructor usable for signing existing signature fields.PDVisibleSignDesigner
(InputStream documentStream, BufferedImage image, int page) Constructor.PDVisibleSignDesigner
(InputStream documentStream, InputStream imageStream, int page) Constructor.PDVisibleSignDesigner
(String filename, BufferedImage image, int page) Constructor.PDVisibleSignDesigner
(String filename, InputStream imageStream, int page) Constructor.PDVisibleSignDesigner
(PDDocument document, BufferedImage image, int page) Constructor.PDVisibleSignDesigner
(PDDocument document, InputStream imageStream, int page) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionAdjust signature for page rotation.affineTransformParams
(byte[] affineTransformParams) Deprecated.private void
calculatePageSize
(PDDocument document, int page) Each page of document can be different sizes.private void
calculatePageSizeFromFile
(String filename, int page) private void
calculatePageSizeFromStream
(InputStream documentStream, int page) coordinates
(float x, float y) formatterRectangleParameters
(int[] formatterRectangleParameters) Sets formatter PDRectangleformatterRectangleParams
(byte[] formatterRectangleParams) Deprecated.byte[]
Deprecated.usegetTransform()
.int[]
byte[]
Deprecated.float
getImage()
float
get image size in percentsfloat
float
returns visible signature textprotected float
float
getWidth()
float
getxAxis()
float
getyAxis()
height
(float height) void
imageSizeInPercents
(float imageSizeInPercents) private PDVisibleSignDesigner
pageHeight
(float templateHeight) pageWidth
(float pageWidth) private void
readImageStream
(InputStream stream) Read the image stream of the signature and set height and width.private void
setImage
(BufferedImage image) Set image and its height and width.signatureFieldName
(String signatureFieldName) signatureImage
(String path) Set the image for the signature.signatureText
(String signatureText) transform
(AffineTransform affineTransform) width
(float width) xAxis
(float xAxis) yAxis
(float yAxis) zoom
(float percent) Zoom signature image with some percent.
-
Field Details
-
imageWidth
-
imageHeight
-
xAxis
private float xAxis -
yAxis
private float yAxis -
pageHeight
private float pageHeight -
pageWidth
private float pageWidth -
image
-
signatureFieldName
-
formatterRectangleParams
private byte[] formatterRectangleParams -
formatterRectangleParameters
private int[] formatterRectangleParameters -
affineTransform
-
imageSizeInPercents
private float imageSizeInPercents -
rotation
private int rotation
-
-
Constructor Details
-
PDVisibleSignDesigner
Constructor.- Parameters:
filename
- Path of the PDF fileimageStream
- image as a streampage
- The 1-based page number for which the page size should be calculated.- Throws:
IOException
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(InputStream documentStream, InputStream imageStream, int page) throws IOException Constructor.- Parameters:
documentStream
- Original PDF document as streamimageStream
- Image as a streampage
- The 1-based page number for which the page size should be calculated.- Throws:
IOException
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(PDDocument document, InputStream imageStream, int page) throws IOException Constructor.- Parameters:
document
- Already created PDDocument of your PDF document.imageStream
- Image as a stream.page
- The 1-based page number for which the page size should be calculated.- Throws:
IOException
- If we can't read, flush, or can't close stream.
-
PDVisibleSignDesigner
Constructor.- Parameters:
filename
- Path of the PDF fileimage
-page
- The 1-based page number for which the page size should be calculated.- Throws:
IOException
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(InputStream documentStream, BufferedImage image, int page) throws IOException Constructor.- Parameters:
documentStream
- Original PDF document as streamimage
-page
- The 1-based page number for which the page size should be calculated.- Throws:
IOException
-
PDVisibleSignDesigner
Constructor.- Parameters:
document
- Already created PDDocument of your PDF document.image
-page
- The 1-based page number for which the page size should be calculated.
-
PDVisibleSignDesigner
Constructor usable for signing existing signature fields.- Parameters:
imageStream
- image as a stream- Throws:
IOException
-
-
Method Details
-
calculatePageSizeFromFile
- Throws:
IOException
-
calculatePageSizeFromStream
- Throws:
IOException
-
calculatePageSize
Each page of document can be different sizes. This method calculates the page size based on the page media box.- Parameters:
document
-page
- The 1-based page number for which the page size should be calculated.- Throws:
IllegalArgumentException
- if the page argument is lower than 0.
-
adjustForRotation
Adjust signature for page rotation. This is optional, call this after all x and y coordinates have been set if you want the signature to be positioned regardless of page orientation.- Returns:
- Visible Signature Configuration Object
-
signatureImage
Set the image for the signature.- Parameters:
path
- Path of the image file.- Returns:
- Visible Signature Configuration Object
- Throws:
IOException
-
zoom
Zoom signature image with some percent.- Parameters:
percent
- increase (positive value) or decrease (negative value) image with x percent.- Returns:
- Visible Signature Configuration Object
-
coordinates
- Parameters:
x
- - x coordinatey
- - y coordinate- Returns:
- Visible Signature Configuration Object
-
getxAxis
public float getxAxis()- Returns:
- xAxis - gets x coordinates
-
xAxis
- Parameters:
xAxis
- - x coordinate- Returns:
- Visible Signature Configuration Object
-
getyAxis
public float getyAxis()- Returns:
- yAxis
-
yAxis
- Parameters:
yAxis
-- Returns:
- Visible Signature Configuration Object
-
getWidth
public float getWidth()- Returns:
- signature image width
-
width
- Parameters:
width
- signature image width- Returns:
- Visible Signature Configuration Object
-
getHeight
public float getHeight()- Returns:
- signature image height
-
height
- Parameters:
height
- signature image height- Returns:
- Visible Signature Configuration Object
-
getTemplateHeight
protected float getTemplateHeight()- Returns:
- template height
-
pageHeight
- Parameters:
templateHeight
-- Returns:
- Visible Signature Configuration Object
-
getSignatureFieldName
- Returns:
- signature field name
-
signatureFieldName
- Parameters:
signatureFieldName
-- Returns:
- Visible Signature Configuration Object
-
getImage
- Returns:
- image Image
-
readImageStream
Read the image stream of the signature and set height and width.- Parameters:
stream
- stream of your visible signature image- Throws:
IOException
- If we can't read, flush, or close stream of image
-
setImage
Set image and its height and width.- Parameters:
image
-
-
getAffineTransformParams
Deprecated.usegetTransform()
.- Returns:
- Affine Transform parameters for PDF Matrix
-
getTransform
- Returns:
- Affine Transform parameters for PDF Matrix
-
affineTransformParams
Deprecated.- Parameters:
affineTransformParams
-- Returns:
- Visible Signature Configuration Object
-
transform
- Parameters:
affineTransform
-- Returns:
- Visible Signature Configuration Object
-
getFormatterRectangleParams
Deprecated.- Returns:
- formatter PDRectangle parameters
-
getFormatterRectangleParameters
public int[] getFormatterRectangleParameters()- Returns:
- formatter PDRectangle parameters
-
formatterRectangleParams
Deprecated.Sets formatter PDRectangle- Parameters:
formatterRectangleParams
-- Returns:
- Visible Signature Configuration Object
-
formatterRectangleParameters
Sets formatter PDRectangle- Parameters:
formatterRectangleParameters
-- Returns:
- Visible Signature Configuration Object
-
getPageWidth
public float getPageWidth()- Returns:
- page width
-
pageWidth
- Parameters:
pageWidth
- pageWidth- Returns:
- Visible Signature Configuration Object
-
getPageHeight
public float getPageHeight()- Returns:
- page height
-
getImageSizeInPercents
public float getImageSizeInPercents()get image size in percents- Returns:
- the image size in percent
-
imageSizeInPercents
public void imageSizeInPercents(float imageSizeInPercents) - Parameters:
imageSizeInPercents
-
-
getSignatureText
returns visible signature text- Returns:
- the visible signature's text
-
signatureText
- Parameters:
signatureText
- - adds the text on visible signature- Returns:
- the signature design
-
transform(java.awt.geom.AffineTransform)
.