[R-SIG-Mac] Re-creating PDF's

Marc Schwartz marc_schwartz at me.com
Mon Oct 22 20:55:11 CEST 2012


On Oct 22, 2012, at 12:36 PM, Fisher Dennis <fisher at plessthan.com> wrote:

> R 2.15.1
> Lion
> 
> Colleagues
> 
> In previous versions of OS X, I might do the following:
> 	1.  create a PDF in R
> 		pdf(FILENAME)
> 		plot(1)
> 		dev.off() 
> 	2.  open the file using the command 
> 		system("open …")
> 	3.  create the file again (same commands as above).	
> The opened file was replaced with the new version.
> (This differs from Windows in which the file needed to be closed in order to create a new version)
> 
> As of Lion, it appears that something changed.  In some instances, the behavior is identical, i.e., creating the new version of the file results in the open version being replaced with the second version.  However, in some circumstances, I observe the following behavior:
> 	1.  the original version of the file remains open
> 	2.  the new version appears as a second instance of Preview
> 	3.  the system appears to freeze for a few seconds
> 	4.  Preview is frozen and requires a ForceQuit
> 
> Sample code is:
> pdf("xx.pdf") ; plot(1); dev.off() ; system("open xx.pdf"); Sys.sleep(3) ; pdf("xx.pdf") ; plot(2); dev.off()
> 
> The code above results in the desired outcome and I can't provide a short reproducible example (the problem only happens with extremely large multipage documents).
> 
> Does anyone have any thoughts as to whether this is a problem in OS X (Preview) or R?  Any thoughts on how to prevent it from happening?  I suspect that this will be a un-solveable mystery but I thought that it was worth asking.
> 
> Dennis



This may be a consequence of the change in Lion, which introduced Auto Save and Versions (a local version control system) as part of the OS functionality. Note the little pull down menu (downward pointing triangle) to the right of the file name in the Preview title bar when you move the cursor over the file name.

These might be helpful for background:

  http://support.apple.com/kb/HT4753

  http://support.apple.com/kb/PH3729

but the distinctions between the various operations ("Save As", "Duplicate", "Export") can be confusing. "Save As" came back in Mountain Lion if you press the "Alt" key while viewing the File menu in the app.

Using your sample code above, the original file is replaced with the second version when I actually click on the Preview app window, so that it has focus. This is a behavior that has been consistent to me for some time, when using Sweave, for example, even with very large (100's of pages) PDF documents. I have never ended up with a second instance of Preview, when viewing the same PDF file.

You might want to check/change the "When opening files:" options in Preview's Preferences -> General tab to see if that affects the behavior you are observing.

Regards,

Marc Schwartz



More information about the R-SIG-Mac mailing list