'Printing from iOS / ImageRenderer error

Good morning,

The swift data project is completed as far as the database portion but a label needs to be printed for a saved record.

The approach has been to have a view containing the text and image ( QR code) for the particular record . This view was converted to an image using ImageRenderer.

In trying to use this image an error is given < Cannot call value of non-function type ‘ImageRenderer’

Just don’t understand the meaning of this message although I think it is something very basic .

There doesn’t seem to be a lot of information regarding iOS printing so a third party was used - PrintKit. Any direction as to printing , labels , reports ,etc is also appreciated.

Code and screen shot included



import SwiftUI
import PrintingKit
import CoreImage.CIFilterBuiltins
import UIKit

struct ContentView: View {
    let user: String = "Eisenstat"
    let date: Date = Date.now
    let pouchID: UUID
    let instruments:String = "Explorer"
    let printer = Printer.shared
    let contextt = CIContext()
    let filter = CIFilter.qrCodeGenerator()
    let imageModel: UIImage

    var body: some View {
        VStack(alignment: .leading) {
            Image(uiImage: generateQRCode(from: "\(date.ISO8601Format())\n\(user)\n\(instruments)\n\(pouchID.uuidString)"))
            let labelPrint = ContentView(pouchID: UUID(), imageModel: UIImage())
            let renderer = ImageRenderer(content: labelPrint) //**Cannot call value of non-function type 'ImageRenderer<ContentView>'**
            Button("Print label") {
                if let image = renderer(named: "label") {
                   if let data = renderer.jpeg.data(compressionQuality: 0.5) {
                        let p = PrintItem.imageData(data)
                        try? printer.print(p)
        func generateQRCode(from string: String) -> UIImage {
            filter.message = Data(string.utf8)
            if let outputImage = filter.outputImage {
                if let cgImage = contextt.createCGImage(outputImage, from: outputImage.extent) {
                    return UIImage(cgImage: cgImage)
            return UIImage(systemName: "xmark.circle") ?? UIImage()

Screenshot 2024-04-18 at 11.04.15 AM

All good , sorted out . Now able to print any view .

Still looking for a way to replace PrintKit

An other gotcha was that the print interface doesn’t seem to be available in the simulator so a device is required.