Aspose.Pdf - PDF数字签名

通过Aspose.Pdf可以便捷地实现对PDF文件的数字签名处理。

Aspose.Pdf - PDF数字签名

1 Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Aspose.Pdf.Forms;
using Aspose.Pdf.Facades;

namespace SignTest
{

class Program
{
static string MyDir = "C:\\Dev\\Test\\";

static void signAndSave(string inFile,
string outFile,
string sigPath,
string sigPassword,
string sigReason,
string sigContactInfo,
string sigLocation,
int pageNo,
int x,
int y,
int width,
int height,
string sigAppearancePath)
{
// sign
PKCS1 sig = new PKCS1(sigPath, sigPassword);
sig.Reason = sigReason;
sig.ContactInfo = sigContactInfo;
sig.Location = sigLocation;
PdfFileSignature pdfSign = new PdfFileSignature(inFile, outFile);
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(x, y, width, height);
pdfSign.SignatureAppearance = sigAppearancePath;
pdfSign.Sign(pageNo, true, rect, sig);
pdfSign.Save();
pdfSign.Close();
}

static void Main(string[] args)
{
// sign 1
signAndSave(MyDir + "quotation.pdf",
MyDir + "quotation_signed1.pdf",
MyDir + "Heary.pfx",
"password",
"Software Dev",
"Heary",
"SuZhou",
1,
100,
100,
100,
50,
MyDir + "heary.jpg");
}
}
}