So I guess this is a Topic which many had to discuss upon or maybe some people are finding a reliable solution to this. So after lots of R&D I have finally come up with a reliable solution to this problem
Firstly what kind of PDF’s can be treated in this case
- Password protected PDF’s
- Password Protected PDF’s with attachments in it
So the best part of this utility is a PDF which has attachments generally when we remove passwords when using online sites the attachments inside it are lost but with this utility attachments also can be retrieved and maintained within the PDF.
So the name of this utility is QPDF.
You can read about this more on - GitHub - qpdf/qpdf: Primary QPDF source code and documentation
So basically what this utility does is, just with a simple one line command fired in Powershell we can remove the password from PDF irrespective of what encryption the PDF has
Node.js setup file - Node.js (You can download any version you want the LTS and latest both versions work in this case)
Below are the steps
- Install Node.js but keep in mind while installing when you come up at this screen
Make sure to tick the checkbox in the image it is not ticked but you have to compulsorily check mark it.
Now why to tick this mark the motive is to install a package manager named Chocolatey which actually contains this QPDF utility, so Once this is tick marked the node js installer will automatically install the Chocolatey package manager it takes a while but it’s worth the wait. Reboot your system once installtion is done. Not Necessary but do it to avoid future errors.
- Now Once this is installed you can open a powershell with (administrator rights) to check whether chocolatey is properly installed or not, hit the command $choco
After firing the command if chocolatey is installed properly your system will return a message with the version of chocolatey installed in your system which means you are good to go
- Open a fresh powershell command window with administrator rights again Install the QPDF utility by firing the command
choco install qpdf
In my system it is already installed that’s why it is throwing a message of already installed but for you it will be different just wait till the installation is finished.
- Finally the Testing. To remove the password from the PDF’s the command is :
qpdf -password=your_password -decrypt /path/to/secured.pdf /path/to/decrypted.pdf
Make sure to give all paths and provide the PDF opening password in the password parameter
Example command :
qpdf --decrypt --password=22205024080 "C:\Users\Ishan\Downloads\Secured.pdf" "C:\Users\Ishan\Downloads\output_file.pdf"
The resulting pdf will be a no password PDF, and if it contains attachments the attachments will also be preserved. You can use Invoke PowerShell Code or directly open CMD through UI and play along with the command
Below is an example attached in what way you can use this Utility.
QPDF.zip (3.6 KB)
Just put your encrypted PDF in the input folder and make sure to check all paths. After everything is done just run the workflow. . Let me know your observations