How to sanitize, optimize, compress & secure PDF files
Why & how to remove PDF metadata, JavaScript, & hidden information.
How to use PDF sanitization, optimization, and compression options, to reduce file size, increase performance and security.
When you share a secure PDF, it is not just the visible information you need to worry about. Every PDF comes with metadata describing who the author of the document is, when it was created, and when it was last modified. This information can be used to trace the file back to its creator, which is not ideal if you want to protect the identity of your employees. Additionally, some PDFs contain annotations, JavaScript, blank pages, attachments, and hidden information that you may not want distributed with its final draft.
In this guide, we’ll be exploring several ways to remove this information to ensure that you do not inadvertently share sensitive or private information. We’ll also cover ways to optimize and compress your PDFs before distribution to reduce file size and increase their load times and responsiveness. Adobe Acrobat and Locklizard Safeguard both offer PDF sanitization, optimization, and compression options, to reduce file size, but one provides much better protection for sharing PDF files.
How to sanitize PDFs to improve security |
Sanitize PDF files with Adobe Acrobat
Acrobat Pro comes with a “remove hidden information” feature that is designed to remove sensitive metadata from your PDF files. It is found by pressing the “Sanitize” button in the toolbar while using the “Redact” tool. Adobe’s sanitization removes PDF metadata, embedded files, JavaScript, unreferenced data, hidden layers and comments, etc.
You can also scan your document for metadata and selectively hide content/metadata to meet your use case.
Sanitize PDF files with Locklizard Writer
If you don’t have Adobe Acrobat installed then Locklizard customers can use our PDF DRM software to remove sensitive hidden content. By default, Locklizard automatically removes metadata and JavaScript from your document for security reasons, so we advise you to leave these options checked. However, you can customize which hidden elements you’d like to remove in its optimization settings. You can choose whether to:
- Remove Annotations
- Remove Attachments
- Remove Metadata
- Remove JavaScript
- Remove Blank Pages
The entire process takes just a few seconds and is very intuitive:
- Right-click the PDF and choose “Make secure PDF”
- Tick “Optimize PDF” and press the cog icon next to it.
- Tick the sanitization options you’d like to apply.
- Press the “Publish” button at the bottom of the window.
How to optimize PDF files to reduce file size |
PDF optimization involves removing elements that do not affect the appearance of the document to reduce the file size, improve load times, and increase responsiveness. This is particularly important if you plan to distribute protected PDF files for use with the Locklizard Secure Web Viewer and/or Android and OS devices which may have limited resources.
Optimizing a PDF is achieved by removing duplicate and unused elements. The savings you can achieve will depend on how many of these elements your PDF file has and how impactful they are. A simple PDF file consisting purely of text stands to gain less from optimization than a large, 100-page document with links, images, etc.
You can optimize PDF files in both Adobe Acrobat Pro and Locklizard Safeguard.
Optimize PDF with Adobe Acrobat Pro
PDF optimization in Adobe Acrobat is achieved by selecting the “Optimize PDF” button in its tool menu.
The “Discard Objects”, “Discard User Data” and “Clean Up” sections all contain options to reduce the file size of your PDF documents.
Optimize a PDF with Locklizard Safeguard
Optimizing a PDF with Locklizard Safeguard is just as easy:
- Right-click the PDF and choose “Make secure PDF”
- Tick “Optimize PDF” and press the cog icon next to it.
- Tick the optimization options you’d like to apply.
There are several PDF optimization options that increase performance and reduce the file size of your PDF documents. In the ‘Resources’ section select the following:- Remove unused objects: Removes resources that aren’t used in the document’s pages, such as objects that are not deleted along with a page when it is removed.
- Remove unused streams: When images are removed from pages but not removed from page resources, it can result in useless, left-over streams. This option analyzes page contents to determine which resource streams are used and deletes the ones that aren’t.
- Link duplicate streams: Sometimes documents contain several different resource streams (for example images) which are identical. This may happen when a document is concatenated with itself and the resultant document will contain two independent copies of the same resource stream. This option analyzes all resource streams and compares them. If some streams are duplicated, they are merged.
You should also select the sanitize PDF options in the ‘Additional section’ to remove them as well:
- Remove annotations
- Remove attachments
- Remove metadata
- Remove JavaScript – Safeguard secure Viewer does not process custom JavaScript so you should remove it as it will just use up unecessary space
- Remove blank pages
The more items you remove, the more quickly your PDF files will load.
- Press the “Publish” button at the bottom of the window.
When you publish your DRM-protected PDF, Safeguard Writer will take a second or two to apply these changes to your document.
How to compress a PDF (images) to reduce file size
PDF compression is primarily focused on reducing the size of PDF media (images, videos, etc.) to lead to lower file size and improved user experience. Unlike other optimizations, PDF compression is often lossy, with the quality of images and videos either marginally or drastically decreased depending on how much you decide to compress them.
How to compress a PDF with Adobe Acrobat
Adobe Acrobat PDF compression is achieved by pressing the “Optimize PDF” button in its sidebar and then selecting “Compress PDF” in the top bar. This will output it using Adobe’s default settings or settings you chose previously.
For further control, you can additionally press “Advanced Optimization” and change the compression options in the “Images” section. You can additionally adjust document structure compression options in the “Clean Up” section.
How to compress a PDF and secure it with Locklizard Safeguard
Locklizard Safeguard enables secure PDF compression through its combination of standard PDF optimization techniques and Digital Rights Management software. As well as compressing your files to reduce PDF file size, Locklizard can make sure that only authorized users can open it and nobody can edit, screenshot, print, or copy it unless you say so.
Here’s how to compress a PDF and secure it:
- Right-click the PDF and choose “Make secure PDF”.
- Tick “Optimize PDF” and press the cog icon next to it.
- Tick “Compress Images” and enter a number for the quality. A lower number means a worse-quality image, but a lower file size. We recommend trying the default of 85 and seeing how you get on.
- Optionally, enter page numbers that you want to skip – for example, 1 for the title page. You can separate pages by comma (6,8), enter a range of pages (11-15), or combine the methods (6,8, 11-15).
- Remove unused elements by selecting items in the ‘Resources’ and ‘Additional’ sections. This will make your compressed PDF file even smaller.
- Press “OK” and choose the security options you want to apply to your PDF. You can restrict printing and screenshots, add an expiry date or watermark, and more.
- Press “Publish” at the bottom of the window
Your secure, compressed PDF file will be output in the encrypted .PDC format. Users will only be able to open it in the Safeguard Viewer application after installing a valid license file (generated by the Safeguard Admin system) on their PC. As licenses are single-use (unless you choose otherwise) and the decryption keys it transfers cannot be moved, only authorized devices will be able to open the document.
As you can see from the image above, applying PDF compression can dramatically reduce the file size of image-heavy documents.
Adobe vs Locklizard PDF security
If you are familiar with Adobe Acrobat, you will know that it offers its own security for compressed PDF files. It is important to understand that Locklizard offers dramatically improved security when compared to Acrobat Pro.
Acrobat Pro uses password protection for security. As we have covered in our blog on Adobe PDF encryption, passwords are not a secure mechanism. The permissions password, which is supposed to stop editing and printing is trivial to remove using online tools. The open password can be brute-forced or shared by an authorized user with others. Even Adobe DRM cannot stop screenshots, which are one of the easiest ways for users to share information.
As Adobe cannot prevent editing or copying, adding a watermark to a PDF is also useless. Users can either delete the watermark or copy the document contents to a new file with no watermark. Though Acrobat does not have built-in expiry controls, any expiry plugins or document revocation are also useless, as users can simply make an unprotected copy of the PDF before it is revoked.
The best choice for PDF sanitization and protection
Locklizard doesn’t just compress PDFs and make them uneditable – it gives document publishers modular control over how their documents can be used and who can use them. With it, admins can:
- Stop users copying and pasting text and images
- Block screenshot grabbers
- Prevent sharing by locking PDFs to devices
- Revoke users and documents at any point, regardless of location
- Expire documents on a fixed date, after a number of prints or views
- Track document use, including how many times a document is opened or printed
- Prevent printing of PDF files
- Lock access to IP addresses and countries
- Allow offline use with full security enforced
- Use our API and command-line tools to automate PDF protection and user management
This flexibility, combined with robust compression, sanitization, and optimization features makes Locklizard a one-stop-shop for secure PDF publication and distribution.
To compress and secure your PDF without passwords and ensure permanent protection of your sensitive information or ebook, take a 15-day free trial of our DRM software.
FAQs
What does it mean to sanitize a PDF?
It means to remove hidden information that may disclose confidential or sensitive information. This differs from redaction which is the censoring or obscuring of a part of visible text for legal or security purposes.
What is hidden information in a PDF?
This could be metadata, links, images, layers and JavaScript that is executed when a certain action or event occurs.
What is the purpose of removing hidden information in a PDF?
The purpose of removing hidden information in a PDF is to:
- Prevent sensitive or confidential information being exposed
- Reduce the file size
- Optimize the PDF so it loads quicker
What is a PDF optimizer or PDF compressor?
A PDF optimizer or compressor is software used to reduce PDF file size by removing uncessary elements such as metadata, JavaScript, hidden information, etc., and by compressing images so that they take up less space. Most PDF Editors provide compression and optimization functionality.
Why should I use PDF optimizer or PDF compressor software?
By optimizing a PDF using a compression tool you can create a smaller file for email, upload and download, and have it load quicker in a web browser. Be aware that image quality of graphics in the document (jpg, png, etc.) will be reduced if you apply heavy compression.
Can you compress a PDF and secure it with Acrobat?
Yes, but if you use Adobe password protection to secure a PDF then users can remove the password and any restrictions to prevent editing, copying and printing.
You can use Adobe Acrobat to compress, sanitize and optimize PDF documents before securing them with Locklizard and/or use Locklizard to perform these functions when protecting a PDF. Both products remove all metadata, JavaScript and other hidden information to reduce file size and increase performance.
If I remove JavaScript from PDF files will forms still work?
No, since JavaScript is used for PDF form functionality. Locklizard only support basic forms functionality (custom user JavaScript is NOT supported) to prevent our Viewer being exposed to AcroForm vulnerabilties. You can use Locklizard for secure PDF form submission without having to worry about malicious JavaScript being executed.
How do I mask confidential information in a PDF?
Use any PDF editor’s redact tool to mask out confidential content. Failing to do so will allow somebody to remove the mask using normal PDF editing tools. Alternatively, use Locklizard Safeguard to sanitize a PDF when protecting it.
How do you compress an encrypted PDF?
If it has an open password then you need to remove that first. You can then use either Adobe or a similar tool to compress it and reduce the file size. This is also the case if you want to reduce the file size of a secured PDF.
If it is a Locklizard DRM encrypted PDF then you cannot compress it. Only an unprotected PDF can be compressed during the encryption process.
If I optimize a PDF using Locklizard how much will it reduce the file size?
The amount the file size will be reduced by will depend on how much hidden information and unused functionality can be removed (JavaScript, PDF metadata, unused streams, etc.), and by the amount of compression you apply to images.