Applying digital signature to an existing PDF

Discussions about PDF management.
Post Reply
User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Applying digital signature to an existing PDF

Post by Loïc » Tue Aug 09, 2011 5:17 am

Code: Select all

      Dim oGdPicturePDF As New GdPicturePDF

      oGdPicturePDF.SetLicenseNumber("XXX") 'Replace XXX by a valid demo or commercial key

      oGdPicturePDF.LoadFromFile("c:\test.pdf", False)
      oGdPicturePDF.DigiSign("c:\signed.pdf", "c:\test.pfx", "certificat_password", "The Reason", "The Location", "The Contact Info", "The Signer Name")
      oGdPicturePDF.CloseDocument()

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: Applying digital signature to an existing PDF

Post by Gabriela » Fri Mar 29, 2019 10:12 pm

Please find the refreshed and updated code sample here:
https://www.gdpicture.com/guides/gdpicture/web ... ments.html

You can also find our Digital Signing PDF Sample project in the installation directory:
https://www.gdpicture.com/guides/gdpicture/web ... l#PDF.html

KurtInCali
Posts: 13
Joined: Fri Mar 27, 2020 6:21 pm

Re: Applying digital signature to an existing PDF

Post by KurtInCali » Mon May 24, 2021 7:30 pm

Hi,

I'm being asked by a customer if we can digitally sign a pdf from a certificate in the local machine certificate store?
Alternately is there a way to do it from a certificate stored up in Azure?

From looking at internet CAs it looks like they are selling personal ones on thumb drives and enterprise ones on HSM hardware. Could you please provide details on what type of certificates that can be used?

I'd like to avoid my customer spending too much for one or purchasing something that doesn't work.

Thanks in advance,

Kurt

sbarlow
Posts: 33
Joined: Fri Jun 19, 2009 3:13 pm

Re: Applying digital signature to an existing PDF

Post by sbarlow » Tue Jun 15, 2021 7:15 pm

KurtInCali wrote:
Mon May 24, 2021 7:30 pm
Hi,

I'm being asked by a customer if we can digitally sign a pdf from a certificate in the local machine certificate store?
Alternately is there a way to do it from a certificate stored up in Azure?

From looking at internet CAs it looks like they are selling personal ones on thumb drives and enterprise ones on HSM hardware. Could you please provide details on what type of certificates that can be used?

I'd like to avoid my customer spending too much for one or purchasing something that doesn't work.

Thanks in advance,

Kurt
Although not a complete answer , it is possible to get a cert from the user and machine stores and use that to sign a document with GDPicture.

The following snippets require their appropriate references and it is in VB.net, but shows what you need. You would need to create your own form or interface for the user to select the proper cert from the store, but you can get the idea from the loop. The 2nd portion shows the beginnings of how to use with GDPicture. This would be from a desktop application that is run with rights to get to the stores. You get the serial ID needed from whatever was selected by the user .

Now I still have no idea how to have it fill an existing signature field identified from a user selecting the field in the viewer

Code: Select all

Dim store As X509Store = New X509Store(StoreName.My, StoreLocation.CurrentUser)
        store.Open(OpenFlags.ReadOnly)
        For Each certificate As X509Certificate2 In store.Certificates
            Debug.Print(certificate.SerialNumber & " " & certificate.SubjectName.ToString & " " & certificate.Issuer)
        Next

Code: Select all

Dim status As GdPictureStatus = _gdPicturePdf.SetSignatureCertificateFromStore(serialID)  'this is only a portion of the process, use this as opposed to pfx in the example

KurtInCali
Posts: 13
Joined: Fri Mar 27, 2020 6:21 pm

Re: Applying digital signature to an existing PDF

Post by KurtInCali » Tue Jun 15, 2021 7:22 pm

Thank you, that's cool, opens my options. I'm still finding it difficult to find Internet CAs who aren't overcharging...
That's very similar to the code needed to use client certs for authentication with Azure AD.

KurtInCali
Posts: 13
Joined: Fri Mar 27, 2020 6:21 pm

Re: Applying digital signature to an existing PDF

Post by KurtInCali » Mon Aug 28, 2023 8:45 pm

What are the rules with this: SetSignatureCertificateFromStore? It seems to only see certs in the personal store and not trusted root. We are having an exceedingly difficult time finding a cert on the AATL that we can use for automated PDF signing on behalf of an elected official who threatens to fire me on a regular basis :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest