Opening a pdf file from the command line

applescriptlatexpdfpreviewsoftware-recommendation

I have been using latexmk to make a pdf file in the following way:

latexmk -pdf filename.tex; open filename.pdf

This opens the pdf in Preview. However I want to open the pdf with a given zoom (problems with vision), and Preview reverts to a default zoom at every opportunity. This is annoying because I like to recompile my latex quite often.

I have tried using "open -a" with both skim.app and Adobe Acrobat Reader, because I have gained the impression from reading about these pdf viewers on the web that one can change the default viewing parameters. Unfortunately, a command line such as the one above, possibly using "open -a skim.app filename.pdf" produces the error message that either the file or the program "can’t be opened because it is from an unidentified developer". This happens whether of not I tell the system (via Command-I) to always open filename.pdf with the appropriate application (skim or Reader).

Since skim provides some kind of AppleScript access, which Preview doesn't, I wondered whether to try using AppleScript. But I need to get on with what I'm writing, rather than get into an infinite regress of things I need to learn first.

I use vim for editing, and briefly considered vim-latex, but rejected it as too complicated to 1) install and 2) learn how to use. I want no more than to open, from the command-line, a particular pdf in a pdf viewer where one can control the parameters for viewing.

Best Answer

You have a couple of problems here.

First, the message ""can’t be opened because it is from an unidentified developer" refers to the application.

Open Skim from the Finder and it will pop up a dialog telling you it is from an unidentified developer. Click on OK. Now open the "Security & Privacy" pane of System Preferences and under the General tab you will have the option to open the application anyway. Click "Open" and the app will open. You only have to do this once.

Second. Open a PDF in Skim and zoom it to the amount you require to be able to view it with your vision problems. Turn on or off the Contents and Notes panes as desired. Now select "Use Current View Settings as Default" under the PDF menu.

Now when you open a PDF in Skim it will be at the right zoom settings so open -a Skim.app example.pdf will work for you.