ios - 从 WKWebView 打印 2 页时出现问题

标签 ios objective-c printing wkwebview

要求:我有一个名为wkWebViewWKWebview 对象。我想使用 Airprint 从我的打印机打印它的内容。我曾经使用 UIWebview 执行此操作,但运行时 javascript 方法的要求让我切换到 WKWebview

@property (strong, nonatomic) WKWebView *wkWebView;

问题:我可以使用下面的代码打印内容。当我打印一页时,它打印得很完美。但是当我尝试打印 2 页时,第 2 页先打印,然后是第 1 页。我想按顺序打印页面。

代码:我目前在我的打印方法中使用这段代码:

UIPrintInfo *pi = [UIPrintInfo printInfo];
pi.outputType = UIPrintInfoOutputGrayscale;
pi.orientation = UIPrintInfoOrientationPortrait;
pi.duplex = UIPrintInfoDuplexNone;


UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.printInfo = pi;
pic.showsPageRange = YES;
pic.showsNumberOfCopies = NO;
pic.printFormatter = _wkWebView.viewPrintFormatter;

UIButton *butn = (UIButton*)sender;

[pic presentFromRect:butn.frame
              inView:self.view
            animated:YES
   completionHandler:^(UIPrintInteractionController *printInteractionController, BOOL completed, NSError *error) {

       //Do something
   }];

最佳答案

您是否尝试过单独打印页面?

我会将它们放在数组中,然后检查数组长度并运行代码以在 For 循环中打印页面。

关于ios - 从 WKWebView 打印 2 页时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32978649/

相关文章:

ios - 使用静态单元格对 Tableview 中的单元格进行子类化

ios - 使用 Cocoa Pods 导入 Google Analytics iOS SDK 时出错

powershell - Powershell Out-Printer破坏了“格式表”列的布局

Css - 用颜色(内容)填充区域

ios - Swift:从 SQLite.swift 访问 NULL 值时应用程序崩溃

iOS,PopOverPresentationController 问题,.xib

iphone - 如何在 iphone 应用程序启动时打开不同的 View Controller ?

ios - Objective-C 中计算 float 的奇怪值

iphone - 字符已在范围内吗?

java - 使用 Java 打印到收据打印机时修复文本拉伸(stretch)