尝试进行此打印但未显示在打印机模拟器中。
这是我打印它的代码:
-(void)printItem:(NSString*)path {
// NSString *path = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"png"];
NSData *dataFromPath = [NSData dataWithContentsOfFile:@"http://www.endnote.com/support/helpdocs/EN%208%20Scripted%20Demo.pdf"];
// path = @"http://www.samplepdf.com/sample.pdf";
path = @"http://www.endnote.com/support/helpdocs/EN%208%20Scripted%20Demo.pdf";
UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];
NSLog(@"Can we print? %@",printController);
// NSLog(@"Secondly, Can we print? %@",[UIPrintInteractionController canPrintURL:[NSURL URLWithString:path]]);
// if(printController && [UIPrintInteractionController canPrintData:dataFromPath]) {
printController.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [path lastPathComponent];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printController.printInfo = printInfo;
printController.showsPageRange = YES;
printController.printingItem = [NSURL URLWithString:path];
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
}
};
[printController presentAnimated:YES completionHandler:completionHandler];
// }
}
弹出打印机选项模式,允许我选择打印机,范围,复印和双面打印机。当我按下范围时,它知道我正在尝试打印的网址有4页。我知道这一点,因为当我尝试另一个有1页的网址时,页面范围显示为1页。
有什么想法吗?
感谢。