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.

Fri Apr 19, 2019 2:43 pm

How can I sign an existing signature field? I am able to add a new signature field, but when I try to apply a signature to an existing signature field, it doesn't work. I tried passing in the signature field to the PdfSignature constructor like this
Code: Select all
var signature = new PdfSignature(pdfDocument, pdfDocument.Pages[2], pdfCertificate, "signature1", signerField);

but I get an error.

When I try applying the signature to the field like this
Code: Select all
var signature = new PdfSignature(pdfDocument, pdfDocument.Pages[2], pdfCertificate, "signature1");
signerfield.Signature = signature;

it signs the document, but as a new signature (my existing signature field remains blank). Am I doing something wrong?

jerradtobii
 
Posts: 5
Joined: Wed Apr 17, 2019 12:21 pm

Mon Apr 22, 2019 10:34 am

Hi,

Thank you for your inquiry.
After an initial test with our latest version of Spire.PDF Pack(Hot Fix) Version:5.4.9, I didn’t encounter your issue. Below is my testing code for your reference. If you were using an old version, I suggest you try with the latest version. If your issue still occurs after trying, please provide your testing file to help us further look into it. You could send it to us via email ([email protected]).
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile("Sample.pdf");
            PdfCertificate cert = new PdfCertificate("gary.pfx", "e-iceblue");
            var form = (PdfFormWidget)doc.Form;
            var field = form.FieldsWidget[0] as PdfSignatureFieldWidget;
            PdfSignature signature = new PdfSignature(doc, doc.Pages[0], cert, field.Name, field);
            signature.ContactInfoLabel = "Contact Number: ";
            signature.ContactInfo = "028-8184455";
            doc.SaveToFile("result.pdf",FileFormat.PDF);

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Mon Apr 22, 2019 12:19 pm

I'm using 5.4.9, and I appear to be doing things the way you show. When I try to save the document, I get an "Object reference is not set to an instance of an object." error. When I inspect the PdfSignature object after instantiation, I noticed that the Appearance, Bounds, and Location properties are all showing a NullReference Exception. Is that expected?
Image

jerradtobii
 
Posts: 5
Joined: Wed Apr 17, 2019 12:21 pm

Tue Apr 23, 2019 6:38 am

Hi,

Thanks for your message.
I did notice that the Appearance, Bounds and Location properties are all showing a NullReference Exception when inspecting the PdfSignature object. This issue has been posted to our Dev team for further investigating. Once there is any update, I will let you know. But It seems that your issue isn’t caused by this, since I can sign and save successfully. Here is my testing Demo, you can run it directly or test your input file. If your issue still exists, please provide the following information to help us further look into it.
1. Your testing file, you can send it to us via email ([email protected]).
2. Your system configuration (E.g. Win 7, 64 bit).
3. Your region setting (E.g. China/Chinese).

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Tue Apr 23, 2019 12:44 pm

I think I've narrowed down the problem. Your demo works, but if I change the graphics mode, I get an error.

Code: Select all
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;
signature.SignImageSource = PdfImage.FromFile("signature.png");


I want to include the signature image in the signature field. This works if I am adding a new signature field, but fails if I am using an existing signature field.

jerradtobii
 
Posts: 5
Joined: Wed Apr 17, 2019 12:21 pm

Wed Apr 24, 2019 9:59 am

Hello,

Thanks for your feedback.
I still can't reproduce your issue after changing the graphics mode. The image can be signed in my existing signature field successfully. We need the following information to do an accurate investigation. Please share them with us. Thanks in advance.
1. Your input file which includes existing signature field, you can send it to us via email ([email protected]).
2. Your system configuration (E.g. Win 7, 64 bit).
3. Your region setting (E.g. China/Chinese).

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Mon Apr 29, 2019 11:26 am

Hi,

Thanks for your patient waiting.
Glad to inform you that the Appearance, Bounds, and Location properties are all showing a NullReference Exception has been resolved, welcome to download the hotfix from the following link.
Website link: Spire.PDF Pack(Hot Fix) Version:5.4.20
Nuget link: https://www.nuget.org/packages/Spire.PDF/5.4.20

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Return to Spire.PDF