Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible

public Class PDVisibleSignDesigner

extends Object
Class Inheritance
Imports
java.awt.geom.AffineTransform, java.awt.image.BufferedImage, java.io.BufferedInputStream, .File, .FileInputStream, .IOException, .InputStream, javax.imageio.ImageIO, org.apache.pdfbox.pdmodel.PDDocument, .PDPage, org.apache.pdfbox.Loader, org.apache.pdfbox.io.RandomAccessRead, org.apache.pdfbox.pdmodel.common.PDRectangle

Class for visible signature design properties. Setters use param() instead of setParam() to allow chaining.
Author
Vakhtang Koroghlishvili

Field Summary

Modifier and TypeField and Description
private AffineTransform
private int[]
private BufferedImage
private Float
private float
private Float
private float
private float
private int
private String
private float
private float

Constructor Summary

AccessConstructor and Description
public
PDVisibleSignDesigner(String
Path of the PDF file
filename
,
InputStream
image as a stream
imageStream
,
int
The 1-based page number for which the page size should be calculated.
page
)

Constructor.

public
PDVisibleSignDesigner(RandomAccessRead
Original PDF document as RandomAccessRead
documentSource
,
InputStream
Image as a stream
imageStream
,
int
The 1-based page number for which the page size should be calculated.
page
)

Constructor.

public
PDVisibleSignDesigner(PDDocument
Already created PDDocument of your PDF document.
document
,
InputStream
Image as a stream.
imageStream
,
int
The 1-based page number for which the page size should be calculated.
page
)

Constructor.

public
PDVisibleSignDesigner(String
Path of the PDF file
filename
,
BufferedImage
the image to be used for the visible signature
image
,
int
The 1-based page number for which the page size should be calculated.
page
)

Constructor.

public
PDVisibleSignDesigner(RandomAccessRead
Original PDF document as RandomAccessRead
documentSource
,
BufferedImage
the image to be used for the visible signature
image
,
int
The 1-based page number for which the page size should be calculated.
page
)

Constructor.

public
PDVisibleSignDesigner(PDDocument
Already created PDDocument of your PDF document.
document
,
BufferedImage
the image to be used for the visible signature
image
,
int
The 1-based page number for which the page size should be calculated.
page
)

Constructor.

public
PDVisibleSignDesigner(InputStream
image as a stream
imageStream
)

Constructor usable for signing existing signature fields.

Method Summary

Modifier and TypeMethod and Description
public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
adjustForRotation
()

Adjust signature for page rotation.

private void
calculatePageSize(PDDocument document, int
The 1-based page number for which the page size should be calculated.
page
)

Each page of document can be different sizes.

private void
calculatePageSizeFromFile(String filename, int page)

private void
public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
coordinates
(float
- x coordinate
x
,
float
- y coordinate
y
)

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
formatterRectangleParameters
(int[]
rectangle parameter of the formatter
formatterRectangleParameters
)

Sets formatter PDRectangle

public int[]

Returns:

formatter PDRectangle parameters
getFormatterRectangleParameters
()

public float

Returns:

signature image height
getHeight
()

public BufferedImage

Returns:

image Image
getImage
()

public float

Returns:

the image size in percent
getImageSizeInPercents
()

get image size in percents

public float

Returns:

page height
getPageHeight
()

public float

Returns:

page width
getPageWidth
()

public String

Returns:

signature field name
getSignatureFieldName
()

public String

Returns:

the visible signature's text
getSignatureText
()

returns visible signature text

protected float

Returns:

template height
getTemplateHeight
()

public AffineTransform

Returns:

Affine Transform parameters for PDF Matrix
getTransform
()

public float

Returns:

signature image width
getWidth
()

public float

Returns:

xAxis - gets x coordinates
getxAxis
()

public float

Returns:

yAxis
getyAxis
()

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
height
(float
signature image height
height
)

public void
imageSizeInPercents(float
image size in percents
imageSizeInPercents
)

private PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
pageHeight
(float templateHeight)

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
pageWidth
(float
pageWidth
pageWidth
)

