0

I am building an app that uses a bunch of text fields to let the user fill in at a doctors office. They will then hit a print button to print the pdf like page that has been filled out by the user. The problem I am having is that with the code for printing that I have it shows it as a blank document.

@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)
}

Anyone have any suggestions?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Blue Moose
  • 125
  • 1
  • 15
  • Replace `printController.printFormatter = pdfView.viewPrintFormatter()` with `printController.printFormatter = formatter` and try – Dharmesh Kheni Dec 16 '17 at 05:18
  • okay thats a start! it shows the text view... is there a way to incorporate this to show the text field boxes that people will fill in and the labels that I make – Blue Moose Dec 16 '17 at 05:42

0 Answers0