-
Printing multiple pages in Objective-C
16 June 2015This prints a representation of a page preview called sheet, which is an NSBox
- (void)sendToPrinter:(int)code { NSPrintInfo *printInfo; NSPrintInfo *sharedInfo; NSPrintOperation *printOp; NSMutableDictionary *printInfoDict; NSMutableDictionary *sharedDict; sharedInfo = [NSPrintInfo sharedPrintInfo]; sharedDict = [sharedInfo dictionary]; printInfoDict = [NSMutableDictionary dictionaryWithDictionary: sharedDict]; [printInfoDict setObject:NSPrintSpoolJob forKey:NSPrintJobDisposition]; printInfo = [[NSPrintInfo alloc] initWithDictionary: printInfoDict]; [printInfo setHorizontalPagination: NSAutoPagination]; [printInfo setVerticalPagination: NSAutoPagination]; [printInfo setVerticallyCentered:NO]; [printInfo setLeftMargin:10]; [printInfo setRightMargin:10]; [printInfo setTopMargin:10]; [printInfo setBottomMargin:10]; [printInfo setScalingFactor:1.1]; printOp = [NSPrintOperation printOperationWithView:sheet printInfo:printInfo]; [printOp setShowsPrintPanel:YES]; [printOp runOperation]; }
- (BOOL)knowsPageRange:(NSRangePointer)aRange; { *aRange = NSMakeRange(1, 10); return YES; } - (void)beginPageInRect:(NSRect)aRect atPlacement:(NSPoint)location; { [self setTitle:[NSString stringWithFormat:@"Page %d", [[NSPrintOperation currentOperation] currentPage]]]; [super beginPageInRect:aRect atPlacement:location]; } - (NSRect)rectForPage:(NSInteger)page; { return [self bounds]; } @end
Comments
Comments closed on this post.

Categories
Tags
- splitview
- image,photo,image picker,UICollectionViewCell
- Status Bar
- Image,filter
- UICollectionView
- Text to Speech
- swipe,refresh
- Android,REST
- Swift
- PDF,Webview
- UIAlertView
- Objective C, Swift,UIPrint​Interaction​Controller
- swift tutorial,swift
- NSArray,NSMutableArray
- uiwebview
- uiwebview,swift
- print,printing
- HTML, webview
- swift tutorial,swift
- Game, Swift
- UICollectionView
- UITableview Cell, Swift
- view controllers,detached
- Wifi file Transfer
- NSTimer, Swift
- power,swift
- swift tutorial,swift
- Storyboards, ios9
- Alert View
- navigation bar, Swift
- popover,swift
- iOS, swift, platform, factors to consider
- webview,android, iOS,swift
- webview, android
- JSON, Swift
- Mobile App Development
- swift, tricks