|
| PdfStamper (PdfReader reader, Stream os) |
|
| PdfStamper (PdfReader reader, Stream os, char pdfVersion) |
|
| PdfStamper (PdfReader reader, Stream os, char pdfVersion, bool append) |
|
void | ReplacePage (PdfReader r, int pageImported, int pageReplaced) |
|
void | InsertPage (int pageNumber, Rectangle mediabox) |
|
void | Close () |
|
PdfContentByte | GetUnderContent (int pageNum) |
|
PdfContentByte | GetOverContent (int pageNum) |
|
void | SetEncryption (byte[] userPassword, byte[] ownerPassword, int permissions, bool strength128Bits) |
|
void | SetEncryption (byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType) |
|
void | SetEncryption (bool strength, String userPassword, String ownerPassword, int permissions) |
|
void | SetEncryption (int encryptionType, String userPassword, String ownerPassword, int permissions) |
|
void | SetEncryption (X509Certificate[] certs, int[] permissions, int encryptionType) |
|
PdfImportedPage | GetImportedPage (PdfReader reader, int pageNumber) |
|
void | AddAnnotation (PdfAnnotation annot, int page) |
|
PdfFormField | AddSignature (String name, int page, float llx, float lly, float urx, float ury) |
|
void | AddComments (FdfReader fdf) |
|
void | SetThumbnail (Image image, int page) |
|
bool | PartialFormFlattening (String name) |
|
void | AddFileAttachment (String description, byte[] fileStore, String file, String fileDisplay) |
|
void | AddFileAttachment (String description, PdfFileSpecification fs) |
|
void | MakePackage (PdfName initialView) |
|
void | MakePackage (PdfCollection collection) |
|
virtual void | AddViewerPreference (PdfName key, PdfObject value) |
|
void | SetFullCompression () |
|
void | SetPageAction (PdfName actionType, PdfAction action, int page) |
|
void | SetDuration (int seconds, int page) |
|
void | SetTransition (PdfTransition transition, int page) |
|
Hashtable | GetPdfLayers () |
|
Applies extra content to the pages of a PDF document. This extra content can be all the objects allowed in PdfContentByte including pages from other Pdfs. The original PDF will keep all the interactive elements including bookmarks, links and form fields.
It is also possible to change the field values and to flatten them. New fields can be added but not flattened.
- Author
- Paulo Soares (psoar.nosp@m.es@c.nosp@m.onsis.nosp@m.te.p.nosp@m.t)
static PdfStamper iTextSharp.text.pdf.PdfStamper.CreateSignature |
( |
PdfReader |
reader, |
|
|
Stream |
os, |
|
|
char |
pdfVersion |
|
) |
| |
|
static |
Applies a digital signature to a document. The returned PdfStamper can be used normally as the signature is only applied when closing.
Note that the pdf is created in memory.
A possible use is:
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("original.pdf");
FileOutputStream fout = new FileOutputStream("signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
- Parameters
-
reader | the original document |
os | the output stream |
pdfVersion | the new pdf version or '\0' to keep the same version as the original document |
- Exceptions
-
- Returns
- a
PdfStamper
static PdfStamper iTextSharp.text.pdf.PdfStamper.CreateSignature |
( |
PdfReader |
reader, |
|
|
Stream |
os, |
|
|
char |
pdfVersion, |
|
|
string |
tempFile |
|
) |
| |
|
static |
Applies a digital signature to a document. The returned PdfStamper can be used normally as the signature is only applied when closing.
A possible use is:
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("original.pdf");
FileOutputStream fout = new FileOutputStream("signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new File("/temp"));
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
- Parameters
-
reader | the original document |
os | the output stream or null to keep the document in the temporary file |
pdfVersion | the new pdf version or '\0' to keep the same version as the original document |
tempFile | location of the temporary file. If it's a directory a temporary file will be created there. If it's a file it will be used directly. The file will be deleted on exit unless os is null. In that case the document can be retrieved directly from the temporary file. If it's null no temporary file will be created and memory will be used |
- Returns
- a
PdfStamper
- Exceptions
-
static PdfStamper iTextSharp.text.pdf.PdfStamper.CreateSignature |
( |
PdfReader |
reader, |
|
|
Stream |
os, |
|
|
char |
pdfVersion, |
|
|
string |
tempFile, |
|
|
bool |
append |
|
) |
| |
|
static |
Applies a digital signature to a document, possibly as a new revision, making possible multiple signatures. The returned PdfStamper can be used normally as the signature is only applied when closing.
A possible use for adding a signature without invalidating an existing one is:
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("original.pdf");
FileOutputStream fout = new FileOutputStream("signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new
File("/temp"), true);
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
- Parameters
-
reader | the original document |
os | the output stream or null to keep the document in the temporary file |
pdfVersion | the new pdf version or '\0' to keep the same version as the original document |
tempFile | location of the temporary file. If it's a directory a temporary file will be created there. If it's a file it will be used directly. The file will be deleted on exit unless os is null. In that case the document can be retrieved directly from the temporary file. If it's null no temporary file will be created and memory will be used |
append | if true the signature and all the other content will be added as a new revision thus not invalidating existing signatures |
- Returns
- a
PdfStamper
- Exceptions
-
void iTextSharp.text.pdf.PdfStamper.SetEncryption |
( |
bool |
strength, |
|
|
String |
userPassword, |
|
|
String |
ownerPassword, |
|
|
int |
permissions |
|
) |
| |
Sets the encryption options for this document. The userPassword and the ownerPassword can be null or have zero length. In this case the ownerPassword is replaced by a random string. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them.
- Parameters
-
strength | true for 128 bit key length, false for 40 bit key length |
userPassword | the user password. Can be null or empty |
ownerPassword | the owner password. Can be null or empty |
permissions | the user permissions |
- Exceptions
-
void iTextSharp.text.pdf.PdfStamper.SetEncryption |
( |
byte[] |
userPassword, |
|
|
byte[] |
ownerPassword, |
|
|
int |
permissions, |
|
|
bool |
strength128Bits |
|
) |
| |
Sets the encryption options for this document. The userPassword and the ownerPassword can be null or have zero length. In this case the ownerPassword is replaced by a random string. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them.
- Parameters
-
userPassword | the user password. Can be null or empty |
ownerPassword | the owner password. Can be null or empty |
permissions | the user permissions |
strength128Bits | true for 128 bit key length, false for 40 bit key length |
- Exceptions
-
void iTextSharp.text.pdf.PdfStamper.SetEncryption |
( |
byte[] |
userPassword, |
|
|
byte[] |
ownerPassword, |
|
|
int |
permissions, |
|
|
int |
encryptionType |
|
) |
| |
Sets the encryption options for this document. The userPassword and the ownerPassword can be null or have zero length. In this case the ownerPassword is replaced by a random string. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them.
- Parameters
-
userPassword | the user password. Can be null or empty |
ownerPassword | the owner password. Can be null or empty |
permissions | the user permissions |
encryptionType | the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext |
- Exceptions
-
Implements iTextSharp.text.pdf.interfaces.IPdfEncryptionSettings.
void iTextSharp.text.pdf.PdfStamper.SetEncryption |
( |
int |
encryptionType, |
|
|
String |
userPassword, |
|
|
String |
ownerPassword, |
|
|
int |
permissions |
|
) |
| |
Sets the encryption options for this document. The userPassword and the ownerPassword can be null or have zero length. In this case the ownerPassword is replaced by a random string. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them.
- Parameters
-
encryptionType | the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext |
userPassword | the user password. Can be null or empty |
ownerPassword | the owner password. Can be null or empty |
permissions | the user permissions |
- Exceptions
-
void iTextSharp.text.pdf.PdfStamper.SetEncryption |
( |
X509Certificate[] |
certs, |
|
|
int[] |
permissions, |
|
|
int |
encryptionType |
|
) |
| |
Sets the certificate encryption options for this document. An array of one or more public certificates must be provided together with an array of the same size for the permissions for each certificate. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
- Parameters
-
certs | the public certificates to be used for the encryption |
permissions | the user permissions for each of the certicates |
encryptionType | the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. |
- Exceptions
-
Implements iTextSharp.text.pdf.interfaces.IPdfEncryptionSettings.