I need to password protect my PDF file(s), because I am going to send them through email and I want anyone who would view my PDF file(s) to be prompted for a password.
How can I add a password to a PDF in Linux Mint 17.1?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You can use the program
pdftk to set both the owner and/or user password
pdftk input.pdf output output.pdf owner_pw xyz user_pw abc
user_pw are the commands to add the passwords
abc respectively (you can also specify one or the other but the
user_pw is necessary in order to prohibit opening).
You also might want to override the default 40 bit encryption strength by adding:
The pdftk toolkit allows for this type of functionality on Linux.
sudo apt-get install pdftk
pdftk. You will see a bunch of pdftk command instructions if it already installed
pdftk <source>.pdf output <destination>.pdf userpw <password>
pdftk Mydocs.pdf output Mydocs_pass.pdf userpw secretword
On Fedora, you can use pdf-stapler to set a password for a PDF file, and also perform other pdftk-like operations.
Example to set the user password (the one required for opening the file):
pdf-stapler -u QRNFFtVXA-8PqF cat input_file.pdf output_file.pdf
This is the password you think of most likely about setting a password to a PDF file.
In case you want to set the owner password (the one that defines permissions like printing, commenting, ect.), use the
Using tools from the Poppler Toolset (from a package like
poppler-tools), you can achieve this with a combination of
pdftops in.pdf out.ps ps2pdf -sUserPassword=XXXXX -sOwnerPassword=YYYYY out.ps out.pdf
Note that to set a User (view) password, you must set an Owner (edit) password.