how do I print the contents of the PdfView?

XCode - Swift

private var mPdfView = PDFView()

private var mDocumentData: Data?

mDocumentData = MakePdfDocument()

mPdfView.document = PDFDocument(data: mDocumentData!)

let printInfo = UIPrintInfo(dictionary: nil)

printInfo.outputType = UIPrintInfo.OutputType.general

printInfo.jobName = “JobName”

let printController = UIPrintInteractionController.shared

printController.printInfo = printInfo

printController.printingItem = mPdfView

printController.showsNumberOfCopies = true

printController.present(animated: true, completionHandler: nil)

**When print is executed, only the blank screen is output, not the generated PDF.

How can I print the generated PDF content?**

Try this

if let pdfData = pdfView.document?.dataRepresentation() {
   let printInfo = UIPrintInfo(dictionary: nil)
   printInfo.jobName = "page"
   printInfo.outputType = .general

   let printController = UIPrintInteractionController.shared
   printController.printInfo = printInfo
   printController.showsNumberOfCopies = true
   printController.printingItem = pdfData
   printController.present(animated: true, completionHandler: nil)
}

I hope this helps.

how do I print the contents of the PdfView?
 
 
Q