[texworks] SCRIPTING: get current poppler page number

Bruno Voisin bvoisin at me.com
Thu Oct 21 11:29:26 CEST 2010

Le 21 oct. 2010 à 10:37, Paul A Norman a écrit :

> On Mac OS, you may use Apple events and AppleScript. Adobe Reader
> supports only the following required Apple events:
> ●open
> ●print
> ●quit
> ●run
> Now unless ther is a way we can pass the options like page=NN to the
> open "Apple event", this may be a dead end, does Ramón's  script below
> look like this can be done please? (We probably don't want all the
> screen placement stuff )
> [...]

The following works (with Acrobat Pro) for opening the first page:



	name=$(basename "$1" .pdf)

	/usr/bin/osascript  <<END
	activate application "Adobe Acrobat Pro"
	tell application "Adobe Acrobat Pro"
	       open POSIX file "$basefname.pdf"
	end tell

It certainly can be made better, for example the PATH setting at the beginning is probably superfluous (if you have TeX the path has already been set at install time) and the check for the file extension .pdf is also probably superfluous.

I've tried to insert in the open command the code telling to open a specific page, for example page 2, as follows

       open /A "page=2=OpenActions" POSIX file "$basefname.pdf"

That doesn't work:

	$ ./pdfopen somefile.pdf
	93:94: syntax error: Expected end of line but found “"”. (-2741)

That's where my competence in scripts ends.

Bruno Voisin

More information about the texworks mailing list