Re: Print-to-PDF
Re: Print-to-PDF
- Subject: Re: Print-to-PDF
- From: "Tim Verscheure" <email@hidden>
- Date: Mon, 12 Nov 2007 17:01:37 +0100
Thx for the answers, I will start testing these.
greetz
2007/11/9, Michael Ghilissen <email@hidden>:
> This version, adapted from my previous posting, does Safari to pdf:
>
> (*
> Safari2PDF - November 2007
>
> - From an open web page in Safari, Preview will generate a
> single PDF file with the correct page layouts.
> So, my script has two sections: the first one, in Safari, that
> gets the document and the file's name and then calls Preview; the
> second one, in Preview, that formats the pdf document and saves it.
> - You need to include delays long enough for the script to keep up
> with the pace (machine's speed and document's size) - or the script
> will crash, so experiment with changing the delays to a comfortable
> level - YMMV.
> - The script is obviously dependent on the versions of OS X,
> Safari and Preview.
> *)
> global theName
> tell application "Safari"
> activate
> set theName to name of front window
> end tell
> tell application "System Events"
> tell application process "Safari"
> keystroke "p" using command down --start print dialog
> delay 0.5
> click button "Preview" of UI element 4 of sheet "print" of window 1
> end tell
> end tell
> --
> delay 1
> --
> tell application "Preview" to activate
> tell application "System Events"
> tell application process "Preview"
> click menu item "Print…" of menu 1 of menu bar item "File" of menu
> bar 1
> delay 1.5 --change here to allow for long or complex documents
> click at position of UI element 1 of UI element 6 of UI element 4
> of sheet 1 of window 1
> delay 0.2
> -- key the down arrow and space bar to select the first item in the
> "PDF" menu ("Save as PDF…"), and wait for the Save dialog to appear.
> key code {125, 49}
> delay 1
> -- if new file name is needed, enter the pdf name into the Save
> dialog's text field
> set value of text field 1 of window 1 to (theName & ".pdf")
> delay 0.5
> -- use Control-d to set the desktop as the destination
> keystroke "d" using command down
> delay 0.5
> click button "Save" of window "Save"
> delay 0.2
> end tell
> end tell
>
> --
>
> Watch those line wraps.
>
> HTH
>
> Michael Ghilissen
>
>
> On Nov 9, 2007, at 11:37 AM, Tim Verscheure wrote:
>
> > I would like to use this function in combination with Safari. So I can
> > press a button (or select from a menu) which automatically calls the
> > print-to-pdf instruction and asks for a filename.
> >
> > Can this also be used with those free virtual printers I've read
> > about? Or applescript on it's own?
> >
> > Thanks for the quick answers!!
> >
> > 2007/11/7, Michael Ghilissen <email@hidden>:
> >>
> >>
> >> On Nov 6, 2007, at 10:59 AM, Tim Verscheure wrote:
> >>
> >>> Dear list,
> >>>
> >>> Is it possible to use the print-to-pdf function from OS X in
> >>> applescripting. I've searched in the libraries of applescript but
> >>> couldn't find anything.
> >>>
> >>> Maybe there's a work-around?
> >>>
> >>>
> >>> greetz
> >>>
> _______________________________________________
> 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
>
_______________________________________________
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