private void
readImageStream(InputStream
stream of your visible signature image
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.

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
signatureFieldName
(String
the name of the signature field
signatureFieldName
)

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
signatureImage
(String
Path of the image file.
path
)

Set the image for the signature.

public PDVisibleSignDesigner

Returns:

the signature design
signatureText
(String
- adds the text on visible signature
signatureText
)

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
transform
(AffineTransform
the affine transformation
affineTransform
)

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
width
(float
signature image width
width
)

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
xAxis
(float
- x coordinate
xAxis
)

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
yAxis
(float
y coordinate
yAxis
)

public PDVisibleSignDesigner

Returns:

Visible Signature Configuration Object
zoom
(float
increase (positive value) or decrease (negative value) image with x percent.
percent
)

Zoom signature image with some percent.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

affineTransformback to summary
private AffineTransform affineTransform
formatterRectangleParametersback to summary
private int[] formatterRectangleParameters
imageback to summary
private BufferedImage image
imageHeightback to summary
private Float imageHeight
imageSizeInPercentsback to summary
private float imageSizeInPercents
imageWidthback to summary
private Float imageWidth
pageHeightback to summary
private float pageHeight
pageWidthback to summary
private float pageWidth
rotationback to summary
private int rotation
signatureFieldNameback to summary
private String signatureFieldName
xAxisback to summary
private float xAxis
yAxisback to summary
private float yAxis

Constructor Detail

PDVisibleSignDesignerback to summary
public PDVisibleSignDesigner(String filename, InputStream imageStream, int page) throws IOException

Constructor.

Parameters
filename:String

Path of the PDF file

imageStream:InputStream

image as a stream

page:int

The 1-based page number for which the page size should be calculated.

Exceptions
IOException:
if the new instance of PDVisibleSignDesigner could not be created
PDVisibleSignDesignerback to summary
public PDVisibleSignDesigner(RandomAccessRead documentSource, InputStream imageStream, int page) throws IOException

Constructor.

Parameters
documentSource:RandomAccessRead

Original PDF document as RandomAccessRead

imageStream:InputStream

Image as a stream

page:int

The 1-based page number for which the page size should be calculated.

Exceptions
IOException:
if the new instance of PDVisibleSignDesigner could not be created
PDVisibleSignDesignerback to summary
public PDVisibleSignDesigner(PDDocument document, InputStream imageStream, int page) throws IOException

Constructor.

Parameters
document:PDDocument

Already created PDDocument of your PDF document.

imageStream:InputStream

Image as a stream.

page:int

The 1-based page number for which the page size should be calculated.

Exceptions
IOException:
If we can't read, flush, or can't close stream.
PDVisibleSignDesignerback to summary
public PDVisibleSignDesigner(String filename, BufferedImage image, int page) throws IOException

Constructor.

Parameters
filename:String

Path of the PDF file

image:BufferedImage

the image to be used for the visible signature

page:int

The 1-based page number for which the page size should be calculated.

Exceptions
IOException:
if the new instance of PDVisibleSignDesigner could not be created
PDVisibleSignDesignerback to summary
public PDVisibleSignDesigner(RandomAccessRead documentSource, BufferedImage image, int page) throws IOException

Constructor.

Parameters
documentSource:RandomAccessRead

Original PDF document as RandomAccessRead

image:BufferedImage

the image to be used for the visible signature

page:int

The 1-based page number for which the page size should be calculated.

Exceptions
IOException:
if the new instance of PDVisibleSignDesigner could not be created
PDVisibleSignDesignerback to summary
public PDVisibleSignDesigner(PDDocument document, BufferedImage image, int page)

Constructor.

Parameters
document:PDDocument

Already created PDDocument of your PDF document.

image:BufferedImage

the image to be used for the visible signature

page:int

The 1-based page number for which the page size should be calculated.

PDVisibleSignDesignerback to summary
public PDVisibleSignDesigner(InputStream imageStream) throws IOException

Constructor usable for signing existing signature fields.

Parameters
imageStream:InputStream

image as a stream

Exceptions
IOException:
if the new instance of PDVisibleSignDesigner could not be created

Method Detail

adjustForRotationback to summary
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:PDVisibleSignDesigner

Visible Signature Configuration Object

calculatePageSizeback to summary
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
page:int

The 1-based page number for which the page size should be calculated.

Exceptions
IllegalArgumentException:
if the page argument is lower than 0.
calculatePageSizeFromFileback to summary
private void calculatePageSizeFromFile(String filename, int page) throws IOException
calculatePageSizeFromRandomAccessReadback to summary
private void calculatePageSizeFromRandomAccessRead(RandomAccessRead documentSource, int page) throws IOException
coordinatesback to summary
public PDVisibleSignDesigner coordinates(float x, float y)
Parameters
x:float

- x coordinate

y:float

- y coordinate

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

formatterRectangleParametersback to summary
public PDVisibleSignDesigner formatterRectangleParameters(int[] formatterRectangleParameters)

Sets formatter PDRectangle

Parameters
formatterRectangleParameters:int[]

rectangle parameter of the formatter

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

getFormatterRectangleParametersback to summary
public int[] getFormatterRectangleParameters()
Returns:int[]

formatter PDRectangle parameters

getHeightback to summary
public float getHeight()
Returns:float

signature image height

getImageback to summary
public BufferedImage getImage()
Returns:BufferedImage

image Image

getImageSizeInPercentsback to summary
public float getImageSizeInPercents()

get image size in percents

Returns:float

the image size in percent

getPageHeightback to summary
public float getPageHeight()
Returns:float

page height

getPageWidthback to summary
public float getPageWidth()
Returns:float

page width

getSignatureFieldNameback to summary
public String getSignatureFieldName()
Returns:String

signature field name

getSignatureTextback to summary
public String getSignatureText()

returns visible signature text

Returns:String

the visible signature's text

getTemplateHeightback to summary
protected float getTemplateHeight()
Returns:float

template height

getTransformback to summary
public AffineTransform getTransform()
Returns:AffineTransform

Affine Transform parameters for PDF Matrix

getWidthback to summary
public float getWidth()
Returns:float

signature image width

getxAxisback to summary
public float getxAxis()
Returns:float

xAxis - gets x coordinates

getyAxisback to summary
public float getyAxis()
Returns:float

yAxis

heightback to summary
public PDVisibleSignDesigner height(float height)
Parameters
height:float

signature image height

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

imageSizeInPercentsback to summary
public void imageSizeInPercents(float imageSizeInPercents)
Parameters
imageSizeInPercents:float

image size in percents

pageHeightback to summary
private PDVisibleSignDesigner pageHeight(float templateHeight)
Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

pageWidthback to summary
public PDVisibleSignDesigner pageWidth(float pageWidth)
Parameters
pageWidth:float

pageWidth

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

readImageStreamback to summary
private void readImageStream(InputStream stream) throws IOException

Read the image stream of the signature and set height and width.

Parameters
stream:InputStream

stream of your visible signature image

Exceptions
IOException:
If we can't read, flush, or close stream of image
setImageback to summary
private void setImage(BufferedImage image)

Set image and its height and width.

signatureFieldNameback to summary
public PDVisibleSignDesigner signatureFieldName(String signatureFieldName)
Parameters
signatureFieldName:String

the name of the signature field

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

signatureImageback to summary
public PDVisibleSignDesigner signatureImage(String path) throws IOException

Set the image for the signature.

Parameters
path:String

Path of the image file.

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

Exceptions
IOException:
if the image for the signature could not be set
signatureTextback to summary
public PDVisibleSignDesigner signatureText(String signatureText)
Parameters
signatureText:String

- adds the text on visible signature

Returns:PDVisibleSignDesigner

the signature design

transformback to summary
public PDVisibleSignDesigner transform(AffineTransform affineTransform)
Parameters
affineTransform:AffineTransform

the affine transformation

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

widthback to summary
public PDVisibleSignDesigner width(float width)
Parameters
width:float

signature image width

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

xAxisback to summary
public PDVisibleSignDesigner xAxis(float xAxis)
Parameters
xAxis:float

- x coordinate

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

yAxisback to summary
public PDVisibleSignDesigner yAxis(float yAxis)
Parameters
yAxis:float

y coordinate

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object

zoomback to summary
public PDVisibleSignDesigner zoom(float percent)

Zoom signature image with some percent.

Parameters
percent:float

increase (positive value) or decrease (negative value) image with x percent.

Returns:PDVisibleSignDesigner

Visible Signature Configuration Object