These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

URGENT: Manage access and usage rights on pdf document using Acrobat Javascrip

Anis
Registered: Nov 2 2011
Posts: 3

Hi everybody,

I have pdf document on my website, and I want to manage access right on those documents, some users has the right to print, save the document and others not,

So I'd like to know if it is possible to do it using Acrobat Javascript, and how I can do it if you have any exemple of script, document it will be very helpfull for me, I'm looking for that from two weeks already!!

Thx

My Product Information:
Acrobat 3D 8.0, Windows
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Impossible with JavaScript.

Also impossible to prevent the Save operation. PDFs don't stream, you can't open them unless you've already saved a copy.

If you just have two options for each PDF file (print or not) then it'll be easier to create two copies, secure one of them, and add code to your website so a logged-in user can only see one of the copies depending on who they are. How you do that is beyond the scope of these forums but on a dynamic website with user accounts it's a trivial concept.
Anis
Registered: Nov 2 2011
Posts: 3
Hi thank you for your answer
It is impossible to have 2 copies of all my files, I have thousands of PDF files!!
I wish it is possible to manage that using Acrobat Javascript.
And I think that it should be possible in the acrobat javascript scripting guide i saw this following code it allows full and unrestricted access to the entire document for one set of users (importantUsers), and allows high quality printing for another set of users (otherUsers):
// Obtain the security handler:
var sh = security.getHandler("Adobe.PPKMS");
// Connect to the directory containing the user certificates:
var dir = sh.directories[0];
var dc = dir.connect();
// Search the directory for certificates:
dc.setOutputFields({oFields:["certificates"]});
var importantUsers = dc.search({oParams:{lastName:"Smith"}});
var otherUsers = dc.search({oParams:{lastName:"Jones"}});
// Allow important users full, unrestricted access:
var importantGroup = {
oCerts: importantUsers,
oPermissions: {allowAll: true}
};
// Allow other users high quality printing:
var otherGroup = {
oCerts: otherUsers,
oPermissions: {allowPrinting: "highQuality"}
};
// Encrypt the document for the intended recipients:
this.encryptForRecipients({
oGroups:[importantGroup, otherGroup],
bMetaData: true
});
what i'm looking for should be similar to this !!
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Trust me it's impossible with Acrobat JavaScript. What you saw in the documentation is about applying security when a document is first *created*, NOT about modifying the policy when a document is viewed.
.
.
You could apply security using a dynamic PDF class on your server (based on the user logged-in to your website). Adobe sells one (the Adobe PDF Library SDK) and there are third-party libraries such as FPDI-protection that can read in an unsecured PDF, apply permissions and route it to the output stream.
Anis
Registered: Nov 2 2011
Posts: 3
Thank you very much UVSAR for your answer.