2014-11-04 1 views
1

Я хочу напечатать файл PDF (iOS 8.1, AirPrint, Swift) непосредственно на принтере. Печать в порядке, но я получаю это сообщение в Xcode:AirPrint: Печать файла pdf непосредственно на принтер

2014-11-04 12: 34: 50,069 PrintApp [801: 266564] - [PKPaperList matchedPaper: preferBorderless: withDuplexMode: didMatch:] paperToMatch = result = matchType = 0

Что это значит?

Это мой код:

let url: NSURL = NSURL(string:"http://www.sirup-shop.de/csv/test-paketlabel.pdf")! 

let printInfo = UIPrintInfo(dictionary: nil) 
printInfo.jobName = "Label" 

let printController = UIPrintInteractionController.sharedPrintController()! 
printController.printingItem = url 
printController.printInfo = printInfo 
printController.delegate = self 
printController.printToPrinter(self.printer!, completionHandler: { 
    (controller:UIPrintInteractionController!, completed:Bool, error:NSError!) -> Void in 
    println("Label finished.") 
}) 

Большое спасибо вам помочь.

+0

вам может понадобиться, чтобы посмотреть на этот ответ: http://stackoverflow.com/a/24966715/1214122 – holex

+0

@holex: да, я видел этот ответ. Проблема заключалась в том, что у него был printFormatter _and_ printItem. Проблема была решена путем предоставления только printFormatter. Но у меня есть только файл печати. – Michael

ответ

0

Я разделяю Objective-C Code, вы можете считать это ссылкой.

UIPrintInteractionController *pc = [UIPrintInteractionController 
            sharedPrintController]; 
UIPrintInfo *printInfo = [UIPrintInfo printInfo]; 
printInfo.outputType = UIPrintInfoOutputGeneral; 
printInfo.orientation = UIPrintInfoOrientationPortrait; 
printInfo.jobName [email protected]"Report"; 

pc.printInfo = printInfo; 
pc.showsPageRange = YES; 
pc.printingItem = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://test.com/Print_for_Client_Name.pdf"]]; 


UIPrintInteractionCompletionHandler completionHandler = 
^(UIPrintInteractionController *printController, BOOL completed, 
    NSError *error) { 
    if(!completed && error){ 
     NSLog(@"Print failed - domain: %@ error code %ld", error.domain, 
       (long)error.code); 
    } 
}; 


[pc presentFromRect:CGRectMake(0, 0, 300, 300) inView:self.view animated:YES completionHandler:completionHandler];