How do you feel about an application saving changes to your files without you knowing? How about if that application is not just saving harmless changes, but in the process of doing so also rewrites the file and removes important information and corrupts the document?
I would say that this behavior is unacceptable.
We are talking about the Mac OS Preview application and PDF forms. It’s a known problem that Preview gives the user the impression that a PDF form can be filled out and saved, but when such a form is then opened in a PDF viewer that is conforming to the PDF specification, the form fields are blank… The data is there, just not visible to the user because Preview “forgot” to tell the viewer that it did actually save the data, but then did not update the “appearance stream”, and it also “forgot” to set the flag that would instruct the viewer application to recreate that appearance stream. The PDF specification actually has a solution for an application that cannot update the appearance stream (section 12.7.2 Interactive Form Dictionary, the NeedAppearances entry in the forms dictionary).
Here is a 5 minute video that shows the damage Preview can do to a PDF form:
The fields that need a new appearance stream are easy to fix – all we need to do is force a redraw: There is a solution in JavaScript, but it requires to identify the problem first, and then run the script to refresh the form fields. You can find the solution with some background information on Joel Geraci’s old Adobe blog.
The problem with missing functionality (missing JavaScript actions and signature fields) are impossible to fix. The information is gone and cannot be restored.
One way to avoid this problem is by changing the Mac OS Mountain Lion (unfortunately this is not available in Lion) setting that controls if changes should be written back to modified documents without prompting the user. You can do that by opening up the Mac OS preferences, then go to the “General” category and check the box next to “Ask to keep changes when closing documents”. In my opinion, this setting should be checked by default, but Apple decided that we need the same user experience as on iOS devices, where we don’t need to worry about saving documents.

There is a way to prevent these automatic saves on Mac OS X Lion (this one is not available in Mountain Lion) is to edit your TimeMachine configuration and make sure that the file gets locked after a certain time frame (unfortunately, the shortest possible time frame is one day). This way, the user has to manually unlock the file before any changes are saved to the file.

Acrobat saves updates to a document with incremental updates, this way the original PDF file is protected and can still be recovered (this requires editing a binary file, and should probably be the topic of a future blog post), Preview wipes out the history of the file and therefore does not provide a way back to the original file.
The automatic saving of documents is fine for documents that can only be edited with one application (e.g. a Pages or Numbers document), but for something as common as a PDF file, especially when data gets destroyed in the process is unacceptable.

















