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 - taking advantage of full page size?



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Printing - taking advantage of full page size? (From: Jim Correia <email@hidden>)
 >Re: Printing - taking advantage of full page size? (From: David Duncan <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.