• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Printing an NSImage fit to page
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: RE: NSLayoutManager question
  • Next by Date: RTFD from a Foundation app?
  • Previous by thread: Re: default Find Panel?
  • Next by thread: RTFD from a Foundation app?
  • Index(es):
    • Date
    • Thread