Page 1 of 1

Applying digital signature to an existing PDF

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

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()

Re: Applying digital signature to an existing PDF

Posted: Fri Mar 29, 2019 10:12 pm
by Gabriela
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

Re: Applying digital signature to an existing PDF

Posted: Mon May 24, 2021 7:30 pm
by KurtInCali
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

Re: Applying digital signature to an existing PDF

Posted: Tue Jun 15, 2021 7:15 pm
by sbarlow
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

Re: Applying digital signature to an existing PDF

Posted: Tue Jun 15, 2021 7:22 pm
by KurtInCali
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.

Re: Applying digital signature to an existing PDF

Posted: Mon Aug 28, 2023 8:45 pm
by KurtInCali
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 :)