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.

Wed Sep 07, 2022 10:17 am

Hi Team,

I'm a new user for Spire.pdf and I would like to validate a test PDF signature through the below code:


Code: Select all
import com.spire.pdf.PdfDocument;
import com.spire.pdf.security.PdfSignature;
import com.spire.pdf.widget.*;

public class VerifySignature {
    public static void main(String[] args) {

        //Load a pdf document
        PdfDocument doc = new PdfDocument();
        doc.loadFromFile("/Users/fernando/Desktop/Test_pdf_signed.pdf");

        //Get the collection of PDF fields
        PdfFormWidget pdfFormWidget = (PdfFormWidget) doc.getForm();
        PdfFormFieldWidgetCollection pdfFormFieldWidgetCollection = pdfFormWidget.getFieldsWidget();

        //Traverse all the PDF form field
        for (int i = 0; i < pdfFormFieldWidgetCollection.getCount(); i++) {
            //check whether it is PdfSignatureField
            if (pdfFormFieldWidgetCollection.get(i) instanceof PdfSignatureFieldWidget) {
                //get the signature field
                PdfSignatureFieldWidget signatureFieldWidget = (PdfSignatureFieldWidget) pdfFormFieldWidgetCollection.get(i);
                //get the PDF signature
                PdfSignature signature = signatureFieldWidget.getSignature();

                //Verify the signature
                boolean result = signature.verifySignature();
                if (result) {
                    System.out.println("Valid signature");
                } else {
                    System.out.println("Invalid signature");
                }
            }
        }
    }
}


I can see the signature info from adobe ("Signer's identity is valid" ), but I don't know why the Sprie code always prints the "Invalid signature",
I was using 5.1.0 which can not work as expected, after I upgraded to 8.8.3 the same result happened.

Could you pls give me some guidance or suggestions? Thanks!

ps: I have sent the test PDF to your support email [email protected] and linked this page.

Fernando88
 
Posts: 3
Joined: Wed Sep 07, 2022 9:37 am

Thu Sep 08, 2022 8:00 am

Hello,

Thanks for your inquiry.
After investigation, I reproduced your issue and logged it into our bug system with the ticket number SPIREPDF-5475. Our development team will investigate and fix it. Once it is fixed, I’ll inform you in time. Sorry for the inconvenience caused. In addition, we also can provide Chinese technical support.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Thu Sep 08, 2022 9:23 am

Abel.He wrote:Hello,

Thanks for your inquiry.
After investigation, I reproduced your issue and logged it into our bug system with the ticket number SPIREPDF-5475. Our development team will investigate and fix it. Once it is fixed, I’ll inform you in time. Sorry for the inconvenience caused. In addition, we also can provide Chinese technical support.

Sincerely
Abel
E-iceblue support team


Thanks for your quick response, I will follow this topic, please let me know the solution after we have it.

Fernando88
 
Posts: 3
Joined: Wed Sep 07, 2022 9:37 am

Mon Sep 19, 2022 8:31 am

Abel.He wrote:Hello,

Thanks for your inquiry.
After investigation, I reproduced your issue and logged it into our bug system with the ticket number SPIREPDF-5475. Our development team will investigate and fix it. Once it is fixed, I’ll inform you in time. Sorry for the inconvenience caused. In addition, we also can provide Chinese technical support.

Sincerely
Abel
E-iceblue support team


Hi Abel.He,

I would like to know, any update for this issue?

Thanks!

Fernando88
 
Posts: 3
Joined: Wed Sep 07, 2022 9:37 am

Mon Sep 19, 2022 9:46 am

Hello,

Thanks for your following up.
Your issue with SPIREPDF-5475 has been in test phase, and I have urged our test team to speed up testing this issue. Once the official version fixing this issue is released, I’ll inform you in time.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Mon Sep 19, 2022 12:52 pm

Fernando88 wrote:Hi Team,

I'm a new user for Spire.pdf and I would like to validate a test PDF signature through the below code:


Code: Select all
import com.spire.pdf.PdfDocument;
import com.spire.pdf.security.PdfSignature;
import com.spire.pdf.widget.*;

