[texworks] SCRIPTING: get current poppler page number

Bruno Voisin bvoisin at me.com
Wed Oct 20 19:29:43 CEST 2010

Le 20 oct. 2010 à 14:47, Paul A Norman a écrit :

> http://code.google.com/p/texworks/issues/detail?id=261&can=5#c35
> Here is a simplistic scripting implementation of a suggestion by Bruno
> to look at using pdfopen. Could use pdfclose if that is needed as
> well.

Credit to whom credit is due: this was Reinhard's suggestion, not mine (I was not even aware of the existence of pdfopen and pdfclose in TeX Live beforehand).

That said, on Mac OS X pdfopen does not work. Typing "pdfopen somefile.pdf" in Terminal launches X11 then yields

	pdfopen: acroread startup failed

This message is because there is no acroread executable in the path. The executable part of Acrobat lives with the Acrobat .app application bundle and depends where this bundle is placed. For Acrobat Pro 9, the default location is

	/Applications/Adobe Acrobat 9 Pro/Adobe Acrobat Pro.app/Contents/MacOS/AdobeAcrobat

Now, to make this work as a binary launched from Terminal you need to turn it into a script, for example


	open -a '/Applications/Adobe Acrobat 9 Pro/Adobe Acrobat Pro.app/Contents/MacOS/AdobeAcrobat' "$1"

Calling this script acroread, making it executable ("chmod a+x acroread") and putting it in the path (for example "sudo cp acroread /usr/local/bin/") works, in the sense that you can just type in "acroread somefile.pdf" in Terminal and the file is opened in Acrobat.

However, that still doesn't appease pdfopen which returns

	$ pdfopen somefile.pdf
	$ open: invalid option -- o
	Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]
	Help: Open opens files from a shell.
	      By default, opens each file using the default application for that file.  
	      If the file is in the form of a URL, the file will be opened as a URL.

So it seems that pdfopen assumes an acroread that (1) opens up in X11 and (2) accepts the options (inclusing -o) that acroread has on Linux.


More information about the texworks mailing list