Re: Printing
Re: Printing
- Subject: Re: Printing
- From: email@hidden
- Date: Thu, 12 Oct 2006 23:12:19 +0200
On 12 Oct 2006, at 20:58, Gerriet M. Denkmann wrote:
I want to print programatically. So I do [NSPrintOperation
setShowsPrintPanel: NO].
But how do I tell the NSPrintOperation about the destination (fax,
printer, file, etc.)? It seems always to print to the default
printer, which is not what I want.
This is what I do do print something without displaying the Print panel:
- (void)markPageViewsDirtyForPrinting
{
NSEnumerator *viewEnum;
NSView *subView;
// Force the subviews to redisplay for printing
viewEnum = [[[scrollView documentView] subviews] objectEnumerator];
while ((subView = [viewEnum nextObject]))
[subView setNeedsDisplay: YES];
[[scrollView documentView] setNeedsDisplay: YES];
}
- (BOOL)writeToFile:(NSString *)aPath
{
BOOL success = YES;
NSPrintInfo *tempPrintInfo;
NSPrintOperation *op;
tempPrintInfo = [[[self printInfo] copyWithZone: [self zone]]
autorelease];
[tempPrintInfo setJobDisposition: NSPrintSaveJob];
[[tempPrintInfo dictionary] setObject: aPath
forKey: NSPrintSavePath];
[[tempPrintInfo dictionary] setObject: [NSNumber numberWithBool:
YES]
forKey: NSPrintAllPages];
op = [NSPrintOperation printOperationWithView: [scrollView
documentView]
printInfo: tempPrintInfo];
[op setShowPanels: NO];
[self markPageViewsDirtyForPrinting];
success = [op runOperation];
[self setDocumentEdited: NO];
return success;
}
Annard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Printing (From: "Gerriet M. Denkmann" <email@hidden>) |