Class SignatureOptions
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureOptions
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class SignatureOptions extends java.lang.Object implements java.io.Closeable
This contains the visual signature as a COSDocument, its preferred size and the page.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_SIGNATURE_SIZE
private int
pageNo
private RandomAccessRead
pdfSource
private int
preferredSignatureSize
private COSDocument
visualSignature
-
Constructor Summary
Constructors Constructor Description SignatureOptions()
Creates the default signature options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the visual signature COSDocument, if any.int
getPage()
Get the 0-based page number.int
getPreferredSignatureSize()
Get the preferred size of the signature.COSDocument
getVisualSignature()
Get the visual signature.private void
initFromRandomAccessRead(RandomAccessRead rar)
void
setPage(int pageNo)
Set the 0-based page number.void
setPreferredSignatureSize(int size)
Set the preferred size of the signature.void
setVisualSignature(java.io.File file)
Reads the visual signature from the given file.void
setVisualSignature(java.io.InputStream is)
Reads the visual signature from the given input stream.void
setVisualSignature(PDVisibleSigProperties visSignatureProperties)
Reads the visual signature from the given visual signature properties
-
-
-
Field Detail
-
visualSignature
private COSDocument visualSignature
-
preferredSignatureSize
private int preferredSignatureSize
-
pageNo
private int pageNo
-
pdfSource
private RandomAccessRead pdfSource
-
DEFAULT_SIGNATURE_SIZE
public static final int DEFAULT_SIGNATURE_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setPage
public void setPage(int pageNo)
Set the 0-based page number.- Parameters:
pageNo
- the page number
-
getPage
public int getPage()
Get the 0-based page number.- Returns:
- the page number
-
setVisualSignature
public void setVisualSignature(java.io.File file) throws java.io.IOException
Reads the visual signature from the given file.- Parameters:
file
- the file containing the visual signature- Throws:
java.io.IOException
- when something went wrong during parsing
-
setVisualSignature
public void setVisualSignature(java.io.InputStream is) throws java.io.IOException
Reads the visual signature from the given input stream.- Parameters:
is
- the input stream containing the visual signature- Throws:
java.io.IOException
- when something went wrong during parsing
-
initFromRandomAccessRead
private void initFromRandomAccessRead(RandomAccessRead rar) throws java.io.IOException
- Throws:
java.io.IOException
-
setVisualSignature
public void setVisualSignature(PDVisibleSigProperties visSignatureProperties) throws java.io.IOException
Reads the visual signature from the given visual signature properties- Parameters:
visSignatureProperties
- thePDVisibleSigProperties
object containing the visual signature- Throws:
java.io.IOException
- when something went wrong during parsing
-
getVisualSignature
public COSDocument getVisualSignature()
Get the visual signature.- Returns:
- the visual signature
-
getPreferredSignatureSize
public int getPreferredSignatureSize()
Get the preferred size of the signature.- Returns:
- the preferred size of the signature in bytes.
-
setPreferredSignatureSize
public void setPreferredSignatureSize(int size)
Set the preferred size of the signature.- Parameters:
size
- the size of the signature in bytes. Only values above 0 will be considered.
-
close
public void close() throws java.io.IOException
Closes the visual signature COSDocument, if any. Do not call this before you're saved your signed PDF document, or saving will fail because COSStream objects held both by the COSDocument and by the signed document would no longer be available.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- if the document could not be closed
-
-