微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

原文地址:https://www.jb51.cc/iOS/334933.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