49

I experienced a behaviour I've never seen before when opening, editing and saving a PDF today. As soon as save the PDF with Preview the file will be password protected, and I cannot open it again.

I've tested this on multiple files, but it seems to only affect files that have an "administrator password" set.

Test files from the Swedish Social Insurance Agency: https://www.forsakringskassan.se/wps/wcm/connect/b581c10a-8782-4c84-8448-4a469b85422b/fk7457-004-f-002.pdf?MOD=AJPERES&CVID=&CACHE=NONE&CONTENTCACHE=NONE

https://www.forsakringskassan.se/wps/wcm/connect/def06bb9-268f-47bd-a99d-2aa3dd75f855/fk7804-004-f-001.pdf?MOD=AJPERES&CVID=

Is this behaviour somehow by design? I've never seen it before, and at first I suspected that some kind of malware caused this. But now I'm not so sure anymore.

I'm using macOS Monterey 12.2.

5
  • Did you figure out how to get around this? I'm trying to edit a govt related doc which I've edited before but now it's always getting locked when I save changes. It won't accept the Mac password as the password either
    – Chirath
    Commented Jun 6, 2022 at 10:46
  • 2
    Hi @Chirath, didn't find any solution no. I think it's a bug in Preview Commented Jun 6, 2022 at 15:38
  • Running into the same thing on MacOS Monterey 12.6 (21G115). Crazy
    – Luca Steeb
    Commented Oct 26, 2022 at 15:09
  • Yep, Australian immigration forms do these and now I can't access the pdfs anymore. Preview is garbage software. Who thought it's a good idea to password protect the pdf without the user's knowledge or input? Commented Apr 13, 2023 at 5:37
  • I have the same problem (MacOS Ventura 13.2.1). I tried my account password but it didn't work, looked in keychain but couldn't come up with a solution. Using Acrobat Reader instead of Preview works fine for new pdf files, but I would be interested to open the pdf files that have been protected by Preview.
    – matslew
    Commented Apr 14, 2023 at 14:44

12 Answers 12

16

I have the same problem with documents from the Australian government on macOS Monterey 12.5 with Preview Version 11.0 (1033.4).

My current workaround is to open and edit the document in Chrome and then save it with my edits. This results in a saved file that I can view without a password.

1
  • 3
    I had the same problem with Australian government documents, like Medicare. Ended up installing Adobe Acrobat Reader that let me save without encrypting.
    – thameera
    Commented Oct 7, 2022 at 12:35
16
+100

This behavior is definitely not by design. The Preview application is corrupting the PDF file upon saving changes. I reported the bug to Apple in FB13736350.

Workaround

You need to use Terminal for this workaround but it is guaranteed to fix the broken PDF file.

LC_ALL=C \
sed \
  -i '' \
  -e 's/\/EncryptMetadata false/\/EncryptMetadata true/g' \
  path/to/affected/file.pdf
  1. Replace path/to/affected/file.pdf in the above command with the path to the broken PDF file.
  2. Run the command in Terminal.

That’s it! The PDF file can be opened once again and it will not become corrupted by Preview on subsequent saves.

Root Cause

I copied my Apple feedback report to OpenRadar, so anyone can read it.

TL;DR Preview has a bug where it subtly corrupts a value inside the PDF file upon saving changes. That value is used when deriving the encryption key. Since Preview changed the value, the original encryption key cannot be derived, so the PDF file cannot be decrypted.

9
  • Thanks for the +100 bounty, kind stranger!
    – fumoboy007
    Commented Apr 19 at 9:17
  • Thank you for documenting this work around!!
    – tmm1
    Commented Apr 22 at 4:13
  • Thanks! Please keep us posted on any activity from Apple on your bug report.
    – Pieter
    Commented Apr 24 at 17:17
  • AWESOME!!! Thanks!
    – Luntegg
    Commented May 26 at 21:33
  • I just tried this but unfortunately it's not working for me.
    – kait
    Commented Jun 11 at 21:07
9

