Digital signatures are handled by the Signature object that is part of the Document object. All the digital signature parameters can be set or retrieved using the Signature object.
Additional to the Common Attributes, this object has the following attributes:
Attribute Name |
Description |
Type |
Values |
Default Value |
---|---|---|---|---|
Page |
Page Index where object is located. Page Number is Page Index + 1. |
Integer |
>= 0 |
0 |
Locked |
Object cannot be modified |
Boolean |
True / False |
False |
ParentFullName |
The fully qualified name of this object' s parent object |
String |
||
Left |
Left position in Twips |
Integer |
0 |
|
Top |
Top position in Twips |
Integer |
0 |
|
Right |
Right position in Twips |
Integer |
0 |
|
Bottom |
Bottom position in Twips |
Integer |
0 |
|
LeftF |
Left position in Twips |
Float |
0.00F |
|
TopF |
Top position in Twips |
Float |
0.00F |
|
RightF |
Right position in Twips |
Float |
0.00F |
|
BottomF |
Bottom position in Twips |
Float |
0.00F |
|
Visible |
Object is visible when document is printed |
Boolean |
True / False |
True |
Editable |
Standard PDF attribute that makes the object editable or not in any viewer. |
Boolean |
True / False |
True |
CanActivate |
User can Activate. |
Boolean |
True/False |
True |
Hidden |
Hidden in certain report states |
Integer |
A binary combination of the following values: 1: Hidden in Run mode 2: Hidden in Design mode 4: Reserved value 8: Hidden in Print preview 16: Hidden in Annotation mode |
0: Always visible |
Annotation |
Object is saved as an annotation as opposed to a drawing within the page contents |
Boolean |
True / False |
False for static objects such as lines, polygons and text. True for dynamic objects such as form fields or high-lighters |
BorderColor |
Color for drawing text border. |
Color |
COLORREF (bbggrr) 000000 to FFFFFF or in COLORREF (aabbggrr) 00000000 to FFFFFFFF |
000000 (Solid black) |
BorderWidth |
Width of border around text. |
enum IacBorderWidth Units are in points or 12th of an inch. |
0: acBorderWidthNone 1: acBorderWidthSimple 2: acBorderWidthDouble 3: acBorderWidthTriple 4: acBorderWidthQuadruple |
0: acBorderWidthNone |
FileName |
Full path of the image associated with the signature. |
String |
|
NULL |
BitmapWidth |
Width of the image. In pixels. |
Integer |
0 |
|
BitmapHeight |
Height of the image. In pixels. |
Integer |
0 |
|
SignatureHandler *ReadOnly |
Type of signature handler. |
String |
Adobe.PPKMS |
Adobe.PPKMS |
SignatureFilter *ReadOnly |
Optional filter to be used by the application validating the signature. |
String |
adbe.pkcs7.sha1 |
adbe.pkcs7.sha1 |
Reason |
Reason for signing the document. |
String |
NULL |
|
Location |
Physical location where the document was signed. |
String |
NULL |
|
StoreName |
Windows stores digital signatures in "stores", each store having a name. This property can be used to get/set the name of the store if it is different from the default "MY" store. |
String |
"MY" |
|
SignerName |
Friendly name of the digital signature as it appears to the user when the digital certificate is installed on the system. In most cases, this is the full name of the person signing the document. |
String |
NULL |
|
Flags |
Combination of options for how to draw the signature. |
Integer |
Check Table Below |
255: Show all |
Sign |
Defines if the document should be signed using the signature object. |
Boolean |
True / False |
False |
DateFormat |
Formatting string for the date value in the digital certificate. The default value (empty string) displays the date in the default PDF format. |
String |
|
"" |
Flags |
Value (Dec) |
Value (Hex) |
---|---|---|
Hidden Signature |
0 |
0x000000 |
Signer name |
1 |
0x000001 |
Reason for signing |
2 |
0x000002 |
Location |
4 |
0x000004 |
Associated image |
8 |
0x000008 |
Certificate |
16 |
0x000010 |
Date of signing |
32 |
0x000020 |
Signature type |
64 |
0x000040 |
Show all |
255 |
0x0000FF |
Enabling PAdES |
256 |
0x000100 |
Enabling PAdES with LTV support (Long Term Validation) |
512 |
0x000200 |
In the current version of the PDF Creator, only one signature object can be present in the document, future versions might support multiple signatures for each document.
Only if the "Sign" attribute is set to True, it will sign the document with object.
This object uses the DefaultFont attribute of the Document Object for the texts.
<Flags()>
Public Enum FlagsSignature As Integer
SIGNATURE_DISPLAY_SIGNER = &H1
SIGNATURE_DISPLAY_REASON = &H2
SIGNATURE_DISPLAY_LOCATION = &H4
SIGNATURE_DISPLAY_IMAGE = &H8
SIGNATURE_DISPLAY_CERTIFICATE = &H10
SIGNATURE_DISPLAY_DATE = &H20
SIGNATURE_DISPLAY_TYPE = &H40
SIGNATURE_LEVEL_PADES = &H100
SIGNATURE_LEVEL_PADES_LTV = &H200
End Enum
Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator .NET Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B"
' Initialize library
' This should be done once
acPDFCreatorLib.Initialize()
' set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode)
' Create a new PDF document
Dim doc As New Amyuni.PDFCreator.IacDocument()
' Create page object
Dim page As Amyuni.PDFCreator.IacPage
' Define first page of PDF document
page = doc.GetPage(1)
' Switch to design mode before adding objects to the document
doc.ReportState = Amyuni.PDFCreator.IacReportState.acReportStateDesign
' Create a Signature
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeSignature, "Signature1")
' General Attributes
.Attribute("Left").Value = 1000
.Attribute("Right").Value = 3250
.Attribute("Top").Value = 0
.Attribute("Bottom").Value = 500
' Signature Attributes
.Attribute("SignerName").Value = "Amyuni Technologies"
.Attribute("Location").Value = "Montreal"
.Attribute("FileName").Value = "C:\temp\signature.png"
.Attribute("Flags").Value = FlagsSignature.SIGNATURE_DISPLAY_SIGNER Or FlagsSignature.SIGNATURE_DISPLAY_IMAGE
.Attribute("Sign").Value = True
End With
' Refresh the PDF document
doc.Refresh()
' Switch to run mode after objects to the document
doc.ReportState = Amyuni.PDFCreator.IacReportState.acReportStateRun
' Create new stream object
Dim fileWrite As System.IO.Stream = System.IO.File.OpenWrite("C:\temp\CreatePDFDocument_resulting.pdf")
' Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView)
' Close the stream
fileWrite.Close()
' terminate library to free resources
acPDFCreatorLib.Terminate()
' destroy objects
doc.Dispose()
page.Dispose()
End Sub
[Flags]
enum FlagsSignature
{
SIGNATURE_DISPLAY_SIGNER = 0x001,
SIGNATURE_DISPLAY_REASON = 0x002,
SIGNATURE_DISPLAY_LOCATION = 0x004,
SIGNATURE_DISPLAY_IMAGE = 0x008,
SIGNATURE_DISPLAY_CERTIFICATE = 0x010,
SIGNATURE_DISPLAY_DATE = 0x020,
SIGNATURE_DISPLAY_TYPE = 0x040,
SIGNATURE_LEVEL_PADES = 0x100,
SIGNATURE_LEVEL_PADES_LTV = 0x200
}
static void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Creator .NET Evaluation";
const string strActivationCode = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B";
// Initialize library
// This should be done once
acPDFCreatorLib.Initialize();
// set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode);
// Create a new PDF document
Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument();
// Create page object
Amyuni.PDFCreator.IacPage page;
// Define first page of PDF document
page = doc.GetPage(1);
// Switch to design mode before adding objects to the document
doc.ReportState = Amyuni.PDFCreator.IacReportState.acReportStateDesign;
// Create a Signature
using (Amyuni.PDFCreator.IacObject oSignature = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeSignature, "Signature1"))
{
// General Attributes
oSignature.Attribute("Left").Value = 1000;
oSignature.Attribute("Right").Value = 3250;
oSignature.Attribute("Top").Value = 0;
oSignature.Attribute("Bottom").Value = 500;
// Signature Attributes
oSignature.Attribute("SignerName").Value = "Amyuni Technologies";
oSignature.Attribute("Location").Value = "Montreal";
oSignature.Attribute("FileName").Value = @"C:\temp\signature.png";
oSignature.Attribute("Flags").Value = (int)(FlagsSignature.SIGNATURE_DISPLAY_SIGNER | FlagsSignature.SIGNATURE_DISPLAY_IMAGE);;
oSignature.Attribute("Sign").Value = true;
}
// ObjectByXY function returns a reference to the object located at the coordinates(X, Y)
Amyuni.PDFCreator.IacObject obj = page.ObjectByXY(2000, 250);
Console.WriteLine(obj.Name);
// Switch to run mode after objects to the document
doc.ReportState = Amyuni.PDFCreator.IacReportState.acReportStateRun;
// Create new stream object
System.IO.FileStream fileWrite = new System.IO.FileStream(@"C:\temp\CreatePDFDocument_resulting.pdf",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.Read);
// Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView);
// Close the stream
fileWrite.Close();
// terminate library to free resources
acPDFCreatorLib.Terminate();
// destroy objects
doc.Dispose();
page.Dispose();
}