我發現這是一個老問題,但由於目前還沒有任何答案,我以爲我會爲任何人提供這個搜索。
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