I guess that it would be easy to edit it to fit your needs.
--{code}
--[SCRIPT print sparse pages]
(*
Enregistrer le script en tant que Script : print sparse pages.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Bibliothèque:Scripts:Applications:Pages:
Il vous faudra peut-être créer le dossier Pages et peut-être même le dossier Applications.
Sélectionner le document Pages à imprimer
Aller au menu Scripts , choisir Pages puis choisir “print sparse pages”
Tapez la liste des pages à imprimer dand le dialogue ad'hoc.
2,5:8 imprimera la page 2 puis les pages 5 à 8.
--=====
L’aide du Finder explique:
L’Utilitaire AppleScript permet d’activer le Menu des scripts :
Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case “Afficher le menu des scripts dans la barre de menus”.
Sous 10.6.x,
aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
--=====
Save the script as a Script: print sparse pages.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Pages:
Maybe you would have to create the folder Pages and even the folder Applications by yourself.
Select the Pages document to print
Go to the Scripts Menu, choose Pages, then choose “print sparse pages”
A dialog will ask you to type the list of pages to print
2,5:8 would print page 2 then pages 5 thru 8
--=====
The Finder’s Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the “Show Script Menu in menu bar” checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2012/04/09
2012/04/10 added support of ranges
2012/04/11 enhanced the handler « imprimePage »
*)
--=====
property rangeDelimiter : ":"
(*
I don't know which one is used under Windows so I use the one used in Numbers ranges (B3:C12)
*)
--=====
on run
my activateGUIscripting()
try
if my parleAnglais() then
display dialog "Type a list of pages numbers to print separated by comma." default answer "2,5" & rangeDelimiter & "8"
else
display dialog "Saisir la liste des numéros de pages à imprimer (séparés par des virgules)." default answer "2,5" & rangeDelimiter & "8"
end if
on error
return
end try
text returned of result
my supprime(result, space)
set listePages to my decoupe(result, ",")
tell application "Pages"
set dName to name of document 1
end tell
my selectMenu("Pages", 9, dName) (* Bring the upper Pages document to front *)
repeat with num in listePages
set num to num as text
if num contains rangeDelimiter then
my decoupe(num, rangeDelimiter)
set {num1, num2} to items 1 thru 2 of result
my imprimePage("Pages", dName, num1, num2)
else
my imprimePage("Pages", dName, num, num)
end if
delay 2
end repeat
end run
--=====
on decoupe(t, d)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
--=====
(*
removes every occurences of d in text t
*)
on supprime(t, d)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end supprime
--=====
on parleAnglais()
local z
try
tell application "Pages" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
on activateGUIscripting()
(* to be sure than GUI scripting will be active *)
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true
end tell
end activateGUIscripting
--=====
(*
my selectMenu("Pages",5, 12)
==== Uses GUIscripting ====
*)
on selectMenu(theApp, mt, mi)
activate application theApp
tell application "System Events" to tell application process theApp to tell menu bar 1 to ¬
tell menu bar item mt to tell menu 1 to click menu item mi
end selectMenu
--=====
on imprimePage(theApp, wName, firstPage, lastPage)
activate application theApp
tell application "System Events" to tell application process theApp
keystroke "p" using {command down}
tell window wName
repeat until exists sheet 1
delay 0.1
end repeat
if (count every radio group of sheet 1) = 0 then
click button -1 of sheet 1 -- switch to expanded dialog
repeat until (count every radio group of sheet 1) > 0
-- wait that the sheet expands
end repeat
end if
tell sheet 1
click radio button 2 of last radio group
set value of text field 1 to firstPage
set value of text field 2 to lastPage
end tell -- sheet
end tell -- window
error number -128
--keystroke return
end tell -- System Events…
end imprimePage
--=====
--[/SCRIPT]
--{code}