We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add multiple visual digital signatures to a PDF without breaking existing signatures?

Thread ID:





146816 Aug 21,2019 12:30 PM UTC Sep 24,2019 05:29 AM UTC WinForms 7
Tags: PDF
Thorsten Twellmann
Asked On August 21, 2019 12:30 PM UTC

Dear all,

I want to write a program for digital signing of PDF/A files with digital certificates. The files are signed by multiple users. Each digital signature shall have a visual presentation on the first page. I am using the code below. When the second user signs the pdf file, the already existing signature is broken. I have not limited the document or certificate permissions. What is required for adding signatures without breaking existing ones?

Thanks for your support!

               PdfLoadedDocument document = new PdfLoadedDocument(System.Convert.FromBase64String(tDocObj.tPayload.strDocBase64));
                PdfCertificate cert = new PdfCertificate(selectedCertificate[0]);
                PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
                // Position of signature box
                float ox = tDocObj.tPayload.afSignatureBox[0];
                float oy = page.Graphics.Size.Height - tDocObj.tPayload.afSignatureBox[1] - tDocObj.tPayload.afSignatureBox[3];
                float w = tDocObj.tPayload.afSignatureBox[2];
                float h = tDocObj.tPayload.afSignatureBox[3];

                PdfSignature signature = new PdfSignature(document, page, cert, "Signature" + DateTime.Now.ToString("yyyyMMdd HHmmssK"));
                signature.TimeStampServer = new TimeStampServer(new Uri("http://rfc3161timestamp.globalsign.com/advanced"));
                signature.DocumentPermissions = PdfCertificationFlags.AllowComments | PdfCertificationFlags.AllowFormFill;
                signature.Bounds = new RectangleF(ox, oy, w, h);
                signature.EnableValidationAppearance = false;
                signature.EnableLtv = true;
                signature.ContactInfo = "CONTACT";
                signature.LocationInfo = "LOCATION";
                signature.Reason = "REASON";

                string htmlText = String.Format("Digitally signed by\n{0}\nDate: {1}", selectedCertificate[0].GetNameInfo(X509NameType.SimpleName, false), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ssK"));

                PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(htmlText, new PdfStandardFont(PdfFontFamily.Helvetica, 14), PdfBrushes.Black);
                richTextElement.TextAlign = TextAlign.Left;

                PdfTemplate template = new PdfTemplate(w, h);
                richTextElement.Draw(template.Graphics, new RectangleF(new PointF(0, 0), new SizeF(w, h)));

                PdfBitmap image = new PdfBitmap("Logo.png");

                //Draw the logo
                PdfGraphicsState state = template.Graphics.Save();
                if (image.Height > template.Graphics.ClientSize.Height || image.Width > template.Graphics.ClientSize.Width)
                    template.Graphics.DrawImage(image, PointF.Empty, new SizeF(w, h));
                    template.Graphics.DrawImage(image, 0, 0);

                signature.Appearance.Normal.Graphics.DrawPdfTemplate(template, new PointF(0, 0));

                //Saves and closes the document.
                FileStream tOutStream = new FileStream(strTempOutFile, FileMode.Create);


Attachment: Syncfusion_a72dccd2.7z

Sowmiya Loganathan [Syncfusion]
Replied On August 22, 2019 12:06 PM UTC

Hi Thorsten, 
Thank you for contacting Syncfusion support.  
We can add multiple signature in PDF document without breaking the existing one. Please refer the below links for more details, 

Please let us know if you need any further assistance on this. 

Sowmiya L 

Thorsten Twellmann
Replied On September 11, 2019 12:44 PM UTC

In my use case the initial document does not contain form fields. It is automatically generated from a DOC file with a PDF printer softer and immediately signed by this PDF printer with a digital signature. Subsequently, human users have to place their signature on the cover page. The position is indicated by an appropriately designed cover page (table with full name and free space for the signature). Each user has to indicate where to place the signature by drawing a box. Can I use syncfusion for multiple signatures of the same PDF file without having to add form fields before (it should be possible somehow, you do this e.g. with Acrobat Reader)?


Sowmiya Loganathan [Syncfusion]
Replied On September 12, 2019 12:45 PM UTC

Hi Thorsten, 

We can add multiple signature in PDF document(different location) without using signature fields. We have created the sample for the same and please find the downloaded link from below, 

Note: Please make ensure whether you have using licensed assemblies. If you are using trial version, it will invalidate the older signature because of adding watermark to PDF.  

Please try the above sample in your end and let us know if it satisfies your requirement.  

Sowmiya L 

Thorsten Twellmann
Replied On September 22, 2019 06:43 PM UTC

Dear Sowmiya,

I was able to identify the line that causes the problem in my code. If you add the bold line to your code, the first signature is invalidated after adding the second signature:

PdfPageBase pageBase = loadedDocument1.Pages[0] as PdfPageBase;
PdfGraphics graphics2 = pageBase.Graphics;

I am using "graphics.Size.Height" for calculating the position and size of the box holding the visual presentation of the signature.

Do you have any idea why adding this line cause the problem?


Sowmiya Loganathan [Syncfusion]
Replied On September 23, 2019 12:22 PM UTC

Hi Thorstem, 

We have tried with the provided code snippet and we were able to see the first signature is invalidated after adding the second one. The reason for this issue is while parsing page graphics (get graphics from loaded page), we have reinitialize it. So it invalidated the existing signature and it is the behavior of our current architecture. We can overcome this behavior by get size from loaded page as like the below code snippet, 

//Get loaded page 
PdfLoadedPage loadedPage = loadedDocument1.Pages[0] as PdfLoadedPage; 
float height = loadedPage.Size.Height;             
//Creates a digital signature 
PdfSignature pdfSignature = new PdfSignature(loadedDocument1, loadedPage, pdfCert, "Signature2"); 
//Sets signature information 
pdfSignature.Bounds = new RectangleF(new PointF(100, 200), new SizeF(200, height)); 

Please try this solution in your end and let us know if it satisfies your requirement. 

Sowmiya L 

Thorsten Twellmann
Replied On September 23, 2019 07:38 PM UTC

This solved my problem.
Thanks a lot!

Sowmiya Loganathan [Syncfusion]
Replied On September 24, 2019 05:29 AM UTC

Hi Thorstem, 
Thank you for the update. We glad to know that your requirement is achieved. 
Sowmiya L 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon