We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Sign PDF and Add Watermark using Aspose.PDF for .NET - Second signature causes first one invalid if watermark was added


We have been using Aspose.PDF to convert DOC to PDF/A, add watermarks, and sign document.
We have found that the result PDF/A file is invalid for multiple signing if it contein watermark .

We have the following flow:

Convert DocX to PDF/A-1B
Add watermark to the PDF/A-1B
Sign PDF/A-1A with first signature
Sign PDF/A-1A with second signature

And after step 4, the first signature (applied on the 3td 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-1A 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: perhaps this issue related to 206359 or 206359

Code example:

using System.IO;
using Aspose.Pdf;
using Aspose.Pdf.Facades;
using Aspose.Pdf.Text;
using Aspose.Words.Saving;
using PdfSaveOptions = Aspose.Pdf.PdfSaveOptions;

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

        static void Main(string[] args)
            var input = @"D:\pdfaSigningIssue\docx.docx";
            var converted = @"D:\pdfaSigningIssue\converted.pdf";
            var withWatermark = @"D:\pdfaSigningIssue\withWatermark.pdf";
            var firstSign = @"D:\pdfaSigningIssue\firstSign.pdf";
            var result = @"D:\pdfaSigningIssue\result.pdf";

            ConvertToPdfA1b(input, converted);
            AddWatermarkAndConvert(converted, withWatermark);

            Sign(withWatermark, firstSign);
            Sign(firstSign, result);

        private static void ConvertToPdfA1b(string inputFilePath, string outputFilePath)
            new Aspose.Words.License()

            var inputDocument = new Aspose.Words.Document(inputFilePath);
            var pdfSaveOptions = new Aspose.Words.Saving.PdfSaveOptions();
            pdfSaveOptions.OutlineOptions.HeadingsOutlineLevels = 9;
            pdfSaveOptions.DmlRenderingMode = DmlRenderingMode.DrawingML;
            pdfSaveOptions.Compliance = PdfCompliance.PdfA1b;

            inputDocument.Save(outputFilePath, pdfSaveOptions);

        private static void AddWatermarkAndConvert(string inputFilePath, string outputFilePath)
            var license = new Aspose.Pdf.License();
            using (Document pdfDocument = new Document(inputFilePath))
                TextStamp textStamp = new TextStamp("Test stamp", new TextState
                    FontStyle = FontStyles.Bold,
                    ForegroundColor = Color.Red
                foreach (Page page in pdfDocument.Pages)

                // we had to convert file to PDF/A-1b becouse
                // aspose saves loaded PDF/A-1b as PDF. 
                pdfDocument.Convert(new MemoryStream(), PdfFormat.PDF_A_1B, ConvertErrorAction.None);


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

pdfaSigningIssue.zip (443.4 KB)


Thanks for contacting support.

I have observed your issue and like to inform that I have created ticket with ID PDFNET-47669 in our issue tracking system to investigate and resolve this issue as soon as possible. We will share good news with you soon.


Any news on this issue? I have the same problem.



We are afraid that issue is not yet resolved. However, we will surely inform you as soon as we have some certain news regarding its resolution. Please spare us some time.


We are wondering whether there are any updates regarding the issue in Aspose?

Thank you in advance.

Best regards, Oleh


Your issue has been under investigation but, we are afraid that it is not yet resolved. We will surely share updates with you as soon as some are available regarding fix of this issue. Please spare us a little time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-47669) have been fixed in Aspose.PDF for .NET 21.9.