|
Precedente
Successivo
|
| Autore |
Messaggio |
borgo1971
Registrato: 14/04/09 08:53
Messaggi: 18
Residenza: Tolmezzo (UD)

|
R13
Inviato: Ven 26 Giu 2009, 08:54 Oggetto: Stampare un PDF con AppleScript
|
|
|
Avrei bisogno di stmpare un PDF con AppleScript lasciando
all'utilizzatore la possibilità di selezionare la stampante e magari
anche la stampa di scala
Il problema è che Anteprima non ha un dizionario (per cui immagino che
non sia scriptabile), ed usando il comando print del dizionario del
Finder, non sembra possibile selezionare la stampante o aprire il
documento con Anteprima e fermarsi al dialogo di stampa senza far
partire la stampa, concludendo lo script apena chiuso il documento.
Qualcuno sa se si può fare qualcosa del genere? |
|
| Top |
|
 |
stefano

Registrato: 09/01/08 12:14
Messaggi: 1685
Residenza: Rimini

|
R13
Inviato: Ven 26 Giu 2009, 11:30 Oggetto:
|
|
|
potresti usare il dizionario di image events
questo script l'ho usato per fare il contrario, da PDF a immagine, prova a vedere se può fare al caso tuo con le opportune modifiche
| Codice: | property Formati : {"BMP", "JPEG", "JPEG2", "PICT", "PNG", "PSD", "QuickTime Image", "TIFF"}
global Bottoni, Messaggi, Titoli, NomeMio, Italiano, Inglese, Risultato
on run
-- per il debug da scripteditor
set ElementiSelezionati to selection of application "Finder"
open (ElementiSelezionati)
end run
on open (ElementiTrascinati)
set NomeMio to quoted form of (name of (info for (path to me)))
set Italiano to {{" Esci ", "Annulla", "Questo"}, {"Questo computer non può eseguire questo script" & return & return & "Lo script usa la technologia di gestione PDF, che richiede l'aggiornamento a Mac OS X 10.4 Tiger o successivo.", ¬
"Trascina documenti PDF sull'icona di " & NomeMio & " per ottenere la conversione al formato JPG.", "Elaboro solamente ", " PDF su ", " documenti trascinati...", "Scegli il formato del documento di destinazione...", "Si è verificato un errore con "}, {"Errore procedimento", "Alcuni PDF non sono validi", "PDF Convertiti"}}
set Inglese to {{" Quit ", "Cancel", "This"}, {"This computer cannot run this script" & return & return & "The script uses the PDF's management, which requires an upgrade to Mac OS X 10.4 Tiger or newer.", ¬
"Drag PDF documents to " & NomeMio & " icon to obtain the conversion to JPG format.", "Working only on ", " PDF document instead of ", " dragged documents...", "Choose destination document format...", "There is an error with "}, {"Procedure error", "Some PDF's isn't made with the correct format", "PDF Converted"}}
my Linguaggio()
if my VerificaVersioneSistema() then
set Risultato to (choose from list Formati with prompt item 6 of Messaggi cancel button name item 2 of Bottoni OK button name item 3 of Bottoni without empty selection allowed and multiple selections allowed) as string
if Risultato = false then return "annullato dall'utente"
set Conteggio to count items of ElementiTrascinati
set NuoviElementiTrascinati to my Vaglia(ElementiTrascinati)
set NuovoConteggio to count items of NuoviElementiTrascinati
if Conteggio = 0 then
display dialog item 2 of Messaggi with title item 1 of Titoli buttons item 2 of Bottoni default button 1 with icon stop
else
if NuovoConteggio <Conteggio> 0 then display dialog item 7 of Messaggi & quoted form of Documento & return & Messaggio buttons item 2 of Bottoni with icon 2 giving up after 5
end repeat
tell application "Finder" to reveal alias Destinazione
end if
end if
end open
on Converti(Dove, Questo)
try
tell application "Finder"
set Nome to name of Questo
set Estensione to length of ("." & name extension of Questo)
set Sorgente to (POSIX path of alias (Questo as string))
end tell
set Nome to (characters 1 thru ((length of Nome) - Estensione) of Nome) as string
tell application "Image Events"
launch
set Sorgente to open Sorgente
-- {"BMP", "JPEG", "JPEG2", "PICT", "PNG", "PSD", "QuickTime Image", "TIFF"}
if Risultato = item 1 of Formati then
save Sorgente as BMP in ((POSIX path of alias Dove) & "/" & Nome & ".bmp")
else if Risultato = item 2 of Formati then
save Sorgente as JPEG in ((POSIX path of alias Dove) & "/" & Nome & ".jpg")
else if Risultato = item 3 of Formati then
save Sorgente as JPEG2 in ((POSIX path of alias Dove) & "/" & Nome & ".jpg2")
else if Risultato = item 4 of Formati then
save Sorgente as PICT in ((POSIX path of alias Dove) & "/" & Nome & ".pct")
else if Risultato = item 5 of Formati then
save Sorgente as PNG in ((POSIX path of alias Dove) & "/" & Nome & ".png")
else if Risultato = item 6 of Formati then
save Sorgente as PSD in ((POSIX path of alias Dove) & "/" & Nome & ".psd")
else if Risultato = item 7 of Formati then
save Sorgente as QuickTime Image in ((POSIX path of alias Dove) & "/" & Nome & ".qti")
else if Risultato = item 8 of Formati then
save Sorgente as TIFF in ((POSIX path of alias Dove) & "/" & Nome & ".tif")
end if
end tell
return {Nome, 0, ""}
return true
on error Messaggio number Errore
return {Nome, Errore, Messaggio}
end try
end Converti
on Vaglia(ElementiTrascinati)
tell application "Finder"
set NuovaLista to {}
repeat with Questo in ElementiTrascinati
set Tipologia to (kind of Questo) as string
if Tipologia contains "PDF" then
set end of NuovaLista to Questo
end if
end repeat
end tell
return NuovaLista
end Vaglia
on SostituisciCaratteri(QuestoTesto, StringaRicerca, StringaSostituzione)
set AppleScript's text item delimiters to StringaRicerca
set ListaElemento to every text item of QuestoTesto
set AppleScript's text item delimiters to StringaSostituzione
set QuestoTesto to ListaElemento as string
set AppleScript's text item delimiters to ""
return QuestoTesto
end SostituisciCaratteri
on VerificaVersioneSistema()
copy my InformazioniVersioneGestalt("sysv", 4) to {VersioneSistema, StringaSistema}
if VersioneSistema is greater than or equal to 1041 then -- Mac OS X 10.4.1
return true
else
activate
beep
display dialog item 1 of Messaggi with icon caution buttons item 1 of Bottoni with title item 1 of Titoli default button 1
return false
end if
end VerificaVersioneSistema
on InformazioniVersioneGestalt(CodiceGestalt, LunghezzaStringa)
try
tell application "Finder" to ¬
copy my DaNumAEsa((system attribute CodiceGestalt), ¬
LunghezzaStringa) to {a, b, c, d}
set the VersioneNumerica to {a, b, c, d} as string
if a is "0" then set a to ""
set the VersioneStringa to (a & b & "." & c & "." & d) as string
return {VersioneNumerica, VersioneStringa}
on error
return {"", "sconosciuta"}
end try
end InformazioniVersioneGestalt
on DaNumAEsa(DatiEsa, LunghezzaStringa)
set StringaEsa to {}
repeat with i from LunghezzaStringa to 1 by -1
set StringaEsa to ((DatiEsa mod 16) as string) & StringaEsa
set DatiEsa to DatiEsa div 16
end repeat
return (StringaEsa as string)
end DaNumAEsa
on Linguaggio()
set LinguaSistema to do shell script "defaults read -g AppleLocale"
if LinguaSistema = "" then set LinguaSistema to "en"
set LinguaSistema to (characters 1 thru 2 of LinguaSistema) as string
if LinguaSistema = "it" then
copy Italiano to {Bottoni, Messaggi, Titoli}
else
copy Inglese to {Bottoni, Messaggi, Titoli}
end if
end Linguaggio |
_________________ coloro i quali affermano che internet è un covo di illegalità, significa che usano internet solo per sfruttare l'illegalità, alias: si sa solo di ciò che si conosce |
|
| Top |
|
 |
|
 |
Non puoi inserire nuovi argomenti Non puoi rispondere a nessun argomento Non puoi modificare i tuoi messaggi Non puoi cancellare i tuoi messaggi Non puoi votare nei sondaggi
|
|
Cerca il Forum con Google
|
|
|
|
|
|