使用分页符将Webview内容打印到Airprinter

时间:2017-03-28 06:26:09

标签: ios objective-c swift ipad airprint

我正在尝试将webview内容打印到airprinter。一切正常,除了我没有得到分页符。我在很多论坛上搜索过,但我找不到解决方案。

这是我的HTML模板

<html><body>
<h1 style='display:block; page-break-after:always;'>PAGE 1</h1>
<h1 style='display:block; page-break-after:always;'>PAGE 2</h1>
<h1 style='display:block; page-break-after:always;'>PAGE 3</h1>
</body></html>

Webview正确显示分页符。

但是当调用打印功能时,我得到了这个

enter image description here

@IBAction func printDoc(_ sender: Any) {

        let pic = UIPrintInteractionController.shared
        let printInfo : UIPrintInfo = UIPrintInfo(dictionary: nil)  
        printInfo.outputType = UIPrintInfoOutputType.general
        printInfo.jobName = "test"
        pic.printInfo = printInfo
        pic.printFormatter = webview.viewPrintFormatter()
        pic.showsPageRange = false    
        pic.present(animated: true, completionHandler: nil)
    }

请告诉我打印到空气打印机时如何分页。

0 个答案:

没有答案
相关问题