public class VerifySignature {
    public static void main(String[] args) {

        //Load a pdf document
        PdfDocument doc = new PdfDocument();
        doc.loadFromFile("/Users/fernando/Desktop/Test_pdf_signed.pdf");

        //Get the collection of PDF fields
        PdfFormWidget pdfFormWidget = (PdfFormWidget) doc.getForm();
        PdfFormFieldWidgetCollection pdfFormFieldWidgetCollection = pdfFormWidget.getFieldsWidget();

        //Traverse all the PDF form field
        for (int i = 0; i < pdfFormFieldWidgetCollection.getCount(); i++) {
            //check whether it is PdfSignatureField
            if (pdfFormFieldWidgetCollection.get(i) instanceof PdfSignatureFieldWidget) {
                //get the signature field
                PdfSignatureFieldWidget signatureFieldWidget = (PdfSignatureFieldWidget) pdfFormFieldWidgetCollection.get(i);
                //get the PDF signature
                PdfSignature signature = signatureFieldWidget.getSignature();

                //Verify the signature
                boolean result = signature.verifySignature();
                if (result) {
                    System.out.println("Valid signature");
                } else {
                    System.out.println("Invalid signature");
                }
            }
        }
    }
}


I can see the signature info from adobe ("Signer's identity is valid" ), but I don't know why the Sprie code always prints the "Invalid signature",
I was using 5.1.0 which can not work as expected, after I upgraded to 8.8.3 the same result happened.

Could you pls give me some guidance or suggestions? Thanks!

ps: I have sent the test PDF to your support email [email protected] and linked this page.



Oi, Fernando. Também tive este problema. Mas no meu caso gostaria apenas de imprimir informações da assinatura (Emissor, Assunto, etc) (como iria passar um documento com assinatura válida, retirei a "validação" se é ou não uma assinatura)


Code: Select all
public List<String> retornarInformacoesAssinaturaDigitalPDFSpire(String pathFile){

        //Load a pdf document
        PdfDocument doc = new PdfDocument();
        doc.loadFromFile(pathFile); //  _dataDir + "documento.pdf"

        //Get the collection of PDF fields
        PdfFormWidget pdfFormWidget = (PdfFormWidget) doc.getForm();
        PdfFormFieldWidgetCollection pdfFormFieldWidgetCollection = pdfFormWidget.getFieldsWidget();

        List<String> signInfo = new ArrayList<>();

        //Traverse all the PDF form field
        for (int i = 0; i < pdfFormFieldWidgetCollection.getCount(); i++) {
            //check whether it is PdfSignatureField
            if (pdfFormFieldWidgetCollection.get(i) instanceof PdfSignatureFieldWidget) {
                //get the signature field
                PdfSignatureFieldWidget signatureFieldWidget = (PdfSignatureFieldWidget) pdfFormFieldWidgetCollection.get(i);
                //get the PDF signature
                PdfSignature signature = signatureFieldWidget.getSignature();

                //Verify the signature
                //boolean result = signature.verifySignature();

                //if (result) {

                    signInfo.add(signature.getCertificate().toString());
                    signInfo.add("2: CN  " + signature.getCertificate().getSubject());
                    signInfo.add("3: Issuer " + signature.getCertificate().getIssuer());
                    signInfo.add("4:  " + signature.getCertificate().getNameInfo(EmailName,true));
                    signInfo.add("6: Data  " + String.valueOf(signature.getDate()));
                    signInfo.add("7: Contato  " + signature.getContactInfo());
                    signInfo.add("8: Motivo " + signature.getReason());
                    signInfo.add("9: toStringSignature: " + signature.toString());
                    signInfo.add("10: getNameInfo: " + signature.getCertificate().getNameInfo(SimpleName,true));

//                } else {
//                    signInfo.add("Assinatura Inválida");
//                }
            }
        }

        return signInfo;
    }

Leecastro
 
Posts: 5
Joined: Mon Sep 19, 2022 12:28 pm

Mon Sep 19, 2022 1:03 pm

Abel.He wrote:Hello,

Thanks for your following up.
Your issue with SPIREPDF-5475 has been in test phase, and I have urged our test team to speed up testing this issue. Once the official version fixing this issue is released, I’ll inform you in time.

Sincerely
Abel
E-iceblue support team



Hi, I would like to extract more information from the signature.
When I open the PDF file in AdobeReader, it shows a lot of details that I am not able to get from the Spire library.

Code: Select all
  List<String> signInfo = new ArrayList<>();
                 ...  PdfSignature signature = signatureFieldWidget.getSignature(); ...
                    signInfo.add(signature.getCertificate().toString());                                                  RETURN infos OK
                    signInfo.add("2: CN  " + signature.getCertificate().getSubject());                             RETURN infos OK
                    signInfo.add("3: Issuer " + signature.getCertificate().getIssuer());                             RETURN infos OK

                    signInfo.add("4:  " + signature.getCertificate().getNameInfo(EmailName,true));        RETURN null ???


