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];

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...