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

EnableValidationAppearance and signature.Appearance.Normal.Graphics at the same time?

Hi!

On a PDF file, Is it possible to draw a custom signature using "signature.Appearance.Normal.Graphics" and then enable the "EnableValidationAppearance" so that the PDF viewer will automatically draw the validation mark over the signature?

I tried to do it but when "EnableValidationAppearance" is enabled the signature graphics is not displayed.
Is it possible that the validation background is white (not transparent)?

10 Replies

SL Sowmiya Loganathan Syncfusion Team December 16, 2019 10:34 AM UTC

Hi Stavros,  
 
Thank you for contacting Syncfusion support.  
 
We can achieve your requirement by enable the “EnableValidationAppearance” and then draw the custom signature appearance in PDF document. Please refer the below code snippet for more details, 
 
//Creates a digital signature 
PdfSignature signature = new PdfSignature(loadedDocument, page, pdfCert, "Signature"); 
 
//Sets signature information 
signature.Bounds = new RectangleF(0, 100, 200, 100); 
signature.ContactInfo = "johndoe@owned.us"; 
signature.LocationInfo = "Honolulu, Hawaii"; 
signature.Reason = "I am author of this document."; 
 
signature.EnableValidationAppearance = true; 
 
//Create appearance for the digital signature 
signature.Appearance.Normal.Graphics.DrawRectangle(PdfBrushes.White, new RectangleF(0, 0, 200, 100)); 
 
 
 
Please try the above solution in your end and let us know whether your requirement is achieved or not. If not kindly share us the further details about your requirement, it will helpful us to provide the precise solution on this. 
 
Regards, 
Sowmiya Loganathan 



SD Stavros Dimopoulos December 19, 2019 12:54 AM UTC

Thanks for the solution!

At the moment I have to solve another problem. The latest Windows Update has compatibility problems with ClickOnce applications so I have to make the app working again before testing the solution.

Thank you!


SL Sowmiya Loganathan Syncfusion Team December 19, 2019 08:40 AM UTC

Hi Stavros,  
 
Thanks for the update. We will wait to hear from you.  
 
Regards, 
Sowmiya Loganathan 



SD Stavros Dimopoulos February 29, 2020 09:23 PM UTC

It works, the background image is displayed correctly.

I still have issues when the page is rotated but I will figure it out.
Thanks!


SD Stavros Dimopoulos March 5, 2020 05:52 PM UTC

I just noticed that the orientation of the signature Graphics object is different if I disable the EnableValidationAppearance option.

The issue occurs only in landscape pages (rotation = 90°).

I signed both pdf attachments with the same code. The only difference is that I commended out the EnableValidationAppearance option in the second file. If you move your cursor over the digital signature, it is obvious that the bounds of the digital signature are correct, however the text is drawn with the wrong orientation.

Another minor problem I noticed is that the validation mark is drawn over the text and the text under it is almost unreadable. It would be very useful if the validation text is positioned on top of the signature and the validation mark is positioned in a layer under the custom text layer, like this:



Attachment: Landscape_Test_df99dc13.zip


PV Prakash Viswanathan Syncfusion Team March 6, 2020 12:28 PM UTC

Hi Stavros,   
  
Thank you for your update.    
  
We have checked the reported issue and we suspect that the issue may occur with a particular PDF document. So, kindly provide below details to reproduce the reported issues in our end. So that it will be more helpful for us to reproduce and analyze further about this issue.    
  
  1. Input PDF document.
  2. Complete code snippet.

Regards, 
Prakash V 



SD Stavros Dimopoulos March 6, 2020 06:29 PM UTC

I attached the input PDF document. It is created using a IntelliCAD based software, using print-> "Adobe pdf". The orientation was set to Landscape.
If you comment out the line "PdfSignature.EnableValidationAppearance = True", you will see that the content of the signature is rotated.

