NSPrintInfo design report

I am developing an macOS Xcode 12 app that requires printing. I have a basic understanding how to implement printing, I understand that I need to create a subclass of NSview to get going. However, I was wondering how to go about designing the report? Is this done with interface builder like designing a window layout or is all done with code, ie supplying position (x,y), headings, font, graphics, font size.. etc. How is this done?

Also, does anybody have any tutorials on this? I have one example but it is very minimal print out, basically it prints a tableview with two columns. I got this from Coca Programming chapter 27, Big Nerd Ranch.
Answered by BigEagle in 673399022
Thanks Claude for sending me the additional examples. Very useful!
The way I do it is to design the report as a view in code.

Schematically, it will be:
I create a PrintView and house all the drawing in the draw function

Code Block
class PrintView: NSView {
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
// Drawing code here.
}
}

Then, to print, I call (from the handler of Print menu command for instance or from a print button in a view)

Code Block
let aSize = NSSize(width: printInfo.paperSize.width - 20, height: totalHeight)
let printView = PrintView(frame: NSRect(origin: NSPoint(x: 1, y: 10), size: aSize)) // a full page, depending on orientation

and call the printPanel
Code Block
        let printOp = NSPrintOperation(view: printView, printInfo: printInfo)

Claude,
Makes sense what you posted, I was hoping there was a design tool to create the drawing code.

So, does that mean thinks like Font, Font Size, colors, Graphics etc. are created in PrintView Class with code? And I guess the only way to see the report is to print it?

Do you have any code of a PrintView class you could share?

Thanks
Of course I have code(s) for PrintView.

But the content is very specific to the different apps. And too long to post here.

If you post an email address, we could continue discussion through this mail channel.
Accepted Answer
Thanks Claude for sending me the additional examples. Very useful!
The following is the correct answer. It was supplied by Claude31 as well as an offline template he sent me.

The way I do it is to design the report as a view in code.

Schematically, it will be:
I create a PrintView and house all the drawing in the draw function


Code Block
class PrintView: NSView {
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect) // Drawing code here. }}


Then, to print, I call (from the handler of Print menu command for instance or from a print button in a view)


Code Block
let aSize = NSSize(width: printInfo.paperSize.width - 20, height: totalHeight)
let printView = PrintView(frame: NSRect(origin: NSPoint(x: 1, y: 10), size: aSize)) // a full page, depending on orientation


and call the printPanel

Code Block
        let printOp = NSPrintOperation(view: printView, printInfo: printInfo)

NSPrintInfo design report
 
 
Q