Free Support Forum -

Merge and Sign PDF files digitally in C# using Aspose.PDF for .NET - Signature becomes invalid


We have been using Aspose.PDF to merge PDF files. We have found that multiple signature invalid for merged PDF files.

We have the following flow:

Merge two PDF/A-1B files
Sign result file with first signature
Sign result file with second signature

And after step 3, the first signature (applied on the 2td step) become invalid.

NOTE 1: we use external tool to sign PDF/A file, however when we try to sign with Aspose, we still have this problem.
NOTE 2: It seems that problem not in signature, but in the created PDF/A-1B file. If converted file is opened and re-saved with Adobe - signing works correct.
NOTE 3: we are using Aspose.Pdf v19.11 and Aspose.Words v19.11
NOTE 4: perhabs similar to this issue (PDFNET-47442)

Code example:

using System.Collections.Generic;
using System.IO;
using Aspose.Pdf;
using Aspose.Pdf.Facades;

namespace TestMergeAsposeAndDoubleSigning
    class Program
        private static string PfxFileName = @"D:\pdfAIssue\cert.pfx";
        private static string CertificatePassword = "1q2w3e4r5t";

        static void Main()
            var files = new List<string>();

            var mergedFileName = "merged.pdf";
            var firstSign = "firstSign.pdf";
            var result = "result.pdf";
            Merge(files, mergedFileName);

            Sign(mergedFileName, firstSign);
            Sign(firstSign, result);
        private static void Merge(
            List<string> filesPath,
            string outputFilePath)
            var license = new License();

            Document outputDocument = null;

            foreach (var filePath in filesPath)
                if (outputDocument == null)
                    outputDocument = new Document();

                var inputDocument = new Document(filePath);


                new MemoryStream(),
                ConvertErrorAction.None /*GetErrorAction(parameters)*/);


        private static void Sign(string inputFilePath, string outputFilePath)
            var license = new License();

            using (PdfFileSignature pdfSign = new PdfFileSignature())
                pdfSign.SetCertificate(PfxFileName, CertificatePassword);
                pdfSign.Sign(1, "Signature Reason", "Contact", "Location", false, System.Drawing.Rectangle.Empty);

Files: (1.4 MB)


Can you please share source files along with generated result and environment details so that we may further investigate to help you out.


I have added files.
Enviroment: windows 10, x64



Thanks for contacting support.

I have observed your issue and like to inform that I have created ticket with ID PDFNET-47666 in our issue tracking system to investigate and resolve this issue as soon possible.