The source code is:
        Dim store As New X509Store(StoreName.My, StoreLocation.CurrentUser)
        Dim doc = New PdfLoadedDocument(input)
        store.Open(OpenFlags.ReadOnly)
        Dim pageBase As PdfPageBase = doc.Pages(0)
        Dim height = pageBase.Size.Height
       
        Dim PdfSignature = New PdfSignature(doc, pageBase, MyCert, "Signature1")
        PdfSignature.EnableValidationAppearance = True
        PdfSignature.TimeStampServer = New TimeStampServer(New Uri(TimestampServer))
        PdfSignature.EnableLtv = EnebleLtv
        PdfSignature.DocumentPermissions = PdfCertificationFlags.AllowComments Or PdfCertificationFlags.AllowFormFill Or PdfCertificationFlags.ForbidChanges
        PdfSignature.Bounds = GetBounds(pageBase, input)
        PdfSignature.ContactInfo = ContactInfo
        PdfSignature.LocationInfo = LocationInfo
        PdfSignature.Reason = Reason

        DrawSignatureImage(PdfSignature, pageBase.Rotation)
        DrawSignatureInfo(PdfSignature, pageBase.Rotation )

        doc.Save(output)
        doc.Close(True)

I also noticed that even with EnableValidationAppearance = True, the signature validation mark is displayed different in portrait and in landscape mode.

Document page in portrait (RotationAngle0):

Document page in landscape mode (RotationAngle90):

The above bugs are not very important and at the moment I can continue my project with the existing functionality. I just want to report bugs so you can make your product even better!
Regards,
Stavros D.

Attachment: Landscape_Test_unsigned_2f8fb43c.zip


PV Prakash Viswanathan Syncfusion Team March 9, 2020 10:36 AM UTC

Hi Stavros,   
   
Thank you for sharing the details.    
   
We have checked the reported issue, when we enable the EnableValidationAppearance, we will not create any appearance for the signature. The PDF viewers/readers will create appearance based on this value. The adobe reader renders the appearance, based on the page. So, the reported issue does not occur with our library.    
   
Please let us know if you need any other assistance with this.    
 
Regards, 
Prakash V 



SG Smithangshu Ghosh replied to Sowmiya Loganathan January 7, 2024 08:45 AM UTC

Hi,


It looks like newer version of the library has corrupted the existing feature. I am trying the code suppose to be working but it makes the verification icon behind the Appearance Graphics. Please try following code.


PdfLoadedDocument loadedDocument = new PdfLoadedDocument("testpdf.pdf");

PdfCertificate pdfCertificate = new PdfCertificate("testlicense.pfx", "password");
PdfSignature signature = new PdfSignature(loadedDocument, loadedDocument.Pages[0], pdfCertificate, "Signature");

signature.Bounds = new RectangleF(0, 100, 200, 100);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";

signature.EnableValidationAppearance = true;

signature.Appearance.Normal.Graphics.DrawRectangle(PdfBrushes.White, new RectangleF(0, 0, 200, 100));

loadedDocument.Save();

Process.Start("testpdf.pdf");


JT Jeyalakshmi Thangamarippandian Syncfusion Team January 8, 2024 02:21 PM UTC

Hi Smithangshu,

Thank you for the update!

We suggest that you enable the EnableValidationAppearance feature after you've finished making changes to how your signature looks. We recommended to update your highlighted changes to overcome the issue.

PdfLoadedDocument loadedDocument = new PdfLoadedDocument("testpdf.pdf");

 

PdfCertificate pdfCertificate = new PdfCertificate("testlicence.pfx", "password");

PdfSignature signature = new PdfSignature(loadedDocument, loadedDocument.Pages[0], pdfCertificate, "Signature");

 

signature.Bounds = new RectangleF(0, 100, 200, 100);

signature.ContactInfo = "johndoe@owned.us";

signature.LocationInfo = "Honolulu, Hawaii";

signature.Reason = "I am author of this document.";

 

signature.Appearance.Normal.Graphics.DrawRectangle(PdfBrushes.White, new RectangleF(0, 0, 200, 100));

 

signature.EnableValidationAppearance = true;

 

loadedDocument.Save("testpdf1.pdf");

Process.Start("testpdf1.pdf");


Regards,

Jeyalakshmi T


Loader.
Live Chat Icon For mobile
Up arrow icon