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 Aug 26, 2020 11:37 am

I read this topic in forum and I using the code sample in my tests:
"Problem when signing PDF with more then one page"

I using the trial version, and after add the second digital sign, in PDF in Acrobat Reader I see the 2 signatures, but the first signature is not valid, the Acrobat Reader display it's not valid since the document was modified.
This error occurs because I am using the trial version?

I need to insert this code to work ?
Spire.License.LicenseProvider.SetLicenseKey("Your license key");

Do you have a temporary licence key for my tests ?

Thanks,
Wagner

lasdowsky
 
Posts: 1
Joined: Tue Dec 03, 2019 5:50 pm

Thu Aug 27, 2020 7:00 am

Hi,

Thanks for your post.
Yes, you need to apply the license when using multiple digital signatures. Our sales team has sent you the temporary licence to you via email. Please check and have a try.
If there is still the issue, please write back to us.

Sincerely,
Lynn
E-iceblue support team
User avatar

lynn.zhang
 
Posts: 57
Joined: Mon Jul 27, 2020 2:27 am

Tue Sep 01, 2020 7:34 am

Hi,

Has your issue been resolved? Could you please give us some feedback at your convenience?

Sincerely,
Lynn
E-iceblue support team
User avatar

lynn.zhang
 
Posts: 57
Joined: Mon Jul 27, 2020 2:27 am

Mon Oct 11, 2021 11:39 am

Hello , I have the same problem , can I get a license to check if my code working well ?

AshrafNosser66
 
Posts: 2
Joined: Mon Oct 11, 2021 11:37 am

Tue Oct 12, 2021 2:13 am

Hello Ashraf,

Thanks for your interests in our Spire product.
We have sent you a temporary licence for Spire.PDF Pro Edition. Please check your emails.
Our Spire.PDF provides two ways to sign PDF documents. Here is sample code for reference.
Code: Select all
 static void SignPDF1()
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile("MutiplePages.pdf");
            PdfCertificate digi = new PdfCertificate("gary.pfx", "e-iceblue");
            for (int i = 0; i < doc.Pages.Count; i++)
            {
                Spire.Pdf.Security.PdfSignature signature = new Spire.Pdf.Security.PdfSignature(doc, doc.Pages[i], digi, "signName_" + (i + 1));
                signature.Bounds = new RectangleF(new PointF(100, 600), new SizeF(120, 70));
                signature.NameLabel = "Signer:";
                signature.Name = "Gary";
                signature.ContactInfoLabel = "ContactInfo:";
                signature.ContactInfo = "Amy";
                signature.LocationInfoLabel = "Location:";
                signature.LocationInfo = "China";
                signature.ReasonLabel = "Reason:";
                signature.Reason = "protect document data ";
                signature.DateLabel = "Date:";
                signature.Date = DateTime.Now;
                signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
                //Save and reload, then sign again.
                MemoryStream ms = new MemoryStream();
                doc.SaveToStream(ms);
                doc = new PdfDocument();
                doc.LoadFromStream(ms);
            }

            doc.SaveToFile("signPDF1.pdf");
           
        }

        static void SignPDF2()
        {
            X509Certificate2 x509 = new X509Certificate2("gary.pfx", "e-iceblue");
            PdfDocument document = new PdfDocument();
            document.LoadFromFile("MutiplePages.pdf");

            PdfOrdinarySignatureMaker signatureMaker = new PdfOrdinarySignatureMaker(document, x509);
            Spire.Pdf.Interactive.DigitalSignatures.PdfSignature signature = signatureMaker.Signature;
            signature.Name = "Gary";
            signature.ContactInfo = "Amy";
            signature.Location = "China";
            signature.Reason="protect document data";
         
            PdfSignatureAppearance appearance = new PdfSignatureAppearance(signatureMaker.Signature);

            appearance.NameLabel = "Signer:";
            appearance.ContactInfoLabel = "ContactInfo:";
            appearance.LocationLabel = "Location:";
            appearance.ReasonLabel = "Reason:";
            appearance.DateLabel = "Date:";

            PdfPageBase pageBase = null;
            for (int i = 0; i < document.Pages.Count; i++)
            {
                pageBase = document.Pages[i];
                signatureMaker.MakeSignature("signName_" + (i + 1), pageBase, 100, 600, 120, 70, appearance);
            }

            document.SaveToFile("signPDF2.pdf");
        }


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 14, 2021 7:09 am

Dear Ashraf,

Have you received the temporary license file? Have you tried to add digital signature for your PDFs?
Feel free to contact us if you have any issues.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Mon Feb 06, 2023 1:35 pm

Hello,
I am facing a issue.
I am using the freeSpire.pdf library version (7.8.9).
I have to add same digital signature on multiple pages of the pdf file.
I have added a digital signature on each page of the pdf but when I open the pdf file it gives me an error like the attached screenshot.
Also, I have tried multiple ways but still, I am getting an error as "Signature Invalid, document altered". in this pdf, only the first signature gets a valid signature, and the remaining all others get invalid.
Here is my code:-

Some parameter will get replace by original passed values

Public Function DigitallySignDocument()
Try
'Create a PdfDocument object and 'Load a sample PDF file
Dim doc As Spire.Pdf.PdfDocument = New Spire.Pdf.PdfDocument()
doc.LoadFromFile(PDFFilePath)

Dim PdfPageCount As Int16 = doc.Pages.Count

While (PdfPageCount > 0)
'Load the certificate and Create a PdfSignature object and specify its position and size
Dim cert As Spire.Pdf.Security.PdfCertificate = New Spire.Pdf.Security.PdfCertificate(PfxFilePath, PswdForPfxFile)

