打印网页视图的第一面不同

Print the first side of the web view different

我正在为 macOS 使用 Swift 4,我可以将 HTML 字符串加载到我的 Web 视图中并使用我的代码打印它:

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()

是否可以仅对第一页应用不同的 printInfo 设置?

例如:第一页应该有 topMargin = 50,所有其他页面应该有 0。这可能吗?

您只能为整个文档设置这些值,不能为单个页面设置这些值。如果要为特定页面设置不同的页边距,则必须直接修改文档。