Weird 40pt pixel margin from "Any" Printer setup

I'm working on implementing printing for my graphics app. This is an NSDocument-based app written in Swift.


I'm setting printInfo fields as follows, on the .printInfo member of the document class, and passing that instance into NSPrintOperation:


self.printInfo.topMargin = 0.0
self.printInfo.rightMargin = 0.0
self.printInfo.leftMargin = 0.0
self.printInfo.bottomMargin = 0.0
self.printInfo.isHorizontallyCentered = true
self.printInfo.isVerticallyCentered = true
self.printInfo.orientation = .landscape

let newPrintOp = NSPrintOperation(view: self.printView!, printInfo: self.printInfo)
newPrintOp.showsPrintPanel = true       
return newPrintOp


Now, I know that the *actual* printer page bounds I get from the system will depend on what printer is selected in Page Setup. This buggy behavior I'm seeing occurs when I select the "Any" default system printer. It sends back (and enforces) the following imageablePageBounds:

(18.0, 18.0, 734.0, 576.0)


This is a page with 1/4" margins on top, left, and bottom, and 40pt margin on the right! (792-734-18 = 40). So not only is it not centered as requested, it doesn't even permit a centered image with 1/2" margin to be printed without clipping.


I think this is a bug. The "Any" printer should give a reasonable 1/4" minimum margin - particularly for printing to PDF.


Note this error does not happen if I select my actual printer in page setup, which provides both normal and borderless options. The normal option then gives me back a reasonable, centered imageablePageBounds (with a consistent small margin), while the borderless option gives me the expected (0.0, 0.0, 792.0, 612.0) for borderless letter/leandscape.


Is this 40-pt right margin a known bug in the system default "Any" printer page setup?


Also FWIW I've posted this issue on stackoverflow with some screenshots of the print panel showing the issue:

https://stackoverflow.com/questions/59691305/cocoa-printing-with-swift-any-printer-setup-has-irregular-margins-page-size


Thanks for any tips or workarounds, or replies if you've seen this as well.

Christopher