Can I check if PDF is signed?

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  Can I check if PDF is signed?

DynamicPDF CoreSuite for .NET (v10) Forum

 Oct 08 2018 2:18 PM
Hello,
Is there a method in Merger to check if document is signed before I manipulate it?
Thanks,
Anna
 Oct 08 2018 4:30 PM
Posted by a ceTe Software moderator
Hello,

Merger does not have the capability to detect if a PDF is signed or not. We don’t have any other products that can detect signed PDFs.

Thanks,
ceTe Software Support Team.
 Apr 05 2020 3:35 PM
Has there been any change since this was originally brought up?  Even if it were a simple boolean "IsSigned" would be extremely useful. 
What we need to do is change our workflow of what we do with the PDF if it's signed or not and this may be a show stopper for us.

Were you able to find a work around or did you have to go with a different product that offered the functionality (if so, which one did you go with)?

Thanks,
 Apr 06 2020 8:42 AM
Hello,
This is what we did
private bool IsSigned(string pdfAsText)
        {
            int part1 = pdfAsText.IndexOf("/Adobe.PPKLite");
            if (part1 < 0) return false;

            int part2 = pdfAsText.IndexOf("/M(D:");
            if (part2 < 0) return false;

            int part3 = pdfAsText.IndexOf(")/Name(");

            if ((part3 <= part2) || (part2 <= part1)) return false;

            // scan for "/M(D:" soon followed by ")/Name("
            return true;
        }

Been using it for 4 years now, seems to work.
 Apr 06 2020 12:15 PM
Posted by a ceTe Software moderator
Hello,

Our developers are working on this feature and we will be releasing it soon. We will update this post once it’s ready for download.

Thanks,
ceTe Software Support Team

 Apr 10 2020 10:17 AM
Posted by a ceTe Software moderator

Hello,

This feature is included in the latest release, DynamicPDF for .NET v10.27. You can download latest from Nuget (product ID: ceTe.DynamicPDF.CoreSuite.NET) or from our website here.

Please use the Signed Boolean property of the PdfDocument object to check whether the PDF is singed or not. Below is a code sample.

            PdfDocument pdf = new PdfDocument(@"Input PDF file path");
            bool isSigned = pdf.Signed;

Thanks,
ceTe Software Support Team
 May 07 2020 3:35 PM
Posted by a ceTe Software moderator
Hello,

The feature to detect whether an existing PDF is protected with a user or owner password is included in latest release, DynamicPDF for .NET v10.28. You can download latest from Nuget (product ID: ceTe.DynamicPDF.CoreSuite.NET) or from our website here.

Here is a code sample:

       EncryptionInfo info = PdfDocument.GetEncryptionInfo("PDF file path or byte array");
       bool hasOwnerPasword = info.HasOwnerPassword;
       bool hasUserPassword = info.HasUserPassword;
                
Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 7:55 PM.