I'm trying to sign a PDF with a belgian eID smart card.
I encountered an issue where the PIN has to be passed 2 times. I found this post which proposes a solution:
signing-with-smart-card-t6556.html
It works in that I only have to enter my PIN once, but I'm not seeing the signature when I open the file in Adobe Acrobat Reader.
I've attached my unsigned and signed file. I did notice that when I try to close the file again, it asks me to save my changes, while I've not made any. So maybe something changes when the file is opened by Adobe?
This is the code I'm running
- Code: Select all
public static void Sign(X509Certificate2 cert)
{
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();
//Load a sample PDF file
doc.LoadFromFile("test.pdf");
//create CustomPKCS7SignatureFormatter
CustomPKCS7SignatureFormatter customPKCS7SignatureFormatter = new CustomPKCS7SignatureFormatter(cert);
PdfSignature signature = new PdfSignature(doc, doc.Pages[0], customPKCS7SignatureFormatter, "signature0");
//signature.Bounds = new RectangleF(new PointF(90, 550), new SizeF(270, 90));
//signature.GraphicsMode = GraphicMode.SignDetail;
//signature.NameLabel = "Signer:";
//signature.Name = "Test";
//signature.Reason = "The certificate of this document";
//signature.DistinguishedNameLabel = "DN: ";
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
//signature.SignDetailsFont = new PdfFont(PdfFontFamily.TimesRoman, 10f);
//signature.SignNameFont = new PdfFont(PdfFontFamily.Courier, 15);
//signature.SignImageLayout = SignImageLayout.None;
//Save to another PDF file
doc.SaveToFile("out_spire.pdf");
doc.Close();
}
Any help as to what may be causing this issue?