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.

Tue May 28, 2019 6:04 pm

Hello,

How can I change the sample code in Tutorials > Spire.PDF > Spire.PDF-Program-Guide > Security > How-to-add-signature-field-to-PDF.html
to an already existing PDF document?

PdfDocument pdfdoc = new PdfDocument(args[0]); // args[0] is the path+name of the already existing PDF

doesn't work as it crashes with message:

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=SignPDF
StackTrace:
at Add_Signature_Filed_to_PDF.Program.Main(String[] args) in D:\SourceTree\SignPDF\Program.cs:line 21

Thanks,

--
Paulo

pnascim@gmail.com
 
Posts: 2
Joined: Sat Apr 27, 2019 3:10 pm

Wed May 29, 2019 3:37 am

Hi,

Thanks for your inquiry.
Please set the AllowCreateForm property to allow to create signature field in an existing Pdf. Below is my testing code for your reference. If there is any question, please feel free to write back.
Code: Select all
PdfDocument pdfdoc = new PdfDocument();
pdfdoc.LoadFromFile("input.pdf");
//add this line
pdfdoc.AllowCreateForm = (pdfdoc.Form == null) ? true : false;
PdfPageBase page = pdfdoc.Pages[0];
PdfSignatureField signaturefield = new PdfSignatureField(page, "Signature");
signaturefield.BorderWidth = 1.0f;
signaturefield.BorderStyle = PdfBorderStyle.Solid;
signaturefield.BorderColor = new PdfRGBColor(System.Drawing.Color.Black);
signaturefield.HighlightMode = PdfHighlightMode.Outline;
signaturefield.Bounds = new RectangleF(100, 100, 100, 100);
pdfdoc.Form.Fields.Add(signaturefield);
pdfdoc.SaveToFile("AddSignField.pdf", FileFormat.PDF);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Wed May 29, 2019 2:51 pm

Hello Nina,

Thank you very much for your prompt and simple yet very valuable reply,
Your code worked like a charm, appreciated, that's what I call a 5* support service.

Regards,

--
Paulo

pnascim@gmail.com
 
Posts: 2
Joined: Sat Apr 27, 2019 3:10 pm

Thu May 30, 2019 1:24 am

Dear Paulo,

Thank you for your recognition of our services.
If there is anything we can do for you in the future, please do not hesitate to contact us.
Wish you a nice day!

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Jan 21, 2020 4:22 am

Hi,

Is License version 1.3 work with adding signature field in PDF?

woongm
 
Posts: 2
Joined: Sat Jul 02, 2011 5:58 am
Location: Sydney

Tue Jan 21, 2020 7:08 am

Hi Michael,

Thanks for your post.
All our license version is 1.3. For the mentioned feature, the license file of Spire.Office and Spire.PDF work on it. Meanwhile, we noticed that your Spire.Office subscription has expired on 2015/7/17, kindly note your license file is valid for Spire.Office released before 2015/7/17, but the later versions are no longer available. If you want to use the latest Spire.Office Platinum Version:5.1, we are willing to provide a temporary license (one month free) to help you remove the warning message. If interested, please contact our sales team (sales@e-iceblue.com) to get it.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF