Printing a Composite of Several Views

Is there a way to print data from multiple views on one sheet in Applescript? Say, for example, that I want to print the image from an image view in the upper left corner of a page, wrap some text from a text view around it, and put a title up top that’s from the selected row of a table view. Is that possible in Applescript Studio?

Printing in ASS is not very well supported. You’ll end up using obj-c, at least minimally via code or connections in IB, to get printing to work.

Basically, to get something with multiple views to print using ASS only, you need to create a view (such as a nsbox or a window content view) that will contain all of the things you want to print. Lay out the child views as you’d like them, and then call the cocoa “print:” method of the parent view. This will essentially create a ‘screenshot’ of whatever is in the parent view and then print that. This method does not offer much flexibility in terms of print options, forcing you to set up the parent view’s dimensions to determine layout and positioning. It merely prints the view’s data centered in the middle of the page, so if your content is really small, it’s not printed top left as one might expect. It works solidly, but it does not offer the flexibility that creating a custom print job in obj-c does.

Here is a link to some discussions about this from some time back, which has some code and ideas that were suggested and also some links to related pages…
[url=http://bbs.applescript.net/viewtopic.php?id=12860]http://bbs.applescript.net/viewtopic.php?id=12860[/url]

Good luck,
j

Ah, thank you so much! That makes it easy to do things like setVerticallyCentered to false (dunno why it’s true by default). Now printing from the text view works perfectly. Woo hoo!

Compositing a multi-page document from multiple views will take further meditation on all the info you’ve given me, though. :slight_smile:

-Joe