Leecastro
 
Posts: 5
Joined: Mon Sep 19, 2022 12:28 pm

Tue Sep 20, 2022 9:53 am

Hello,

Thanks for your inquiry.
After investigation, I simulated a pdf to test your scenario and I reproduced your issue. We will fix it. However, to ensure that the fixes we make can also successfully read the information in your document, please provide us with the following message from you. Thanks for your assistance in advance.

1) Your test Pdf document.
2) Application type, such as Console App, .NET Framework 4.8.
3) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Tue Sep 20, 2022 7:02 pm

Abel.He wrote:Hello,

Thanks for your inquiry.
After investigation, I simulated a pdf to test your scenario and I reproduced your issue. We will fix it. However, to ensure that the fixes we make can also successfully read the information in your document, please provide us with the following message from you. Thanks for your assistance in advance.

1) Your test Pdf document.
2) Application type, such as Console App, .NET Framework 4.8.
3) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Sincerely
Abel
E-iceblue support team



Hey,

I need to extract details from the digital signature certificate to a PDF.

I need the values of 3 fields: Issuer, Subject and RFC822 Email, these fields are from the certificate.


In JAVA (Windows 10 bit-64), Eclipse or Intellij. Region:US.

Leecastro
 
Posts: 5
Joined: Mon Sep 19, 2022 12:28 pm

Wed Sep 21, 2022 6:12 am

Hello,
Thanks for your feedback.
When I test your pdf document, I reproduced the issue of getting an empty string when getting an email address from digital signature certificate, and I logged it into our bug tracking system with the ticket number SPIREPDF-5493. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.
In addition, if you have purchased our product, please offer your order number or the email address of purchasing. Thanks for your assistance in advance.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Wed Sep 21, 2022 11:56 am

Abel.He wrote:Hello,
Thanks for your feedback.
When I test your pdf document, I reproduced the issue of getting an empty string when getting an email address from digital signature certificate, and I logged it into our bug tracking system with the ticket number SPIREPDF-5493. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.
In addition, if you have purchased our product, please offer your order number or the email address of purchasing. Thanks for your assistance in advance.

Sincerely
Abel
E-iceblue support team

Leecastro
 
Posts: 5
Joined: Mon Sep 19, 2022 12:28 pm

Thu Sep 22, 2022 8:45 am

Hello,

Thanks for your feedback.
Do you have the issue that the certificate’s information obtained by Spire.Pdf doesn’t match the actual information of certificate? If so, to help us reproduce your issue and work out a solution for you, please offer the following message, thanks for your assistance in advance.
1) Your Pdf doucment that can reproduce your issue.
2) Your JDK version, such as oracle jdk1.8.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Thu Sep 22, 2022 10:43 am

Abel.He wrote:Hello,

Thanks for your feedback.
Do you have the issue that the certificate’s information obtained by Spire.Pdf doesn’t match the actual information of certificate? If so, to help us reproduce your issue and work out a solution for you, please offer the following message, thanks for your assistance in advance.
1) Your Pdf doucment that can reproduce your issue.
2) Your JDK version, such as oracle jdk1.8.

Sincerely
Abel
E-iceblue support team



Spire.PDF is reproducing information correctly. I would just like to extract other fields from the certificate, in addition to those that Spire.PDF already reproduces.

My JDK 18.0.2.1

Leecastro
 
Posts: 5
Joined: Mon Sep 19, 2022 12:28 pm

Fri Sep 23, 2022 7:15 am

Hello,

Thanks for your feedback.
For your issue, I have logged it into our bug tracking system with the ticket number SPIREPDF-5493. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Thu Nov 03, 2022 1:43 am

Leecastro wrote:
Abel.He wrote:Hello,

Thanks for your feedback.
Do you have the issue that the certificate’s information obtained by Spire.Pdf doesn’t match the actual information of certificate? If so, to help us reproduce your issue and work out a solution for you, please offer the following message, thanks for your assistance in advance.
1) Your Pdf doucment that can reproduce your issue.
2) Your JDK version, such as oracle jdk1.8.

Sincerely
Abel
E-iceblue support team



Spire.PDF is reproducing information correctly. I would just like to extract other fields from the certificate, in addition to those that Spire.PDF already reproduces.

My JDK 18.0.2.1


Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.PDF 8.11.0 for Java which fixes the issue with SPIREPDF-5493.
Please download the new version from the following links to test.
Website download link: https://www.e-iceblue.com/Download/pdf-for-java.html

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF

cron