我已经搜索了,我以为我找到了我正在寻找的答案,但是唉,它仍然无法正常工作。该应用程序生成一个窗口并启动打印对话框,等待用户在没有对话的情况下打印时单击打印。
- (IBAction)print:(id)sender {
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
NSPrinter *printer;
printer = [NSPrinter printerWithName:@"Brother QL-710W"];
NSSize size;
size.width = 94;
size.height = 288;
[printInfo setPrinter:printer];
[printInfo setTopMargin:0.0];
[printInfo setBottomMargin:0.0];
[printInfo setLeftMargin:0.0];
[printInfo setRightMargin:0.0];
[printInfo setHorizontalPagination:NSFitPagination];
[printInfo setVerticalPagination:NSFitPagination];
[printInfo setOrientation:NSPaperOrientationLandscape];
[printInfo setPaperSize:size];
NSPrintOperation* printOperation = [NSPrintOperation printOperationWithView:PrintView];
[printOperation setCanSpawnSeparateThread:YES];
[printOperation runOperationModalForWindow:theLabelWindow delegate:theLabelWindow didRunSelector:nil contextInfo:nil];
[printOperation setShowsPrintPanel:NO];
[printOperation setShowsProgressPanel:NO];
//Reset the label window contents
//AppDelegate *printItDamnit = [[AppDelegate alloc] init];
//[printItDamnit resetLabel:self];
//GO!
[printOperation runOperation];
//Get rid of the label window because we're done with it ;)
[theLabelWindow close:self];}
这不应该消除他的对话吗?
[printOperation setShowsPrintPanel:NO];