I have the same problem with Australian Government forms on my MacOS Monterey 12.6 and Preview 11.0 (1033.4). I think I've found the best workaround which still allows editing after re-opening the document; by expanding a bit from Cailean's answer:

  1. Open the PDF. You can start filling the fields but DON'T save it

  2. Hit File > Export... > Permissions...

  3. Type in 'Owner Password' (any password will work)

  4. Above 'Owner Password', make sure to tick all the checkboxes under 'Permissions'. These will allow changes to be made without entering password in the future. Preview allow all permissions

  5. Hit Apply > Save. You can save the file with the same name, just confirm the overwrite by clicking the 'Replace' button.

  6. Fill up the PDF fields and save normally.

  7. Close the document and re-open it, it shouldn't ask for password and you should still be able to edit it just fine.

3
  • This is the best solution out of the listed Commented Aug 11, 2023 at 11:54
  • 2
    "File > Export... > Permissions..." - no such thing in Sonoma Preview. Just a regular Save dialog when I click "File > Export"
    – ADTC
    Commented Jan 20 at 19:21
  • As @ADTC said, File > Export > Permissions is no longer an option, but now on the save location menu there is an option to adjust the permissions. You can tick all of the boxes allowing edits to be made in the exported file without any password required
    – mikey
    Commented May 21 at 15:40
7

The bug in Preview is that if the original PDF had an owner password that prevented some actions but still allowed you to view and fill forms, when Preview saves or exports the file, it sets that password for ALL actions, thus locking up the file from even being viewed without the owner password.

For example, if the original file has an owner password set to prevent inserting or deleting pages:

(Click "Tools > Show Inspector > 🔒 icon" to see this dialog.)

Preview's Encryption Inspector showing one permission denied.

Then the file saved by Preview will have ALL permissions denied:

Preview's Encryption Inspector showing all permissions denied.

Has this bug ever been reported? I don't know.

Will Apple ever fix this bug? I don't know.

PS: One way to circumvent is to use the "Print" option then click the PDF button in the Print dialog. This creates a new PDF that's not form-editable, but you can still view it, and there's no password of any kind in it. (Note: Be sure to finalize any field you're currently editing by clicking outside it before you use the Print option, or that field will become blank in the printed PDF.)

2
  • The issue is indeed caused by a bug in Preview but the description of the bug in this answer is not accurate. See apple.stackexchange.com/a/471985/45340 for more details.
    – fumoboy007
    Commented Apr 18 at 1:33
  • Okay, I guess that's the technical reason. What I shared is what I could observe, which may not be what's actually happening, but it certainly looks like it does. :)
    – ADTC
    Commented Apr 19 at 5:32
6

I called the Immigration Department (Australian Government) and they can't give me a password for the document.

Here's the solution: open the PDF with Adobe Acrobat Reader, edit it with Acrobat, save it with Acrobat. This is the only 'supported' PDF reader.

I downloaded the form again and tired Acrobat; it works.

I downloaded a new form again and tried it with MacOS Preview; it password protects on save.

Further investigation shows that the password is applied (not sure of the correct word) as soon as you edit/save with Preview. Acrobat does not do this.

Preview is clearly broken and should never be trusted with anything important again.

I can't even verbalise my level of anger over this.

1
  • 1
    I'm seeing a slightly different issue: a password-protected document, after saving it with Preview, now has a different password, no idea which. Clearly, Preview is bugged there. Commented Mar 27, 2023 at 6:21
3

The pdf was created with security features enabled. Only the creator of the document would be able to change the security settings. The following screenshot shows what can and cannot be done.

enter image description here

3
  • I noticed that there was security settings that couldn't be changed without a password. But I've never before seen a file that will get password protected as soon as I re-save it. I also tested this on one of my older macs (with Big Sur), and there the files saved without needing a password the next time I opened them. Is this a new feature of macOS Monterey?
    – c3p0
    Commented Feb 7, 2022 at 21:56
  • 1
    It's not that the new file is being password-protected; the original file needs the password in order to make any changes. The 2nd restriction listed above shows "Not Allowed". The "Content Copying" means that you can copy text from the document.
    – agarza
    Commented Feb 7, 2022 at 22:01
  • 2
    That would make sense, but it's not what I'm seeing, hence the question. My new file definitely gets password protected. It's enough to just open the file, and re-save it to another location.
    – c3p0
    Commented Feb 7, 2022 at 22:12
3

