Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Printing



At 12:14 AM -0400 4/29/03, Carla Lewis wrote:
The problem I'm running into is that all print tutorials seems to only defer to the built-in printDocument method. My users won't see what's going to be printed. It won't be on a displayed NSTextView or something. I just want to write dynamic rich text to the printer.

Printing is fairly easy in Cocoa. Aaron Hillegass gives a good overview in "Cocoa Programming for Mac OS X".

Essentially, you get an NSPrintInfo object, say by running the Page Setup (NSPageLayout) dialog or sheet, that describes the page setup information you should use. You use this information to set up an NSView that you'll print. For simple tasks, you don't even need to use a custom NSView subclass for pagination; you can simply create an NSView whose height is a multiple of the height of your page's imageable area (*not* the page's height itself - this bit me when I first wrote printing code). Then you create an NSPrintOperation object referencing your view and use that to run the Print (NSPrintPanel) dialog or sheet and actually generate the output.

Apple's documentation on the Cocoa printing architecture is fairly clear, and the Sketch sample is pretty good when it comes to showing how printing works. The only hangup I ran into was that I had to size the view I was printing for the page's imageable area, not the page's total area.

-- Chris

--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Application Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Printing (From: Carla Lewis <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.