Re: Custom pagination clipping
Re: Custom pagination clipping
- Subject: Re: Custom pagination clipping
- From: Greg Hoover <email@hidden>
- Date: Thu, 13 Sep 2007 16:37:31 -0700
Thanks Matt. I kind of figured that, but I went another route to
temporarily solve the problem -- I'm using adjustPageHeight and
allowing the default NSView implementation take care of the rest.
Greg
On Sep 13, 2007, at 12:39 PM, Matt Neuburg wrote:
On Wed, 12 Sep 2007 14:14:38 -0700, Greg Hoover <ghoover@greg-
web.net> said:
I have an NSTextView that I'm trying to paginate so that lines aren't
cut when printing across several pages. In knowsPageRange I figure
out where the page boundaries should be in the view's coordinate
system. Then I've overridden rectForPage as follows:
- (NSRect)rectForPage:(int)pageNumber {
NSRect rect = [self bounds];
if ([pageBoundaries count]) {
rect.origin.y = 0;
if (pageNumber > 1)
rect.origin.y = [[pageBoundaries objectAtIndex: pageNumber - 2]
floatValue];
rect.size.height = [[pageBoundaries objectAtIndex: pageNumber - 1]
floatValue] - rect.origin.y;
}
return rect;
}
The problem is that the view is wider than the printed page and it
gets clipped. I'd hoped that the rect I return from rectFromPage
would be scaled to fit the printed area, but apparently not. The
default printing from NSVIew handles this scaling great. Can someone
fill in what I'm missing?
I'm a little hesitant to jump in here, but I *think* the problem
lies in
your sentence "The problem is that the view is wider than the
printed page."
This may betray a misconception about how to print. It is your job
to see to
it that the view is NOT wider than the printed page. Typically, you
do this
by making a view, in real time, specifically for the act of
printing, using
the information about the user's print settings to help you get the
size
right. In other words, my advice would be, don't ask the views in
your user
interface to print themselves; set up a whole new view structure for
printing purposes, populate it, tell it to print itself, and let it
tear
down again when printing is over. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden