Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Sep 22, 2022 8:39 am

Hi, I need to add signature visualisation to an existing signature.
The scenario is like that:
1. We have a PDF that is sent to thirdparty signature provider that signs the file.
2. Signature provider gives us signed file - without any visualisation - file is just signed with a certificate
3. We want to add visualisation.

How can we do that? I tried somethink like:

Code: Select all
PdfDocument doc = new PdfDocument(fileName);

//search for existing signature
PdfFormWidget form = (PdfFormWidget)doc.Form;
PdfSignature signature = null;
string name = string.Empty;
foreach (var field in form.FieldsWidget)
{
    var f = field as PdfSignatureFieldWidget;
    if (f == null || f.Signature == null)
        continue;

    signature = f.Signature;
    name = f.FullName;
}

//add visualisation
PdfSignatureField sigField = new PdfSignatureField(doc.Pages[0], name);
sigField.BorderWidth = 1.0f;
sigField.BorderStyle = PdfBorderStyle.Solid;
sigField.BorderColor = new Spire.Pdf.Graphics.PdfRGBColor(Color.Black);
sigField.Bounds = new RectangleF(100, 100, 100, 100);
sigField.Signature = new PdfSignature(doc, doc.Pages[0], signature.Certificate, "SigTest");
sigField.Signature.GraphicsMode = GraphicMode.SignNameAndSignDetail;
sigField.Signature.NameLabel = "Podpisujący: ";
sigField.Signature.Name = "Adam";
sigField.Signature.Date = DateTime.Now;
sigField.Signature.ReasonLabel = "Powód: ";
sigField.Signature.Reason = "Bo mogę";
sigField.Signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges | PdfCertificationFlags.AllowFormFill;

doc.Form.Fields.Add(sigField);

doc.SaveToFile(destinationFilePath, FileFormat.PDF);


But the result is error saying "lost private key". So, is there any way to do that? Add visualisation to existing signature?

ajachocki
 
Posts: 1
Joined: Mon Sep 19, 2022 11:54 am

Thu Sep 22, 2022 10:25 am

Hello,

Thanks for your inquiry.
To help us reproduce your issue and work out a solution for you, please offer the following message, thanks for your assistance in advance.

1) Your input pdf document.
2) Application type, such as Console App, .NET Framework 4.8.
3) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Fri Sep 23, 2022 9:47 am

Hello,

Greeting from E-iceblue.
After the communication with our development team, Spire.Pdf doesn’t support changing invisible signatures to visible signatures in your scenario. Sorry for the inconvenience caused.
If you have any other issue, just feel free to contact us.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF