• 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 in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

printing in Cocoa


  • Subject: printing in Cocoa
  • From: Victor Bovio <email@hidden>
  • Date: Wed, 16 Apr 2008 11:03:39 -0500

Hi,

Does anyone knows a good book or tutorial that covers printing (in- depth) in Cocoa apps ??, I have Hillegass book but just covers the minimal steps for printing..

I'll write below the problems I have with my app in case anyone can help, Thanks!


----------------------


I have a document-based Cocoa application, in which I display quartz routines directly to the context of my NSView.
Following the documentation I added this methods to enable printing in my application:



on NSDocument:

- (void)printDocumentWithSettings:(NSDictionary *)printSettings showPrintPanel:(BOOL)showPrintPanel
delegate:(id)delegate didPrintSelector: (SEL)didPrintSelector contextInfo:(void *)contextInfo
{
NSView *view = [self myDocumentView];
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
NSPrintOperation *printOp = [NSPrintOperation printOperationWithView:view printInfo:printInfo];
[printOp setShowPanels:showPrintPanel];
[self runModalPrintOperation:printOp delegate:delegate
didRunSelector:didPrintSelector contextInfo:contextInfo];
}



on NSView:

- (void)drawRect:(NSRect)rect
{
   NSGraphicsContext *nsctx = [NSGraphicsContext currentContext];
   CGContextRef context = (CGContextRef)[nsctx graphicsPort];
   // draw quartz routines to the context
}

- (BOOL)knowsPageRange:(NSRangePointer)aRange
{
   aRange->location = 1;
   aRange->length = 1;
   return YES;
}

- (NSRect)rectForPage:(NSInteger)pageNumber
{
   return NSMakeRect(0, 0, 8.5*72, 11*72);
}


It works and I can print, but I have two problems:

1) the preview image that is displayed in the print panel does not show correctly the contents of my view, it looks like it was blured (a lot)

2) if I select a different page size and/or orientation in the page setup panel, it is ignored when I print.


Any ideas what I'm missing ??


_______________________________________________

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


  • Follow-Ups:
    • Re: printing in Cocoa
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: Enabling File Open/Save etc in a non-document-based application
  • Next by Date: Re: NSAllocateCollectable() questions
  • Previous by thread: Re: NSString and utf16
  • Next by thread: Re: printing in Cocoa
  • Index(es):
    • Date
    • Thread