[OS X TeX] Placing eps figures

Claus Gerhardt gerhardt at math.uni-heidelberg.de
Mon Jun 5 15:38:22 EDT 2006


George,

Use the modified script as a macro, which has the subroutine included.

Beware that you need in addition the shell script pdfselectc  
(downloadable from my tex page) which should be in
/Users/gratzer/Library/TeXShop/bin/pdfselectc

If you can't get it, I shall send it to you as an executable file  
separately.

The Applescript will probably not run in TS 2.10beta because of some  
bug in the beta version.

Claus


--AppleScript
-- Apply only to an already saved file
-- Claus Gerhardt, June 2006
(*The script extracts a pdf page, then  transforms it  to a ps file  
which will be opened in Illustrator.

Important: If  the name Preview in the last command is still present,  
then it has to be replaced by the name of your Illustrator application.

Run the script when either the tex file or the pdf file is front most  
in TeXShop.
*)


-- In the first dialog enter the papersize (a4, letter or any other  
standard size)
-- In the following dialog enter your selection of pages like
-- 3:4,6,8:12 This would be the selection for one output file
-- It would contain the pages 3-4, 6, and 8-12

tell application "TeXShop"
	get path of document of window 1
	set Filename to result
end tell

set {baseName, texName, pdfname, namePath, dirName, dirNameunquoted,  
logName, logPath, rtfName} to setnamets(Filename)



activate
set dialogPaper to "Which paper size do you want: a4, a5, a3, letter"
activate
set input to the text returned of (display dialog dialogPaper default  
answer "a4" buttons {"Cancel", "Next"} default button "Next")

set dialogSelection to "Your selection for  file # 1. The file will  
be saved as " & baseName & "-1.pdf."
set i to 1 as number
activate
set input to input & " " & the text returned of (display dialog  
dialogSelection default answer "" buttons {"Cancel", "Next"} default  
button "Next")


set input to input & " " & baseName

set shellScript to "cd " & dirName & ";"
set shellScript to shellScript & "~/Library/TeXShop/bin/pdfselectc  "  
& input
do shell script shellScript

set pdfname to baseName & "-1.pdf"
set shellScript to "cd " & dirName & ";"
set shellScript to shellScript & "/usr/local/bin/gs -sDEVICE=pswrite - 
dNOCACHE -sOutputFile=" & baseName & "-1.ps" & " -q -dbatch - 
dNOPAUSE  " & pdfname & " -c quit"
do shell script shellScript
set PSName to baseName & "-1.ps"
set PSName to dirNameunquoted & "/" & PSName
set theFile to alias (POSIX file PSName)


tell application "Adobe Illustrator CS"
	activate
	open theFile
end tell
on setnamets(x)
	set n to (number of characters of contents of x)
	set fileNamequoted to quoted form of x
	set windowName to do shell script "basename " & fileNamequoted
	set m to (number of characters of contents of windowName)
	set dirName to quoted form of (characters 1 thru (n - m - 1) of x as  
string)
	set dirNameunquoted to (characters 1 thru (n - m - 1) of x as string)
	set theText to contents of windowName as string
	
	set n to (number of characters of contents of theText)
	set i to n as number
	
	repeat while i > 0
		if character i of theText is equal to "." then
			set m to i
			exit repeat
		else
			set i to (i - 1)
		end if
	end repeat
	
	set baseName to (characters 1 thru (m - 1) of theText as string)
	set texName to baseName & ".tex"
	set namePath to dirNameunquoted & "/" & baseName as string
	set pdfname to namePath & ".pdf" as string
	set rtfName to namePath & ".rtf" as string
	set logPath to namePath & ".log" as string
	set logName to baseName & ".log" as string
	
	try
		tell application "TeXShop"
			save document texName
		end tell
	end try
	return {baseName, texName, pdfname, namePath, dirName,  
dirNameunquoted, logName, logPath, rtfName} as list
end setnamets
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the MacOSX-TeX mailing list