ios - 如何以编程方式在 IOS AirPrint 上打印特定页面

标签 ios printing airprint

我有一个 iOS iPad 应用程序,它显示一个用户可以选择打印的 web View 。虽然显示的内容只有一页,但在第一页之后打印垃圾页,这是浪费碳粉。我只想打印第 1 页,但到目前为止,我能找到的唯一解决方案是使用确实不能解决我的问题的 showsPageRange = YES 选项。

谁能建议一个简单的方法来做到这一点?

最佳答案

用一个按钮测试这个你在 View 中包含的所有内容都是打印

 ///PRINT///
UIGraphicsBeginImageContextWithOptions(self.ImagentoPrint.bounds.size,    normal, 0.0);

 [self.ImagentoPrint drawViewHierarchyInRect:self.ImagentoPrint.bounds
                         afterScreenUpdates:normal];
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIPrintInfo *info = [UIPrintInfo printInfo];
info.orientation = UIPrintInfoOrientationLandscape;
info.outputType = UIPrintInfoOutputPhoto;
UIPrintInteractionController *pic =
[UIPrintInteractionController sharedPrintController];
pic.delegate = self;
pic.printingItem = snapshotImage;
pic.printInfo = info;

UIPrintInteractionCompletionHandler completionHandler =
^(UIPrintInteractionController *pic, BOOL completed, NSError *error)
{
    if (error)
        NSLog(@"failed... %@ %ld", error.domain, (long)error.code);
    if (completed)
        NSLog(@"completed yes");
    else
        NSLog(@"completed no");
};

[pic presentFromRect:CGRectMake(600, 650, 100, 200) inView:_ImagentoPrint animated:YES completionHandler:completionHandler];

关于ios - 如何以编程方式在 IOS AirPrint 上打印特定页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12395451/

相关文章:

ios - 部署 cordova admob 应用广告标识符检查

html - 分页前 : always is freezing print dialog box

python - 打印带有宽度说明符的 python 列表

html - 如何在不使用 WebBrowser 控件的情况下打印网页

html - 如何在 iOS 上假装是打印机,例如应用程序 Save2PDF 或 Adob​​e® CreatePDF?

objective-c - 如何在整个应用程序生命周期中获取有关初始化的每个 UIImage 的通知?

ios - 删除的 CloudKit 记录重新出现

ios - 有人在提交给苹果 ITMS-90709 时收到此错误吗?