This worked for me when other answers did not.

After opening the file in Preview and typing data into the form, I did the following without saving the document first.

  1. File > Print
  2. In a dropdown that defaulted to PDF, I selected Save as PDF
  3. A new popup appears. Click the Security Options button
  4. A new, new, popup appears (so much fun!)... make sure the boxes are unchecked for required password. Click OK.
  5. Click Save
  6. Click Print

Result: PDF saved with filled-out info and it is able to be opened in Preview again without a password.

Preview: v11.0 (1056.2.4)
MacOS: Sonoma 14.1.1 (23B81)

1
  • 1
    You don't need steps 3 and 4 unless you're adding a new password. The Print option creates a new PDF from scratch and will always be unencrypted and unprotected by default. It will never copy the password from the original PDF. Also, there's no step 6.
    – ADTC
    Commented Jan 20 at 19:13
1

I found 2 things that worked for me:

Option 1

Open pdf in web browser (e.g. Chrome) and print, then "Save as PDF". So, right click the pdf, Open With -> Google Chrome. Then

File -> Print... -> Destination -> Save as PDF

Option 2

The password may be an empty string, i.e. when presented with a password prompt, just hit enter.

So, for me, I opened the file using Adobe Acrobat, went to:

File -> Properties (cmd-D) -> Security -> Security Method -> No Security

screenshot of the Document Properties -> Security pane

It will probably ask you for the owner password at some point; as mentioned, try just hitting ok without typing anything.

In Preview, File -> Enter Password... or File -> Edit Permissions... there's some things you can fiddle around with, but I couldn't figure out how to remove the options entirely.


For background on my issue, when I downloaded my W-2, it was stated to be "password encrypted" and, although it viewed fine in Preview without needing to type in a password, trying to upload it to a Tax Software the software complained that it was password protected so I had to do this to get the tax software to read it correctly.

2
  • "The password may be an empty string" - You were just incredibly lucky this time. LOL
    – ADTC
    Commented Jan 20 at 19:24
  • I was about to add an answer equal to option 1, it worked for me. The pdf does look a little different and the form fields are no longer clickable but luckily for me I've already filled it out
    – Sam
    Commented Feb 7 at 19:45
1

Open the browser. Log into Microsoft One Drive. Upload the pdf document to Microsoft One Drive. And open from there. It did open and showed me the contents.

1
  • It looks like Google Drive would do the trick too. As some other answer suggested, select Print from the PDF preview, print with "Save as PDF". I was able to gain access to the filled PDF locally again.
    – xyb994
    Commented Jan 15 at 4:49
0

I tried the "Export..." option, then clicked on the "Permissions..." button. Entering in an owner password and then clicking "Save" allowed me to re-open the PDF without a password. (Full disclosure: I used my user account password as the owner password, in case that makes a difference.)

3
  • Update: once I re-open the document, it cannot be edited. The owner password is unusable. Commented Aug 8, 2022 at 6:33
  • Please use the edit link under your answer to add/make changes. Comments can be purged over time.
    – agarza
    Commented Aug 8, 2022 at 13:26
  • Where is this "Permissions" button? When I click Export, all I get is a "Save As" dialog.
    – ADTC
    Commented Jan 20 at 18:54
0

I am on Sonoma, and I can confirm that this still happens. I've had to switch to Adobe Acrobat. Unfortunately, this also means that I've had to refill out a lot of standard forms. Thanks, Apple.

I did talk to Apple support at length, and tried to get them to at least admit the problem. At first he was adamant that this is a security "feature", but when I pressed and said that there was a bug report, he went away to consult with someone else, and then came back and admitted that this is a known bug in macOS/Preview, and that "they are working on a resolution." Who knows when they will get to a fix.

0

Seems like this is still an issue with many PDF forms with an existing password in the latest Sonoma and beta.

For my heavy PDF form users I've installed LibreOffice which is now very good at editing PDFs with all the features of a wordprocessor / layout tools etc and made it the PDF default. They can still use Adobe Reader as an "open with" fallback.

The Mac version of LibreOffice is native and I've been using it as my primary office software for many years but not everyone is aware of how well it handles PDFs too. You may want to experiment with this option instead of paying Adobe.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .