Class PDVisibleSignDesigner
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSignDesigner
-
public class PDVisibleSignDesigner extends java.lang.Object
Class for visible signature design properties. Setters use param() instead of setParam() to allow chaining.
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.geom.AffineTransform
affineTransform
private int[]
formatterRectangleParameters
private byte[]
formatterRectangleParams
private java.awt.image.BufferedImage
image
private java.lang.Float
imageHeight
private float
imageSizeInPercents
private java.lang.Float
imageWidth
private float
pageHeight
private float
pageWidth
private int
rotation
private java.lang.String
signatureFieldName
private float
xAxis
private float
yAxis
-
Constructor Summary
Constructors Constructor Description PDVisibleSignDesigner(java.io.InputStream imageStream)
Constructor usable for signing existing signature fields.PDVisibleSignDesigner(java.io.InputStream documentStream, java.awt.image.BufferedImage image, int page)
Constructor.PDVisibleSignDesigner(java.io.InputStream documentStream, java.io.InputStream imageStream, int page)
Constructor.PDVisibleSignDesigner(java.lang.String filename, java.awt.image.BufferedImage image, int page)
Constructor.PDVisibleSignDesigner(java.lang.String filename, java.io.InputStream imageStream, int page)
Constructor.PDVisibleSignDesigner(PDDocument document, java.awt.image.BufferedImage image, int page)
Constructor.PDVisibleSignDesigner(PDDocument document, java.io.InputStream imageStream, int page)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PDVisibleSignDesigner
adjustForRotation()
Adjust signature for page rotation.PDVisibleSignDesigner
affineTransformParams(byte[] affineTransformParams)
Deprecated.private void
calculatePageSize(PDDocument document, int page)
Each page of document can be different sizes.private void
calculatePageSizeFromFile(java.lang.String filename, int page)
private void
calculatePageSizeFromStream(java.io.InputStream documentStream, int page)
PDVisibleSignDesigner
coordinates(float x, float y)
PDVisibleSignDesigner
formatterRectangleParameters(int[] formatterRectangleParameters)
Sets formatter PDRectanglePDVisibleSignDesigner
formatterRectangleParams(byte[] formatterRectangleParams)
Deprecated.byte[]
getAffineTransformParams()
Deprecated.usegetTransform()
.int[]
getFormatterRectangleParameters()
byte[]
getFormatterRectangleParams()
Deprecated.float
getHeight()
java.awt.image.BufferedImage
getImage()
float
getImageSizeInPercents()
get image size in percentsfloat
getPageHeight()
float
getPageWidth()
java.lang.String
getSignatureFieldName()
java.lang.String
getSignatureText()
returns visible signature textprotected float
getTemplateHeight()
java.awt.geom.AffineTransform
getTransform()
float
getWidth()
float
getxAxis()
float
getyAxis()
PDVisibleSignDesigner
height(float height)
void
imageSizeInPercents(float imageSizeInPercents)
private PDVisibleSignDesigner
pageHeight(float templateHeight)
PDVisibleSignDesigner
pageWidth(float pageWidth)
private void
readImageStream(java.io.InputStream stream)
Read the image stream of the signature and set height and width.private void
setImage(java.awt.image.BufferedImage image)
Set image and its height and width.PDVisibleSignDesigner
signatureFieldName(java.lang.String signatureFieldName)
PDVisibleSignDesigner
signatureImage(java.lang.String path)
Set the image for the signature.PDVisibleSignDesigner
signatureText(java.lang.String signatureText)
PDVisibleSignDesigner
transform(java.awt.geom.AffineTransform affineTransform)
PDVisibleSignDesigner
width(float width)
PDVisibleSignDesigner
xAxis(float xAxis)
PDVisibleSignDesigner
yAxis(float yAxis)
PDVisibleSignDesigner
zoom(float percent)
Zoom signature image with some percent.
-
-
-
Field Detail
-
imageWidth
private java.lang.Float imageWidth
-
imageHeight
private java.lang.Float imageHeight
-
xAxis
private float xAxis
-
yAxis
private float yAxis
-
pageHeight
private float pageHeight
-
pageWidth
private float pageWidth
-
image
private java.awt.image.BufferedImage image
-
signatureFieldName
private java.lang.String signatureFieldName
-
formatterRectangleParams
private byte[] formatterRectangleParams
-
formatterRectangleParameters
private int[] formatterRectangleParameters
-
affineTransform
private java.awt.geom.AffineTransform affineTransform
-
imageSizeInPercents
private float imageSizeInPercents
-
rotation
private int rotation
-
-
Constructor Detail
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(java.lang.String filename, java.io.InputStream imageStream, int page) throws java.io.IOException
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:
java.io.IOException
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(java.io.InputStream documentStream, java.io.InputStream imageStream, int page) throws java.io.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:
java.io.IOException
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(PDDocument document, java.io.InputStream imageStream, int page) throws java.io.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:
java.io.IOException
- If we can't read, flush, or can't close stream.
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(java.lang.String filename, java.awt.image.BufferedImage image, int page) throws java.io.IOException
Constructor.- Parameters:
filename
- Path of the PDF fileimage
-page
- The 1-based page number for which the page size should be calculated.- Throws:
java.io.IOException
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(java.io.InputStream documentStream, java.awt.image.BufferedImage image, int page) throws java.io.IOException
Constructor.- Parameters:
documentStream
- Original PDF document as streamimage
-page
- The 1-based page number for which the page size should be calculated.- Throws:
java.io.IOException
-
PDVisibleSignDesigner
public PDVisibleSignDesigner(PDDocument document, java.awt.image.BufferedImage image, int page)
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
public PDVisibleSignDesigner(java.io.InputStream imageStream) throws java.io.IOException
Constructor usable for signing existing signature fields.- Parameters:
imageStream
- image as a stream- Throws:
java.io.IOException
-
-
Method Detail
-
calculatePageSizeFromFile
private void calculatePageSizeFromFile(java.lang.String filename, int page) throws java.io.IOException
- Throws:
java.io.IOException
-
calculatePageSizeFromStream
private void calculatePageSizeFromStream(java.io.InputStream documentStream, int page) throws java.io.IOException
- Throws:
java.io.IOException
-
calculatePageSize
private void calculatePageSize(PDDocument document, int page)
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:
java.lang.IllegalArgumentException
- if the page argument is lower than 0.
-
adjustForRotation
public PDVisibleSignDesigner 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
public PDVisibleSignDesigner signatureImage(java.lang.String path) throws java.io.IOException
Set the image for the signature.- Parameters:
path
- Path of the image file.- Returns:
- Visible Signature Configuration Object
- Throws:
java.io.IOException
-
zoom
public PDVisibleSignDesigner zoom(float percent)
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
public PDVisibleSignDesigner coordinates(float x, float y)
- Parameters:
x
- - x coordinatey
- - y coordinate- Returns:
- Visible Signature Configuration Object
-
getxAxis
public float getxAxis()
- Returns:
- xAxis - gets x coordinates
-
xAxis
public PDVisibleSignDesigner xAxis(float xAxis)
- Parameters:
xAxis
- - x coordinate- Returns:
- Visible Signature Configuration Object
-
getyAxis
public float getyAxis()
- Returns:
- yAxis
-
yAxis
public PDVisibleSignDesigner yAxis(float yAxis)
- Parameters:
yAxis
-- Returns:
- Visible Signature Configuration Object
-
getWidth
public float getWidth()
- Returns:
- signature image width
-
width
public PDVisibleSignDesigner width(float width)
- Parameters:
width
- signature image width- Returns:
- Visible Signature Configuration Object
-
getHeight
public float getHeight()
- Returns:
- signature image height
-
height
public PDVisibleSignDesigner height(float height)
- Parameters:
height
- signature image height- Returns:
- Visible Signature Configuration Object
-
getTemplateHeight
protected float getTemplateHeight()
- Returns:
- template height
-
pageHeight
private PDVisibleSignDesigner pageHeight(float templateHeight)
- Parameters:
templateHeight
-- Returns:
- Visible Signature Configuration Object
-
getSignatureFieldName
public java.lang.String getSignatureFieldName()
- Returns:
- signature field name
-
signatureFieldName
public PDVisibleSignDesigner signatureFieldName(java.lang.String signatureFieldName)
- Parameters:
signatureFieldName
-- Returns:
- Visible Signature Configuration Object
-
getImage
public java.awt.image.BufferedImage getImage()
- Returns:
- image Image
-
readImageStream
private void readImageStream(java.io.InputStream stream) throws java.io.IOException
Read the image stream of the signature and set height and width.- Parameters:
stream
- stream of your visible signature image- Throws:
java.io.IOException
- If we can't read, flush, or close stream of image
-
setImage
private void setImage(java.awt.image.BufferedImage image)
Set image and its height and width.- Parameters:
image
-
-
getAffineTransformParams
@Deprecated public byte[] getAffineTransformParams()
Deprecated.usegetTransform()
.- Returns:
- Affine Transform parameters for PDF Matrix
-
getTransform
public java.awt.geom.AffineTransform getTransform()
- Returns:
- Affine Transform parameters for PDF Matrix
-
affineTransformParams
@Deprecated public PDVisibleSignDesigner affineTransformParams(byte[] affineTransformParams)
Deprecated.- Parameters:
affineTransformParams
-- Returns:
- Visible Signature Configuration Object
-
transform
public PDVisibleSignDesigner transform(java.awt.geom.AffineTransform affineTransform)
- Parameters:
affineTransform
-- Returns:
- Visible Signature Configuration Object
-
getFormatterRectangleParams
@Deprecated public byte[] getFormatterRectangleParams()
Deprecated.- Returns:
- formatter PDRectangle parameters
-
getFormatterRectangleParameters
public int[] getFormatterRectangleParameters()
- Returns:
- formatter PDRectangle parameters
-
formatterRectangleParams
@Deprecated public PDVisibleSignDesigner formatterRectangleParams(byte[] formatterRectangleParams)
Deprecated.Sets formatter PDRectangle- Parameters:
formatterRectangleParams
-- Returns:
- Visible Signature Configuration Object
-
formatterRectangleParameters
public PDVisibleSignDesigner formatterRectangleParameters(int[] formatterRectangleParameters)
Sets formatter PDRectangle- Parameters:
formatterRectangleParameters
-- Returns:
- Visible Signature Configuration Object
-
getPageWidth
public float getPageWidth()
- Returns:
- page width
-
pageWidth
public PDVisibleSignDesigner pageWidth(float 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
public java.lang.String getSignatureText()
returns visible signature text- Returns:
- the visible signature's text
-
signatureText
public PDVisibleSignDesigner signatureText(java.lang.String signatureText)
- Parameters:
signatureText
- - adds the text on visible signature- Returns:
- the signature design
-
-