This is what is working for me :
var viewController: ViewController {
get {
return self.window!.contentViewController! as! ViewController
}
}
...
viewController.cwHello.color = cptHello.colr
Post
Replies
Boosts
Views
Activity
I am also interested!
ChatGPt found the problem today, this code is working:
func createPrintOperation() {
let printOpts: [NSPrintInfo.AttributeKey: Any] = [.headerAndFooter: false,.orientation : 1] // set
let printInfo = NSPrintInfo(dictionary: printOpts)
printInfo.leftMargin = 0
printInfo.rightMargin = 0
printInfo.topMargin = 0
printInfo.bottomMargin = 0
printInfo.horizontalPagination = .fit
printInfo.verticalPagination = .automatic
printInfo.isHorizontallyCentered = true
printInfo.isVerticallyCentered = true
printInfo.scalingFactor = 1.0
printInfo.paperSize = NSMakeSize(612, 792) // letter
printInfo.orientation = .portrait
let printOperation = NSPrintOperation(view: PrintView, printInfo: printInfo)
// Attempt to show paper size and orientation options
printOperation.printPanel.options.insert(.showsPaperSize)
printOperation.printPanel.options.insert(.showsOrientation)
// Set the job title
let jobTitle = fact.nom_complet_f.replacingOccurrences(of: " ", with: "")
printOperation.jobTitle = jobTitle
// Ensure the print operation runs on the main thread
DispatchQueue.main.async {
printOperation.run()
}