我发现这是一个老问题,但由于目前还没有任何答案,我以为我会为任何人提供这个搜索。
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
// This is your chance to modify printInfo if you need to change
// the page orientation, margins, etc
[printInfo setOrientation:NSLandscapeOrientation];
NSPrintOperation *printOperation = [yourWebView.mainFrame.frameView
printOperationWithPrintInfo:printInfo];
// Open the print dialog
[printOperation runOperation];
// If you want your print window to appear as a sheet instead of a popup,
// use this method instead of -[runOperation]
[printOperation runOperationModalForWindow:yourWindow
delegate:self
didRunSelector:@selector(printDidRun)
contextInfo:nil];
尝试printDocumentView –
作为'[[[WebView中的主机] frameView] printDocumentView]'?没有做任何事情,甚至没有发生错误。我还应该提到,我已经确定该问题只影响pdf并将在上面进行编辑。 – Zoz