我正在构建一个应用程序,它使用一堆文本字段让用户填写医生办公室。然后,他们将点击打印按钮以打印用户填写的pdf页面。我遇到的问题是,我使用的打印代码将其显示为空白文档。
@IBAction func printBtnPressed(_ sender: Any) {
let pInfo = UIPrintInfo(dictionary:nil)
pInfo.outputType = UIPrintInfoOutputType.general
pInfo.jobName = "Print Patient Forms"
//Set up print controller
let printController = UIPrintInteractionController.shared
printController.printInfo = pInfo
//Assign a UIMage version of my UIView as a printing Item
printController.printingItem = self.view
//var pInfo : UIPrintInfo = UIPrintInfo.printInfo()
pInfo.orientation = UIPrintInfoOrientation.portrait
let formatter = UIMarkupTextPrintFormatter(markupText: textView.text!)
printController.showsNumberOfCopies = false
printController.showsPageRange = true
printController.printFormatter = pdfView.viewPrintFormatter()
printController.present(animated: true, completionHandler: nil)
}
有人有任何建议吗?