uiprintformatter

AirPrint contents of a UIView

做~自己de王妃 提交于 2019-12-21 05:06:28
问题 I'm trying to set up printing through an iPad app, where clicking Print will print a view with all of its contents. Here's what I've tried (pulled together from a few examples online): // This is the View I want to print // Just a 200x200 blue square var testView = UIView(frame: CGRectMake(0, 0, 200, 200)) testView.backgroundColor = UIColor.blueColor() let printInfo = UIPrintInfo(dictionary:nil)! printInfo.outputType = UIPrintInfoOutputType.General printInfo.jobName = "My Print Job" // Set up

UIMarkupTextPrintFormatter never renders base64 images

天大地大妈咪最大 提交于 2019-11-28 01:11:04
问题 Im creating a pdf file out of html content in swift 3.0: /** * */ func exportHtmlContentToPDF(HTMLContent: String, filePath: String) { // let webView = UIWebView(frame: CGRect(x: 0, y: 0, width: 694, height: 603)); // webView.loadHTMLString(HTMLContent, baseURL: nil); let pdfPrinter = PDFPrinter(); let printFormatter = UIMarkupTextPrintFormatter(markupText: HTMLContent); // let printFormatter = webView.viewPrintFormatter(); pdfPrinter.addPrintFormatter(printFormatter, startingAtPageAt: 0);