How to print a non PDF document from MacOS using swift or shell script

Is there any framework in macOS to print a non pdf document. PDF kit is showing print panel that too only for PDF documents.


Code snippet :

let pdfView = PDFView()

let path = URL(fileURLWithPath: "/Users/syamala/Desktop/Book1.pdf")

let pdfDoc = PDFDocument(url: path)

pdfView.document = pdfDoc

let wnd = NSWindow()

pdfView.autoScales = true

pdfView.displaysPageBreaks = false

wnd.setContentSize(pdfView.frame.size)

wnd.contentView = pdfView

pdfView.print(with: NSPrintInfo.shared, autoRotate: true)



Shell command

lp /Users/syamala/Desktop/Book1.pdf , even this prints only pdf docs but not non-pdf docs.


Is there any swift native framework to print a document from local directory or shell command to print a document.