-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathAddDigitalSignatureRFC3161.cs
More file actions
64 lines (51 loc) · 2.01 KB
/
Copy pathAddDigitalSignatureRFC3161.cs
File metadata and controls
64 lines (51 loc) · 2.01 KB
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
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Text;
using Datalogics.PDFL;
/*
*
* This sample program demonstrates the use of AddDigitalSignature for RFC3161 timestamp signature type.
*
* Copyright (c) 2025, Datalogics, Inc. All rights reserved.
*
*/
namespace AddDigitalSignatureRFC3161
{
class AddDigitalSignatureRFC3161
{
static void Main(string[] args)
{
Console.WriteLine("AddDigitalSignatureRFC3161 Sample:");
using (new Library())
{
Console.WriteLine("Initialized the library.");
String sInput = Library.ResourceDirectory + "Sample_Input/CreateAcroForm2h.pdf";
String sOutput = "DigSigRFC3161-out.pdf";
if (args.Length > 0)
sInput = args[0];
if (args.Length > 1)
sOutput = args[1];
Console.WriteLine("Input file: " + sInput);
Console.WriteLine("Writing to output: " + sOutput);
using (Document doc = new Document(sInput))
{
using (Datalogics.PDFL.SignDoc sigDoc = new Datalogics.PDFL.SignDoc())
{
// Setup Sign params
sigDoc.FieldID = SignatureFieldID.SearchForFirstUnsignedField;
// Set signing attributes
sigDoc.DigestCategory = DigestCategory.Sha256;
// Set the signature type to be used, RFC3161/TimeStamp.
// The available types are defined in the SignatureType enum. Default CMS.
sigDoc.DocSignType = SignatureType.RFC3161;
// Setup Save params
sigDoc.OutputPath = sOutput;
// Finally, sign and save the document
sigDoc.AddDigitalSignature(doc);
Console.WriteLine();
}
}
}
}
}
}