I use Spire.PDF Pack Version:4.0
1) I am having problem with signing documents with Spire.PDF
I use free trail version to make something that works so I could buy licence for this API.
So far i managed to digitaly sign 1 document with smart card. Problem is that every time i sign doc Windows10 prompts me 4 times to input PIN for smart card. Is it possible to bypass it so i could input PIN only once if i want to digitaly sign PDF?
2)Is it possible to digitaly sign more than one document?
I already tried to merge two documents in one PDF and than sign each page of merged PDF, than split it in multiple PDF-s. It does Sign each document but then windows prompts me 8 times for PIN...
C# code so far:
- Code: Select all
string[] path = new string[2];
path[0] = @"path\to\doc1.pdf";
path[1] = @"path\to\doc2.pdf";
string MergePath = @"\path\to\mergeddoc.pdf";
//MERGE PDF
PdfDocumentBase doc = PdfDocument.MergeFiles(path);
doc.Save(MergePath, FileFormat.PDF);
doc.Close();
//Load Merged PDF
PdfDocument doc1 = new PdfDocument(MergePath);
//Load Certificate
PdfCertificate cert = new PdfCertificate(@"path\to\certificate", "pass");
for(int i=0; i<doc1.Pages.Count; i++)
{
PdfPageBase pageVar = doc1.Pages[i];
var signature = new PdfSignature(doc1, pageVar, cert, "Requestd1");
signature.Bounds = new RectangleF(new PointF(200, 600), new SizeF(750, 750));
signature.NameLabel = "Digitally signed by";
signature.Name = cert.Subject;
signature.DistinguishedName = "DN:";
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "Rijeka";
signature.ReasonLabel = "Reason: ";
signature.Reason = "Potpis dokumenta";
signature.DateLabel = "Date: ";
signature.Date = DateTime.Now;
signature.ContactInfoLabel = "Contact: ";
signature.ContactInfo = "7441236985";
signature.Certificated = false;
if (i == doc1.Pages.Count-1)
{
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges;
signature.IsConfiguerGraphicFilledBounds = false;
}
}
doc1.CompressionLevel = PdfCompressionLevel.Best;
doc1.SaveToFile(MergePath + "signed.pdf");
//SPLITTING INTO MLTIPLE PDF-s
String pattern = "SplitDocument-{0}.pdf";
doc1.Split(pattern);
String lastPageFileName = String.Format(pattern, doc1.Pages.Count - 1);
doc1.Close();