[英]How to set number of pages to print using UIPrintInteractionController.print in swift 3?
I'm using the UIPrintInteractionController
to print a html from a UIWebView
directly to an AirPrint printer.我正在使用
UIPrintInteractionController
将 html 从UIWebView
直接打印到 AirPrint 打印机。 I would like to tell the UIPrinter
that only the first page should be printed.我想告诉
UIPrinter
应该只打印第一页。 How can I do this?我该怎么做?
Here is my code which prints all pages:这是我打印所有页面的代码:
let printer = UIPrinter(url: myURL)
let printerController = UIPrintInteractionController.shared
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "My print job name"
printInfo.outputType = .general
printerController.printInfo = printInfo
let printPageRenderer = MyCustomPageRenderer()
printPageRenderer.addPrintFormatter(myWebView.viewPrintFormatter(), startingAtPageAt: 0)
printerController.printPageRenderer = printPageRenderer
printerController.print(to: printer!) { (printerController, success, error) in
}
The code should be compatible with iOS 9.0.该代码应与 iOS 9.0 兼容。
There is numberOfPages
property in UIPrintPageRenderer
that you can override.您可以覆盖
UIPrintPageRenderer
中的numberOfPages
属性。 Or you may just set the UIPrintInteractionController
property showsPageRange
to true .或者您可以将
UIPrintInteractionController
属性showsPageRange
设置为true 。
For more reference please use see this link - https://developer.apple.com/documentation/uikit/uiprintpagerenderer/1621631-numberofpages如需更多参考,请使用此链接 - https://developer.apple.com/documentation/uikit/uiprintpagerenderer/1621631-numberofpages
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.