0

I have started using pdftk-php to populate form data into a pdf. Everything is working great. I would like to prompt the person viewing the newly created pdf (which is being viewed in the browser window) to add a password to protect the pdf prior to downloading/saving. I have found the answer to adding passwords to pdfs using pdftk command line commands. However, I do not understand how to execute it in php. I found this line:
pdftk sales_report.pdf output SalesReport.pdf user_pw PROMPT
in the page: https://www.linux.com/learn/manipulating-pdfs-pdf-toolkit. Can anyone tell me how to modify the pdftk-php files to get this to work from within the php environment?

Moppo
  • 18,797
  • 5
  • 65
  • 64
Humphrey
  • 1
  • 2

1 Answers1

0

Figured it out. Simple answer. In the pdftk-php.php file go to/around line 73 and locate the passthru() line. Append the end of the line after "output -" to say "output - user_pw $password" $password being the regular text password without the "$". This doesn't prompt for creation of a password but does allow, through php, to create a variable on the page and use that as the password. Worked for my needs.

Humphrey
  • 1
  • 2