Re: Print-to-PDF
Re: Print-to-PDF
- Subject: Re: Print-to-PDF
- From: "Tim Verscheure" <email@hidden>
- Date: Fri, 9 Nov 2007 17:37:39 +0100
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>:
> Not knowing the specifics of your needs and your environment, I
> submit an example of a script I use to create PDF from a Word
> document, using System Events.
>
> This will get your starting, hopefully.
>
> Michael Ghilissen
>
> --
>
> (*
> Word2PDF - June 2007
>
> - If you use the built-in print-to-PDF feature of Mac OS X for an MS
> Word document with multiple sections, you will get multiple PDFs, one
> per section. Preview will generate a single PDF file with the correct
> page layouts. And that does the trick as Preview's GUI can be
> scripted! So my script has two sections: the first one, in Word, 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,
> Microsoft Word and Preview.
> *)
>
> tell application "Microsoft Word" to activate
> tell application "System Events"
> tell application process "Microsoft Word"
> click menu item "Print..." of menu "File" of menu bar item "File"
> of menu bar 1
> delay 0.5
> click button 4 of UI element 5 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 0.5
> 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 "test2.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
>
>
> 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 (applescript-
> > email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> > 40hotmail.com
> > 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
>
_______________________________________________
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