I am using PDFsharp-extended version 1.0.1 and have the following code
using System.IO;
using System.Security.Cryptography.X509Certificates;
using PdfSharp.Pdf;
using PdfSharp.Pdf.AcroForms;
using PdfSharp.Pdf.IO;
using PdfSharp.Pdf.Security;
class Program
{
static void Main()
{
string inputPdfPath = "input.pdf";
string outputPdfPath = "output.pdf";
string privateKeyPath = "privatekey.pfx";
string privateKeyPassword = "password";
PdfDocument document = PdfReader.Open(inputPdfPath, PdfDocumentOpenMode.Modify);
PdfSignatureField signatureField = new PdfSignatureField(document.Pages[0], "Signature");
signatureField.SignatureHandler = new X509Certificate2SignatureHandler(privateKeyPath, privateKeyPassword);
document.AcroForm.Fields.Add(signatureField);
document.Save(outputPdfPath);
Console.WriteLine("PDF signed successfully.");
}
}
I am getting the following error:
Error CS1729 'PdfSignatureField' does not contain a constructor that takes 2 arguments
I have tried with multiple inputs but I keep getting the same error.
Maybe that version of PDFsharp only uses 1 parameter for the c'tor.
Your sample code comes from a different source and does not match the port of the library you are using.