gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 16:55:06 25 4
gpt4 key购买 nike

我有一个 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/

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