Hi, I'm trying to print a really large image into 'N' pages. So I over-rode 'knowsPageRange' and 'rectForPage'. Since I was able to successfully draw on a single page, my rectForPage function returns the entire 'print view frame' itself, and I draw a sub-image in this frame. My understanding is that rectForPage simply returns an NSRect in the print view to which all drawing operations are clipped. So I don't want to clip anything, but I do it myself by creating a sub-image (using CGImageCreateWithImageInRect) and drawing it like any other image on the entire view. But this doesn't seem to work, I'm getting just a single line on my 2nd page, and from my 3rd page onwards I don't get any output. My first page appears fine. What could be wrong? Here is the basic skeleton of the code I'm using:
// BEGIN CODE void OnPrint() { PrintView *printView = [[PrintView alloc] initWithFrame:printViewFrame]; NSPrintOperation *printOp = [NSPrintOperation printOperationWithView:printView]; [printOp runOperation]; } Class print view functions over-ridden: - (BOOL) knowsPageRange: (NSRangePointer) aRange { aRange->location = 1; aRange->length = totalPages; return YES; } - (NSRect) rectForPage: (int) page { mCurrentPage = page; return [self frame]; } - (void) drawRect: (NSRect) rect { // assume a CGImageRef 'sourceImage', its width and height as 'imageWidth' and 'imageHeight' CGRect imageRect = {{0, imageHeight*((float)(numPages-1)/totalPages)}, {imageWidth, imageHeight / totalPages} }; CGImageRef subImage = CGImageCreateWithImageInRect(sourceImage, imageRect); NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; CGContextRef context = (CGContext*)[currentContext graphicsPort]; CGContextDrawImage(context, imageRect, subImage); } // END CODE Thanks, Renzil _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com