gpt4 book ai didi

iphone - iOS AirPrint - 打印多个 URL

转载 作者:行者123 更新时间:2023-11-28 17:34:52 26 4
gpt4 key购买 nike

根据这篇文章的问题: Unable to display printer options with AirPrint

我有几个问题:

1) 答案之一是将 Controller.printItem 设置为 URL。同样,我可以设置多个网址吗?基本上,我有一组需要一次打印的 URL。是否可以将 controller.printitems 设置为 URL 数组?另外,我知道 controller.printItem 采用“数据”类型,那么如何将基于 Web 的图像 URL 转换为“数据”类型?

2) 由于某些奇怪的原因,默认情况下,每次我到达打印对话框时,双面都设置为打开。我需要什么变量来关闭它?如果我可以不向用户显示该选项,那就太好了。

最佳答案

试试这个代码可能对你有帮助

- (IBAction)btnPrintTapped:(id)sender {
NSData *imageData = UIImagePNGRepresentation(self.imgV.image);
[self printItem:imageData];
}

#pragma mark - Printing

-(void)printItem :(NSData*)data {
printController = [UIPrintInteractionController sharedPrintController];
if(printController && [UIPrintInteractionController canPrintData:data]) {
printController.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [NSString stringWithFormat:@""];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printController.printInfo = printInfo;
printController.showsPageRange = YES;
printController.printingItem = data;
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 presentFromBarButtonItem:self.item animated:YES completionHandler:completionHandler];
}
}

- (BOOL)presentFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated completionHandler:(UIPrintInteractionCompletionHandler)completion {
return YES;
}

- (BOOL)presentFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated completionHandler:(UIPrintInteractionCompletionHandler)completion {
return YES;
}

关于iphone - iOS AirPrint - 打印多个 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10102392/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com