Package com.logicaldoc.sign.pdf
Class CreateVisibleSignature
- java.lang.Object
-
- com.logicaldoc.sign.pdf.CreateSignatureBase
-
- com.logicaldoc.sign.pdf.CreateVisibleSignature
-
- All Implemented Interfaces:
org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface
public class CreateVisibleSignature extends CreateSignatureBase
Visually signs a PDF with pdf box. A keystore can be created with the java keytool.- Since:
- 7.7.2
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description CreateVisibleSignature(File ksFile, String keyStorePassword, String alias, String aliasPassword)
Initialize the signature creator with a keystore and certficate password
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isLateExternalSigning()
void
setLateExternalSigning(boolean lateExternalSigning)
Set late external signing.void
setVisibleSignatureProperties(String name, String location, String reason, int preferredSize, int page, boolean visualSignEnabled)
Set visible signature properties for new signature fields.void
setVisibleSignDesigner(String filename, int x, int y, int zoomPercent, FileInputStream imageStream, int page)
Set visible signature designer for a new signature field.void
setVisibleSignDesigner(String filename, int x, int y, Integer width, Integer height, FileInputStream imageStream, int page)
Set visible signature designer for a new signature field.void
signPDF(File inputFile, File signedFile)
Sign pdf file and create new file-
Methods inherited from class com.logicaldoc.sign.pdf.CreateSignatureBase
getMDPPermission, isExternalSigning, setCertificateChain, setExternalSigning, setMDPPermission, setPrivateKey, sign
-
-
-
-
Constructor Detail
-
CreateVisibleSignature
public CreateVisibleSignature(File ksFile, String keyStorePassword, String alias, String aliasPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, IOException, CertificateException
Initialize the signature creator with a keystore and certficate password- Parameters:
ksFile
- the java keystore file containing the signing certificatekeyStorePassword
- the password for opening the keystorealias
- the alias of the certificatealiasPassword
- the password to open the alias- Throws:
KeyStoreException
- if the keystore has not been initialized (loaded)NoSuchAlgorithmException
- if the algorithm for recovering the key cannot be foundUnrecoverableKeyException
- if the given password is wrongCertificateException
- if the certificate is not valid as signing timeIOException
- if no certificate could be found
-
-
Method Detail
-
isLateExternalSigning
public boolean isLateExternalSigning()
-
setLateExternalSigning
public void setLateExternalSigning(boolean lateExternalSigning)
Set late external signing. Enable this if you want to activate the demo code where the signature is kept and added in an extra step without using PDFBox methods. This is disabled by default.- Parameters:
lateExternalSigning
- external signing flag
-
setVisibleSignDesigner
public void setVisibleSignDesigner(String filename, int x, int y, int zoomPercent, FileInputStream imageStream, int page) throws IOException
Set visible signature designer for a new signature field.- Parameters:
filename
- name of the filex
- position of the signature fieldy
- position of the signature fieldzoomPercent
- zoom as percent 0..1imageStream
- content of the imagepage
- the signature should be placed on- Throws:
IOException
- cannot write the PDF file
-
setVisibleSignDesigner
public void setVisibleSignDesigner(String filename, int x, int y, Integer width, Integer height, FileInputStream imageStream, int page) throws IOException
Set visible signature designer for a new signature field.- Parameters:
filename
- name of the filex
- position of the signature fieldy
- position of the signature fieldwidth
- width of the imageheight
- height of the imageimageStream
- content of the imagepage
- the signature should be placed on- Throws:
IOException
- cannot write the PDF file
-
setVisibleSignatureProperties
public void setVisibleSignatureProperties(String name, String location, String reason, int preferredSize, int page, boolean visualSignEnabled) throws IOException
Set visible signature properties for new signature fields.- Parameters:
name
- name of the signerlocation
- the locationreason
- the reason for signingpreferredSize
- preferred widthpage
- index of the page to place the signaturevisualSignEnabled
- flag indicating if the signature must be visible- Throws:
IOException
- cannot write the PDF file
-
signPDF
public void signPDF(File inputFile, File signedFile) throws IOException
Sign pdf file and create new file- Parameters:
inputFile
- The source pdf document filesignedFile
- The file to be signed- Throws:
IOException
- cannot write the PDF file
-
-