Copy link to clipboard
Copied
I want to do the following in web application developed using .NET(JQUERY, ANGULAR):
1. Check PDF is password protected or not
2. Check PDF is corrupted or not
Please help with sample codes and examples
The AxAcroPDFLib is client side, so you're talking about having something that will run on the browser. In that vein. I do not know if there are any extensions to browser JS for examining a PDF. I doubt it. The Acrobat browser API (AxAcroPDFLib) is weak. It does not contain any objects of function that provide details on security. But the Acrobat JavaScript "doc.Security" object does provides information on PDF security. To use this function you need to run a script inside the Acrobat/Reader sc
...Copy link to clipboard
Copied
You cannot know either of these things without a tool that parses a PDF file, for example, a viewer like Acrobat. However, you could write a relatively simple program to examine the PDF trailer to find out if there is security applied to the PDF.
.Net would work for this because you can open files and get byte level info, but you can't get any of this info from JavaScript. JQuery is just a layer on top of JS so the same applies.
And finally, there is absolutely no way to know if the PDF is corrupted without a tool that fully parses the PDF.
Copy link to clipboard
Copied
Thanks, I would go with C#. Please can you help what do I need to check PDF security in C#. what is recommended PDF trailor and API?
Appreciate if you can share some sample coding.
Copy link to clipboard
Copied
I think C# will work fine, but I have never written any code for parsing a PDF trailer, so that's something you'll need to do yourself.
To do this you need to read the PDF Specification as it relates to the trailer. In this case you shouldn't need an API. You'll need to write code to parse the trailer.
On the other hand, there are some free PDF libraries, such as Quick PDF from FoxIt. You may be able to get the info you want with one of these, which would be much simpler that parsing it yourself. But again, I haven't done this myself.
Copy link to clipboard
Copied
Are there any methods or properties in AxAcroPDFlib library to check PDF's security like password protected or not?
Copy link to clipboard
Copied
The AxAcroPDFLib is client side, so you're talking about having something that will run on the browser. In that vein. I do not know if there are any extensions to browser JS for examining a PDF. I doubt it. The Acrobat browser API (AxAcroPDFLib) is weak. It does not contain any objects of function that provide details on security. But the Acrobat JavaScript "doc.Security" object does provides information on PDF security. To use this function you need to run a script inside the Acrobat/Reader scripting environment. This can be done from the IAC. I don't know for sure that this can be used from the browser, but if it is possible to write a VBA script for IE, then you can call the JS function through the "JavaScript Object" in the IAC.
You can read about it here: Acrobat DC SDK Documentation
Copy link to clipboard
Copied
Another thought. There is a bridge between Acrobat JavaScript and Browser JavaScript for a PDF displayed in Acrobat/Reader on the browser. This bridge only works if there is supporting JS in the PDF. So if your documents are under your control you could use this bridge to get the security info.