how to print a form from ASStudio

I found a dead link in the AppleScript-Studio list that was posted by jobu on how to print a form from ASStudio. I have a need to print a image overlaying an image.

Here’s a summary of what that broken link page said, if I’m thinking of the right topic…
To easily get a bunch of objects to print on one page, first set up a box (nsbox) in your window. Then, add all of the items you wish to print to that box, adjusting their settings and layers as you would if you had placed them in the window itself. Then, when you want to print the objects, simply tell the box to print, either with a cocoa connection, or by using a call method command with the box as the target of the command.

To use a cocoa connection, control-drag from the menu item or button which will serve as the print control to the box. In the “Connections” pane that should pop up, select “print:” from the possibe connections, and then click the “Connect” button. Now when you click that control, the standard print dialog should open and you can print from there.

To do this programmatically in your AS code, you can use a ‘call method’ command to do this same thing, but without the need for any cocoa connections. For example, if you have a button (named “printButton”) you’d use something like the following to print the contents of the target box (named “printableBox”)…

on clicked theObject
if name of theObject is "printButton" then
tell box "printableBox" of window "theWindow" to call method "print:" of it
end if
end clicked

Note that I typed this all from my head so there may be some typos, and “print:” may actually need to be “print”. This method, while about the only good way to use only applescript to do multi-object printing, has some shortcomings. Without getting into more complicated printing settings using obj-c, you’re limited to some pretty basic default print options. The best way to implement this, is to make the box exactly one page size. That way the printout is properly aligned on the page. You’ll have to do some fooling with it to get your output set up right, but it does work pretty well.

Please post the url of the ‘broken link’ that you found related to this topic. I can’t seem to find that post, but I think it’s a valuable thread that should be found and complete, if possible. Good luck, and let me know if you have any problems… as I know this is a very simple explanation of a tricky process.


Here are a few threads I was involved in over in the Applescript/Xcode forum which covered printing in some capacity…

Here’s the dead link

I seem to be missing the part about making the box visible to print.