Print the first side of the web view different

102 views Asked by At

I'm working with Swift 4 for macOS and I can load a HTML string into my web view and print this with my code:

let printInfo = NSPrintInfo.shared
printInfo.isHorizontallyCentered = true
printInfo.isVerticallyCentered = true
printInfo.orientation = .portrait
printInfo.topMargin = 0
printInfo.rightMargin = 0
printInfo.bottomMargin = 50
printInfo.leftMargin = 0
printInfo.verticalPagination = .autoPagination

let printOp = NSPrintOperation(view: sender.mainFrame.frameView.documentView, printInfo: printInfo)

printOp.run()

Is it possible to apply different printInfo settings only for the first page?

For example: The first page should have topMargin = 50 and all other pages should have 0. Is this possible?

1

There are 1 answers

0
Tamás Sengel On BEST ANSWER

You can only set those values for the whole document and not for individual pages. If you want to set up different margins for a specific page, you'll have to modify the document directly.