Re: automatic saving pdf files in pages
Re: automatic saving pdf files in pages
- Subject: Re: automatic saving pdf files in pages
- From: KOENIG Yvan <email@hidden>
- Date: Tue, 21 Sep 2010 12:23:37 +0200
Le 21 sept. 2010 à 11:29, Jarda Kotesovec a écrit :
>
> Hi all!
>
> I was wondering if would be possible solve the following issue in
> Pages with apple script.
>
> I need to force Pages to save document in PDF format at the moment
> when you save it as a native Pages document. Normally user have to
> save it (as a native pages document) and then pick up "File -> Export
> ... -> PDF -> Next.. -> Export" to have pdf copy as well. I need to
> save these clicks (exporting to pdf) in term of faster workflow.
>
> Any feedback is really appreciated.
>
> Regards
> Jarda
And now the one without GUI scripting.
Of course, if someone may give enhancements, I'm interested.
--(SCRIPT save2Pages&PDF.app]
(*
Enregistrer le script en tant que Script : save2Pages&PDF.scpt
déplacer le fichier créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Pages:
Il vous faudra peut-être créer le dossier Pages et peut-être même le dossier Applications.
menu Scripts > Pages > save2Pages&PDF
Le script enregistre le document au format natif de Pages
et l'enregistre dans un fichier PDF.
S'il existe déjà un PDF homonyme, il est renommé en lui ajoutant une chaîne
construite sur sa date de modification comme le fait mon script équivalent dédié aux tableurs.
--=====
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".
+++++++++
Save the script
as a Script: save2Pages&PDF.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.
Go to
menu Scripts > save2Pages&PDF
The script saves the document in the native Pages format
and it saves it in a .pdf file
If a .pdf already exists, it is renamed with a stamp matching its modification date.
I choose this soluce to match the one used in the script doing this task for spreadsheets.
--=====
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
--=====
Yvan KOENIG (VALLAURIS, France)
modifié 2008/11/22
modifié 2009/07/25
*)
property withPDF : true
(* true = save a .PDF version
false = doesn't save a .PDF version *)
property closeIt : true
(* true = closes the saved document
false = doesn't close it *)
property theApp : "Pages"
property theExt : "pages"
--=============
on run
tell application theApp
activate
save front document (*
CAUTION, save front document as "SLDocumentTypeNativePublication"
no longer works under 10.5
*)
delay 0.2
set thePath to path of document 1
end tell -- theapp
set {xPath, xExt} to my saveAs(thePath)
if closeIt then tell application theApp to close document 1 saving no
end run
--=============
on saveAs(p)
local xExt, xType, nom_de_p, dossier_de_p, n_xport, p_xport
set {xExt, xType} to {"pdf", "SLDocumentTypePDF"}
set {nom_de_p, dossier_de_p} to my quelNomEtDossier(p)
set n_xport to (text 1 thru -(1 + (length of theExt)) of nom_de_p) & xExt (*
• replace the original extension by the xExt one *)
set p_xport to dossier_de_p & n_xport
(*
• CAUTION, When saving, Pages doesn't take care of an existing document.
It replaces it by the new one. Playing safety, it renames the existing file. *)
tell application "System Events" to if exists (file p_xport) then set name of file p_xport to (text 1 thru -(2 + (length of xExt)) of n_xport) & my horoDateur(modification date of file p_xport) & "." & xExt (*
• Insert modDate stamp *)
tell application "Pages" to save document nom_de_p as xType in p_xport (*
• save as xType document *)
return {p_xport, xExt}
end saveAs
-- =============
on quelNomEtDossier(f)
local nom, dossier
tell application "System Events" to tell file (f as Unicode text)
set nom to name (* Unicode text *)
set dossier to path of container (* Unicode HFS path *)
end tell -- to System Events
return {nom, dossier}
end quelNomEtDossier
(* =============
• Build a stamp from the modification date_time
*)
on horoDateur(date_de_modification)
local les_secondes
set les_secondes to time of date_de_modification
return "_" & year of date_de_modification & text -2 thru -1 of ("0" & (month of date_de_modification as integer)) & text -2 thru -1 of ("0" & day of date_de_modification) & "_" & text -2 thru -1 of ("0" & les_secondes div 3600) & text -2 thru -1 of ("0" & (les_secondes mod 3600) div 60) & text -2 thru -1 of ("0" & les_secondes mod 60)
(*
• Here, the stamp is "_YYYYMMDD-hhmmss" *)
end horoDateur
--=============
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) mardi 21 septembre 2010 12:23:04
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden