Re: Printing - taking advantage of full page size?
Re: Printing - taking advantage of full page size?
- Subject: Re: Printing - taking advantage of full page size?
- From: Jim Correia <email@hidden>
- Date: Tue, 29 Jan 2008 17:12:45 -0500
On Jan 29, 2008, at 1:34 PM, David Duncan wrote:
The pagination methods are still the best way to do this. You would
simply state that your content has exactly 1 page that fills the
size of the paper. Then when your -drawRect is invoked, it will be
invoked to draw within the bounds of the page size you specified
previously.
I guess I'm confused as to what your advice specifically is here. The
rect passed to -drawRect: is the clipping rect. I use that to restrict
myself to only drawing what is necessary. The contents of the view are
already laid out (and possibly cached) relative to the view's bounds,
which remains unchanged.
In my sample view I've added:
- (BOOL)knowsPageRange:(NSRangePointer)range
{
range->location = 1;
range->length = 1;
return YES;
}
- (NSRect)rectForPage:(NSInteger)page
{
NSPrintOperation *printOperation = [NSPrintOperation currentOperation];
NSPrintInfo *printInfo = [printOperation printInfo];
NSRect pageRect;
pageRect.origin = NSZeroPoint;
pageRect.size = [printInfo paperSize];
NSLog(@"-rectForPage: %@", NSStringFromRect(pageRect));
return pageRect;
}
At the top of -drawRect: I log
NSLog(@"-drawRect: %@, onScreen = %d, bounds = %@",
NSStringFromRect(rect), [[NSGraphicsContext currentContext]
isDrawingToScreen], NSStringFromRect([self bounds]));
When message as part of the print sequence, I see:
-rectForPage: {{0, 0}, {612, 792}}
-drawRect: {{0, 0}, {448, 205}}, onScreen = 0, bounds = {{0, 0}, {448,
205}}
Thanks,
Jim
_______________________________________________
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