In our digital age, sharing valuable or sensitive information securely is paramount, but unfortunately it’s also tricky. Portable Document Format (PDF) files are widely used for their versatility and ease of sharing/viewing. PDF is an open file specification, meaning not only can anyone build a PDF, but anyone can build a PDF builder/reader application. There are good and not-so-good PDF files just like there are good and not-so-good PDF applications.
If you open a PDF file with a text editor application, you can see what a PDF is made of: a bunch of numbers, letters, and strange characters. One can view the PDF “guts” and edit them, assuming they understand the structure, based on PDF specification. PDF Ink attempts to understand your PDF using PDF specification as a guide, and can then add encryption and passwords/protection to that PDF.
PDF security measures can be added in the form of passwords and file permissions, limiting printing, copying and modification and more, but due to the open specification of the PDF file format, these protections are not necessarily secure. Understanding that most humans are not out to cheat and steal, we know that applying security measures definitely helps us in doing our best to secure our intellectual property and sensitive material.
In this blog post, we will explore how to set PDF file permissions using PDF Ink, explaining PDF file encryption, the distinction between PDF owner and user passwords, limitations of these security measures, and yet how to take advantage of PDF security.
Setting PDF File Permissions with PDF Ink
PDF Ink gives you the choice which PDF writing library to use: TCPDF, FPDF, or SetaPDF-Stamper. All provide a straightforward way for us to edit PDFs programmatically, including the ability to set encryption and file permissions.
PDF Encryption is Required to Set Permissions
In order to set permissions, encryption must be set. If you do not turn on encryption in the PDF Ink settings, you will not see permission settings. Below in a GIF, you can see that “Document permissions” do not show unless the “Encryption level” is set.

OpenSSL is Required for Encryption
In order to set encryption, your server must support OpenSSL, and OpenSSL must be a version compatible with the server’s PHP version. If you have managed hosting, this will have been arranged for you in most cases. If you encounter errors when attempting to encrypt your PDF files with PDF Ink, verbose error messages may tell you that your server does not support OpenSSL yet, or that the PHP version is incompatible. Your host should be able to sort that out for you.
PDF Permissions
There are eight permissions which can be removed from a PDF if encryption is set:
⃡ | Print (High Resolution) | |
Copy | ⃡ | Extract/Accessibility |
Modify | ⃡ | Assemble |
Annotate forms | ⃡ | Fill Forms |
Learn more about each of the eight PDF permissions.
The permissions which can be reliably removed with 40-bit encryption are in the first column above (print, copy, modify, annotate forms).
We say reliably, because if any of these are set, their higher-level counterpart is also set when using 40-bit encryption. So if low print is turned off, then high print is turned off. If copy is turned off, extract is turned off. There is no nuance. And remember, 40-bit encryption isn’t very secure. So unless your site is hosted on cheap shared hosting, it’s probably worth it to upgrade to 128-bit in order to set nuanced permission controls.
If we use higher encryption (128-bit or 256-bit) the permissions in the right hand column (high resolution print, extract, assemble, and fill forms) can also be removed, and distinctly from the lower permissions:
Here are a couple of interesting examples that arise when using 128-bit and higher encryption. If print-high is disabled using 128-bit encryption but print is still allowed, then the end user might only be able to print a low-fidelity copy. Another example: if fill forms is disabled but modify is allowed, and those are the only permissions set, then all modifications except filling forms, annotating forms, and PDF assembly (insert, rotate, or delete pages and create bookmarks or thumbnail images) will be allowed. Depending on the PDF application, this might leave no modification privileges at all.
Owner vs. User Passwords
When dealing with PDF permissions, it’s crucial to understand the difference between owner and user passwords. Every PDF has two passwords:
- User Password: Optional. If set, this password is required to open the PDF file. If a user does not have this password and it is set, they cannot open the document to view the content. A user password can help limit the PDF access to specific individuals.
- Owner Password: The owner password controls the permissions of the PDF file, and is always set. The owner password is not required to open a PDF, but can be used to open a passworded PDF if the user password is not known, or instead of the user password. If a user has the owner password, they can not only open the PDF, but they can change the permissions of the PDF file and are not restricted from performing actions like printing or copying or editing, regardless of the original restrictions set by the document owner. Someone with the owner password essentially becomes the “owner” or “controller” of the PDF.
For example, let’s set the user password to ‘user_password’, and the owner password to ‘owner_password’ and restrict print and copy. Now anyone who wants to open the PDF will need the user password, “user_password”; but they can still be restricted from printing or copying the content unless they have the owner password, “owner_password”.
Understanding File Encryption
In order to set permissions and/or password a PDF, you must encrypt it. Encryption is a process that transforms the original data into a format that is unreadable without the appropriate decryption key. In the context of PDFs, this means that the file probably cannot be opened and/or manipulated without the correct passwords.
Encryption does not always mean that a password is required to open the document. You can encrypt a PDF to restrict certain actions (like printing or copying) without requiring a password to view the content. This is particularly useful for documents that you want to share widely but still want to control how they can be used.
Several levels of encryption are available with PDF Ink, each progressively stronger, yet each using more server memory to function. RC4-40 is included, yet we do not recommend you use it for critical documents, because it is vulnerable to brute-force attacks. If you choose to encrypt, please use at least 128-bit encryption, or whatever works best on your server. If your server can handle the load, go ahead and use 256-bit encryption, but really, for most cases 256-bit will be overkill.
The Limitations of PDF Security
While setting permissions, passwording and encrypting PDFs can provide a layer of security, it is not foolproof. There are several reasons why relying solely on PDF permissions can be problematic:
- Technical Expertise: A determined user with technical knowledge can often find ways to bypass PDF restrictions. There are various “hacker tools” available that can remove passwords and permissions from PDF files, allowing users to print or copy content even if those actions are restricted.
- Screen Capture: Even if printing is disabled, users can still take screenshots of the PDF content. This means that sensitive information can still be captured and shared, regardless of the permissions set on the document.
- PDF Readers: Different PDF readers may handle permissions differently. Some readers may not enforce restrictions as intended, allowing users to perform actions that should be restricted. In fact, this is a common complaint for PDF owners who forget that not everyone is using well-behaved PDF readers like Safari and Adobe Acrobat.
- User Behavior: Ultimately, the security of a PDF file also depends on the behavior of the users. If a user is determined to share the content, they may find ways to do so, regardless of the restrictions in place.
- Processing Time and Performance: Protecting a document requires encryption, which can significantly increase processing time, especially for larger files that contain images or fonts. This added processing can lead to PHP timeouts in some cases, particularly on shared hosting environments or servers with limited resources. It’s essential to consider the performance implications when generating encrypted PDFs, as this can affect user experience and system reliability.
Best Practices for PDF Security
Given the limitations of PDF security, it’s essential to adopt best practices when sharing sensitive information:
- Combine Security Measures: Use a combination of PDF permissions, encryption, and other security measures (such as watermarking) to protect your documents. Hot tip: invisible (fully transparent) watermarks are easy to apply with PDF Ink and are great for catching bad actors. Even better: tiny and transparent text marks with user data interspersed on certain pages.
- Educate Users: If you are sharing sensitive information, educate users about the importance of keeping the content confidential and the potential risks of sharing it.
- Regularly Update Security Protocols: As technology evolves, so do the methods for bypassing security measures. Regularly review and update your security protocols for file storage and dissemination to stay ahead of potential threats.
- Occasionally: Move the location of stored files and change passwords.
- Consider Alternative Formats: We have all heard news of some monied, high level government or corporation being hacked and know that… ultimately there is no such thing as a “secure file.” For highly sensitive information, consider using alternative formats or methods for sharing that provide stronger security measures. One suggestion is simply not sharing the information, since there is ultimately no such thing as “security” in this day and age.
PDF Guts
We can’t mention PDF guts without showing some PDF guts! Here are the “guts” of one of the most famous PDFs in America, the 1040 (2024 U.S. Individual Income Tax Return):