Printing an NSImage fit to page
Printing an NSImage fit to page
- Subject: Printing an NSImage fit to page
- From: Jan Van Tol <email@hidden>
- Date: Wed, 5 Feb 2003 22:15:32 -0600
List,
I'm trying to print an NSImage so it scales to fit the page. I can't
seem to get this work though, as it always seems to chop off the right
half of my image. My code is below, though it's probably much more
complicated than need be. Do I have the right idea here? I've
searched the archives, and this seems to be about what people were
recommending.
Thanks in advance,
-Jan Van Tol
- (void)printImage:(id)sender {
[[NSPrintInfo sharedPrintInfo]
setHorizontalPagination:NSFitPagination];
NSImage *image = [imageView image];
NSImage *newImage = [[NSImage alloc] initWithSize:[[NSPrintInfo
sharedPrintInfo] imageablePageBounds].size];
[newImage lockFocus];
[image drawInRect:[[NSPrintInfo sharedPrintInfo]
imageablePageBounds] fromRect:NSMakeRect(0.0, 0.0, [image size].width,
[image size].height) operation:NSCompositeCopy fraction:1.0];
[newImage unlockFocus];
NSImageView *printView = [[NSImageView alloc]
initWithFrame:[[NSPrintInfo sharedPrintInfo] imageablePageBounds]];
[printView setImageScaling:NSScaleProportionally];
[printView setImage:newImage];
[printView print:sender];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.