PdfPageCount = PdfPageCount - 1
Dim signature As Spire.Pdf.Security.PdfSignature = New Spire.Pdf.Security.PdfSignature(doc, doc.Pages(PdfPageCount), cert, NameValue)

Dim rectangleF As RectangleF = New RectangleF(22, 40, 160, 44)
signature.Bounds = rectangleF

'Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = Spire.Pdf.Security.GraphicMode.SignImageAndSignDetail

signature.NameLabel = NameLabel
signature.Name = NameValue

signature.ContactInfoLabel = ContactInfoLabel
signature.ContactInfo = ContactInfoValue

signature.DateLabel = "Date"
signature.Date = DateTime.Now

signature.LocationInfoLabel = LocationInfoLabel
signature.LocationInfo = LocationInfoValue

signature.ReasonLabel = ReasonLabel
signature.Reason = ReasonValue

signature.DistinguishedNameLabel = "DN:"
signature.DistinguishedName = signature.Certificate.IssuerName.Name

signature.Certificated = True
'Set the signature image source "D:\PDFWithDigitalSign2_0\check-mark-2.png"
signature.SignImageSource = Spire.Pdf.Graphics.PdfImage.FromFile(SignatureImagePath)

'Set the signature font
signature.SignDetailsFont = New Spire.Pdf.Graphics.PdfTrueTypeFont(New Font("Arial Unicode MS", 7.0F, FontStyle.Regular))

'Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = Spire.Pdf.Security.PdfCertificationFlags.ForbidChanges Or Spire.Pdf.Security.PdfCertificationFlags.AllowFormFill


End While

'Save to file
doc.SaveToFile(OutputFilePath)
doc.Close()

Return "Success"
Catch ex As Exception
Return ex.Message
End Try
End Function

fipldevops
 
Posts: 6
Joined: Thu Jan 19, 2023 1:52 pm

Tue Feb 07, 2023 6:47 am

Hello,

Thanks for your inquiry.
Please kindly notice that the Free Spire.Pdf currently don’t support adding multiple digital signature to pdf file, however, our latest commercial version of Spire.PDF support this function, you can download the latest version (Spire.Pdf 9.2.2) and using the following code to test. Meanwhile, we are willing to provide a temporary license (one month free) to help you remove the warning message. If you need it, you can contact our sales team([email protected])

Code: Select all
Sub Main()
       
        'Create a PdfDocument object and 'Load a sample PDF file
        Dim doc As Spire.Pdf.PdfDocument = New Spire.Pdf.PdfDocument()
        doc.LoadFromFile("../../data/testttt.pdf")

        Dim PdfPageCount As Int16 = doc.Pages.Count

        'Load the certificate and Create a PdfSignature object and specify its position and size
        Dim cert As X509Certificate2 = New X509Certificate2("../../data/gary.pfx", "e-iceblue")

        'Create PdfOrdinarySignatureMaker
        Dim signatureMaker As PdfOrdinarySignatureMaker = New PdfOrdinarySignatureMaker(doc, cert)


        While (PdfPageCount > 0)

            PdfPageCount = PdfPageCount - 1

            'Define the width of signature and height of signature, define the coordinate of signature
            Dim x As Single = 50
            Dim y As Single = 600
            Dim width As Single = 120
            Dim height As Single = 70
            Dim signName As String = PdfPageCount.ToString


            'Sign the Pdf
            PdfSign(doc, PdfPageCount, signatureMaker, cert, signName, x, y, width, height)

        End While

        'Save to file
        doc.SaveToFile("../../output/new_result_____.pdf")
        doc.Close()
    End Sub


    Private Sub PdfSign(ByVal doc As PdfDocument, ByVal PdfPageCount As Int16, ByVal signatureMaker As PdfOrdinarySignatureMaker, ByVal cert As X509Certificate2, ByVal signName As String, ByVal x As Single, ByVal y As Single, ByVal width As Single, ByVal height As Single)
        Try

            'Create appearance1
            Dim appearance1 As PdfSignatureAppearance = New PdfSignatureAppearance(signatureMaker.Signature)
            appearance1.NameLabel = "Signer"
            appearance1.ContactInfoLabel = "ContactInfo:"
            appearance1.LocationLabel = "Location:"
            appearance1.ReasonLabel = "Reason:"

            'Create signature1 And set details for the signature1
            Dim signature1 As PdfSignature = signatureMaker.Signature
            signature1.Name = signName
            signature1.ContactInfo = "Tom Tang"
            signature1.Location = "China"
            signature1.Reason = "protect document data"

            'Add signature1 to first page of PDF document.
            signatureMaker.MakeSignature(signName, doc.Pages(PdfPageCount), x, y, width, height, appearance1)
        Catch
        End Try
    End Sub

Sincerely
Abel
E-iceblue support team
User avatar

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

Thu Feb 09, 2023 10:16 am

Hello Abel,
Thanks for the reply.

We are using Free Spire.pdf version 7.8.9 for the dot net 2.0 framework.
Is there any possibility that we use the latest version i.e. 8.6.0 of "Free Spire.pdf"
we can add a digital signature on multiple pages?

fipldevops
 
Posts: 6
Joined: Thu Jan 19, 2023 1:52 pm

Fri Feb 10, 2023 1:54 am

Hello,

Thanks for your feedback.
The function of adding multiple digital signature to a pdf file is a new feature we recently added to the business Edition, but it hasn’t been synced to the free version yet, due to the
our the free version currently don’t support it, and since the free version is not regularly upgraded and maintained, I can't tell you when this feature will be synced to the free version. Therefore, I suggest you evaluate our commercial version(Spire.Pdf9.2.2). And We are willing to provide a temporary license (one month free) to help you remove the warning message and remove the function limitation. If you need it, you can contact our sales team([email protected]).

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