Omer Farooq
Omer Farooq

Reputation: 4084

How to apply password prompt javascript on acrobat pdf

I have a pdf which needs a javascript prompt that would asks for a username and password or just one of these. I have tried the native javascript way inside the javascript editor of acrobat. Alerts work fine but prompts are not working for me.

var customerName = prompt("Please enter your name", "");

have also tried

var customerName = app.prompt("Please enter your name", "");

EDIT: WEll i tried to remove the complex parts of the process so that you guys can understand better. but i guess i owe you guys some explanation on what i am trying to achieve.

Well i have an empty pdf which i am going to send to my users and when it is opened it will ask for a username/password which is then submitted to my website through an api. I already have an api in place which would check for the correct credentials and on success would print the desired pdf content on a php page, which could be grabbed as a curl request through the javascript inside the empty pdf. And when i want to revoke the access to the user i would just delete the user from the database on my server. So the next time he wants to read the pdf he wont be able to pass through the api security.

Well i know there are some drawbacks on applying so many restrictions like pdf reader compatibility etc. but even if it only works on acrobat that would be fine. Later on will try to remove the print and save options etc.

Most of the parts are done the only thing i am stuck at the moment is on how to send a form GET request to a url. I think js prompt doesn't work in acrobat so i guess i have to send the data through an acrobat form. Any one knows how can i send a get request through the forms or get the values of input boxes in javascript?

Upvotes: 1

Views: 1402

Answers (1)

Omer Farooq
Omer Farooq

Reputation: 4084

Thank you everyone, i just found out on how to post data to a webpage. Here is the link, Can a PDF fillable form post itself to an HTTPS URL?

Instead of choosing "PDF the complete document" from the format options, choose html.

Upvotes: 1

Related Questions