|
|
Printing NSViews
|
|
|
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
I have an app that has contains an NSView with a table and some text fields. I would like to be able to print this view, but cleaned up. I can print the view as is, but of course I get the on-screen view with table row colors, etc. I more or less want to print a copy of that view but cleaned up. I think I have to do something with NSView's drawRect: method, which lets you handle how the view draws on screen vs print. But I'm feeling a little lost and could use any advice good or bad! Thanks in advance.
Steve W
|
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Last time I did something like this, I created a second view, with similar contents, but configured slightly differently (ie, configured for printing rather than screen).
Eg, the screen version of the view included a table view as usual. The print version of the view included a table view without any headers displayed, and with column and row lines hidden. Both table views would operate in exactly the same way otherwise (eg, use the same delegate/data source, or same bindings).
There may be a better way, but that's how I've done it.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Code:
if ([[NSGraphicsContext currentContext] isDrawingToScreen]) {
// stuff for screen
} else {
// stuff for printing
}
Though keep in mind (for isDrawingToScreen): "A return value of NO may mean that the drawing destination is a printer, but the destination may also be a PDF or EPS file. If this method returns NO, you can call attributes to see if additional information is available about the drawing destination."
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
|
|
|
|
|
|
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
Thanks, I appreciate the respopnses.
Steve W
|
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|