Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Printing NSViews

Printing NSViews
Thread Tools
techtrucker
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Jul 31, 2006, 08:36 PM
 
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
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Jul 31, 2006, 09:57 PM
 
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.
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Jul 31, 2006, 10:49 PM
 
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];
     
techtrucker  (op)
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Aug 2, 2006, 06:28 PM
 
Thanks, I appreciate the respopnses.

Steve W
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:45 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,