Preview and PDF: Remove a password which I do know

I have a protected PDF file, in which I cannot highlight text using Preview and which I cannot print without a password.

enter image description here

I do know a password, but I cannot understand how to remove it from the document. I can click File > Enter Password and then Unlock as Owner, but the next time I open the document, it will be required to type the password again. How to do this?

enter image description here

I use a shell script, which I have added to the Quick Action list using Automator.
I first installed qpdf using HomeBrew, then this works:

qpdf --decrypt --password=12345678 --replace-input “$1”
qpdf --decrypt --password=abcdefgh --replace-input “$1”

The 2 lines means it can try both passwords. I have 4 set up to remove passwords from bank statements.

edit: (I also have this in Hazel watching a folder)

3 Likes

Thanks, but maybe there is a way to remove the password without installing third-party tools? (Of course, this is OK to use a third-party tool to unlock a PDF file if I don’t know the password, but I do know the password, and using third-party tools looks as something that I would prefer to avoid.)

How to remove password from PDF on Mac (setapp.com) :

Most Mac users tend to overlook Preview and try to find substitute apps right away. For no good reason! Preview is a powerful app installed on your Mac by default and can perform most PDF manipulations you’ll ever need.

One of those is simple PDF unlocking, which you can essentially do by opening a PDF file and exporting it as PDF one more time. The duplicate PDF then won’t have password protection.

Here’s how to remove password protection from PDF with Preview:

  1. Launch Preview and open your password-protected PDF
  2. Enter the password
  3. Go to File ➙ Export as PDF…
  4. Select the location and name
  5. Click Save
2 Likes

Unfortunately, this doesn’t work for me. I already tried this yesterday and also just now. The exported PDF still requires the password.

I had this exact problem just the other day.

I did have the password and could get in to view the document in Preview. But I wasn’t able to remove the password with the export tool.

I gave up fairly quickly.

My work around was to ‘Print PDF’, basically just creating a new version of the file that way.

3 Likes

Yeah, this works, but the new document will be either just ugly or simply not looking exactly the same, because you will need to manually adjust paper size and margins.

Try: Instead of “exporting” a PDF, open in Preview then “Print …”, then “save to PDF” and look at Security options that there are no passwords. Or send the print to Preview as a new PDF.

This would have been my next idea too. You can also use this technique with Google Chrome.

You should be able to use Adobe Reader to change permissions of the PDF.

How to remove a PDF password in 3 easy steps | Adobe Acrobat

I have tried qpdf and it seems the simpler solution is simply

qpdf --decrypt from.pdf to.pdf

That doesn’t seem to work for what I want, which is to overwrite the original file. Nice and neat though for your use case.

@GraemeS Then maybe the following version instead?

qpdf file.pdf --decrypt --replace-input

This seems to overwrite the protected file with unprotected in-place. Are there any disadvantages of this version you know about?

1 Like

Only that it’s the one I know and it works!
I’ll give this a try, thank you :slight_smile: