xcode – 在Cocoa中打印WebView的全部内容,而不仅仅是显示

所以我目前正在尝试打印一个我已经加载到 Cocoa应用程序中的WebView的pdf,如果你想看到你需要滚动的整个内容,它的大小.问题在于,无论何时打印,它只打印当前在WebView中显示的内容而不是整个页面,代码如下:
[[[[WebView mainFrame] frameView] documentView] print:sender];

我不确定我是否只是试图打印错误的部分,或者只是需要以另一种方式解决这个问题,并且非常感谢一些帮助.

解决方法

我看到这是一个老问题,但由于还没有任何答案,我想我会为任何搜索提供这个.
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];

以上是来客网为你收集整理的xcode – 在Cocoa中打印WebView的全部内容,而不仅仅是显示全部内容,希望文章能够帮你解决xcode – 在Cocoa中打印WebView的全部内容,而不仅仅是显示所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。