How do I set the printInfo to print in landscape in OS X?

1k views Asked by At

I have set the following code:

let printInfo = NSPrintInfo.sharedPrintInfo
let textPrint = NSPrintOperation(view: theTextView,printInfo: printInfo())

Now I would like to set the orientation to Landscape, but I can't find any Swift functions that do this.

2

There are 2 answers

7
Ken Thomases On

Try this:

let pmPageFormat = printInfo.PMPageFormat()
PMSetOrientation(pmPageFormat, kPMLandscape, kPMUnlocked)
printInfo.updateFromPMPageFormat()
0
Steve Heffern On

This is what I'm using. The NSView is called drawing.

let pinfo = NSPrintInfo.shared()
pinfo.orientation = .landscape
pinfo.bottomMargin = 0.0
pinfo.topMargin = 0.0
pinfo.leftMargin = 0.0
pinfo.rightMargin = 0.0
drawing!.print(self)