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.
[ Update 07/21/2020: Adobe has “archived” Joel’s blog posts, which means the content is no longer available. Fortunately, Joel did post about this on his own web site: http://practicalpdf.com/the-practicalpdf-fix-form-utility/ ]
[ Update 03/11/2022: Looks like Joel’s site has changed and the previous link is no longer working. Use this instead: https://practicalpdf.com/pages/fix-fields-utility.html
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.
Pingback: Paddle Mini PDF Bundle - Cheap, but is it worth your money? - KHKonsulting LLC
Preview so badly mangles PDF’s when re-saving them, that the object count doubles, page /Contents are rewritten using new commands, and you get different strings if you run “pdftotext” on the original PDF and the new copy. Even the Metadata dictionary is erased. Any suggestion on how to tell that the two PDF’s are even related?
There is no way to tell that the two files are related. The original file is gone, even if you add something to the original file that would allow you to tell that you are dealing with a related file, once Preview has it’s way, that information is no longer available.
Just wondering – there are so many ‘PDF viewers’, enhancers, etc., out on the market today. I supposed that some are as destructive as Preview. Do you have a list, perhaps, of non-destructive viewers for Mac. We now that Preview is not an option – but what about something such as PDFPen and PDFPenPro from Smile?
Clinton
Clinton, if you are looking for a viewer, I would recommend Adobe’s free Reader (http://get.adobe.com/reader). I only use Adobe products (Adobe Acrobat and the free Adobe Reader for “real” work). Reader is definitely non-destructive. I have not looked at PDFPen or PDFPenPro in many years (I played around with it when it first came out). I will try to make some time to give these tools a test drive. You may have seen my post about the Paddle Mini Bundle which also uses the Preview technology to destroy PDF files. There area other “bad” tools out there, and it’s always important to know what the limitations of a certain tool are.
I’m a ‘believer’ in using Acrobat Pro and Adobe Reader – but I’m also a frequent contributor on the Apple Support boards and I always go round and round, it seems, to get people to use Reader for all PDFs. Sometimes, though, folks complain about how slow Reader is to scroll (and sometimes they complain about the same thing in Preview!) so I’m looking for a ‘middle ground’ here. I purchased both PDFPen and PDFPro through some bundles and they don’t seem to effect the PDF structure (as I’ve opened forms in both and then re-opened in Acrobat and all seems fine). If you could take a look at the demo versions of these two apps for Mac and let me know what you think, I would appreciate it!
This works for me:
Print>Save as PDF>Rename[or save it to new location]
Works great. Once done, though, the new fill fields are embedded and cannot be edited.
Should a change need to be made, simply go back to the document first edited, make your changes and repeat the above order of operations. Or just white out the change desired with the line tool (select white) or the Rectangular Selection box too (select/white borderless). Use the Text Tools, make your changes over the white out. It is a work around but it works and I’ve never had someone on the other end not be able to see it.
I have nearly 100 contracts that I use. I have them in a folder named “Master Contracts” and leave them there pristine forever. I duplicate the one I need. Fill in the fields.
Sad but true.
After hours of creating a fantastic PDF form I opened in Preview and it wiped all the Javascript from the document.
This violates any convention of computing since I started using computers in the late 70’s.
One does not expect that simply opening a document in an application will result in the original file being changed.
Apple? Seriously?
Even enabling that setting (System Preferences > General > Ask to keep changes when closing documents) doesn’t cause Preview to prompt me to save changes when closing PDF files. I am using Mac OS X Yosemite.
Forget that, it works now. :/
Glad that it worked out.
Why do the folks at Apple think that they’re more clever with PDF than Adobe? They’re not. They should scrap Preview altogether and make a deal with Adobe, or follow the freaking standard. I have written in BOLD, RED LETTERS “Open this with a version of Adobe Reader” “Download a free version of Adobe Reader HERE” “Please, whatever you do, don’t open this in Preview”…. it’s like every single Apple user out there has one trait in common–they read nothing.
Just had this problem, installed Adobe PDF Reader, but have to copy+paste all data again.
The problem isn’t limited to Apple. My website uses pdf forms to collect data and, if users try to open and save them using the browser’s (virtually all browsers) form viewer, either they will end up with a form that hasn’t been edited, or a pdf that has lost all of its form fields. Is there any software that can take such a form and copy the entries onto a copy of the original pdf form?
Arthur, the better way to deal with such a problem is to add functionality to your PDF file that informs the user that they are using a non-compatible PDF viewer and that they should download the file and then use the free Adobe Reader or Adobe Acrobat to fill out and submit the form.
I have been searching and searching trying to figure out what was screwing up a 34 page PDF form that I spent 50+ hours creating in Adobe Acrobat. Fortunately, I saved a backup. My assumption was that Preview (OSX Yosemite) was dumping javascript when it opened the document. I’m glad I found this page, I won’t have to check into a mental hospital or emergency room for banging my head against a wall. I am also completely befuddled as to why Adobe Acrobat doesn’t come with a date picker…wtf? It is 2016 for goodness sake! Not on free aftermarket plug-in seems to work well or consistently. How is it possible that people at Adobe haven’t integrated this commonly used tool into their software?
Richard, glad that I could help. As far as speculating about why Adobe has not added a date picker – your guess is as good as mine. I assume that one of the problems now is that the PDF format is no longer owned by Adobe, it’s now owned and maintained by ISO as an international standard. This means that if you would add functionality, it would have to go through the standards process. Adobe could however add just a tool on the user interface side of Acrobat/Reader that would at the end create a “normal” text field with date validation and formatting rules… You can always add your voice by submitting an enhancement request: http://www.adobe.com/products/wishform.html
If you want an OS X PDF reader capable of executing javascript then use Adobe Reader. If you want a secure PDF reader use Apple Preview. If you want a secure PDF with excellent note-taking capabilities use Skim.
Using Save As in Preview does not not render the PDF forms un-editable. You make them un-editable by using the Export as PDF command. You should do this before sending a form.
Bob, Apple’s Preview definitely destroys a form – it does not necessarily remove all interactivity from a form, but it certainly removes important parts of text fields and buttons, and completely removes other field types. And, it does save the file potentially without prompting the user.
And this is still happening with El Capitan? Ouch!!
Karl: I really liked your response “the better way to deal with such a problem is to add functionality to your PDF file that informs the user that they are using a non-compatible PDF viewer and that they should download the file and then use the free Adobe Reader or Adobe Acrobat to fill out and submit the form.”
However, I have no idea of how to accomplish that. Can you either provide a link that provides some direction, or let me know how much it would cost to have it done for me?
Arthur, that information is something I keep for my customers. I am pretty open to give away almost everything I know about PDF, but some things I reserve for paying customers. So unfortunately, this is not something I will share. I hope you understand.