let printController = UIPrintInteractionController.sharedPrintController()
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = UIPrintInfoOutputType.General
printInfo.jobName = "note"
printController.printInfo = printInfo
func textFormatter(text: String) -> String
{
return text.stringByReplacingOccurrencesOfString("\n", withString: "<BR>")
}
let formatter = UIMarkupTextPrintFormatter(markupText: textFormatter(self.testo.text))
formatter.contentInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
printController.printFormatter = formatter
if UIDevice.currentDevice().userInterfaceIdiom == .Pad
{
printController.presentFromRect(self.printBtn.frame, inView:self.view, animated:true, completionHandler: nil)
}
else
{
printController.presentAnimated(true, completionHandler: nil)
}
Luca.