Skip to content

Re-creating PDF's

3 messages · Dennis Fisher, Marc Schwartz, Berend Hasselman

#
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


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
#
On Oct 22, 2012, at 12:36 PM, Fisher Dennis <fisher at plessthan.com> wrote:

            
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
#
On 22-10-2012, at 19:36, Fisher Dennis <fisher at plessthan.com> wrote:

            
I've tried this on Mountain Lion but do not get two instances of preview.
One instance only. To check which version of the pdf Preview is displaying I changed the second plot command to plot(2,col="red"). Preview does not immediately show the second version (it doesn't reload the file) but when you switch focus to another app and return to Preview you see the changed pdf.
The initial pdf was not a version of the second (red dot) pdf.

I've tried this several times with the same results. One instance and no versions.

Berend