Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple printing question



You will need to do something like

- (void)printReceipt:(Transaction *)transToPrint
{
NSPrintOperation *op;

NSView *view = [[NSTextView alloc]
initWithFrame:NSMakeRect(0.0,0.0,200.0,10.0)]; // replace 200.0 with an
appropriate width
[view insertText:[transToPrint descriptionSummary]];

NSPrintInfo * pi = [NSPrintInfo sharedPrintInfo];
[pi setHorizontallyCentered:NO];
[pi setVerticallyCentered:NO];
[pi setLeftMargin:36.0]; // 36 points
[pi setTopMargin:36.0];
op = [NSPrintOperation printOperationWithView:view printInfo:pi];

[op setShowPanels:NO];
[op runOperation];

[view release]; // don't leak memory
}

There are a lot of things you may control with NSPrintInfo, including paper
size, margins and whether the view is centered vertically and horizontally.

Regards,

Tom Bernard
email@hidden







on 6/28/04 5:32 AM, Andrew Kinnie at email@hidden wrote:

> However, now it prints, but it is tiny, and leaves large margins on
> each side (which is bad considering the paper is only 72 mm wide).
_______________________________________________
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.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.