打印WebView的整个内容在Cocoa,不是显示 [英] Printing Entire Contents of WebView in Cocoa, Not Just Displayed

查看:237
本文介绍了打印WebView的整个内容在Cocoa,不是显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我目前正试图打印一个pdf,我已经加载到一个Cocoa应用程序中的WebView,它的大小如何,如果你想看到你必须滚动的整个事情。问题是,无论何时打印,它只打印当前显示在WebView中,而不是整个页面,代码如下:

So I am currently trying to print a pdf that I have loaded into a WebView in a Cocoa application, which is sized to where if you want to see the whole thing you have to scroll. The problem is that whenever it prints, it only prints what is currently displayed in the WebView and not the entirety of the page, with code like this:

    [[[[WebView mainFrame] frameView] documentView] print:sender];

我不知道我只是打印错误的部分,

I'm not sure if I am just trying to print the wrong part of it, or just need to go about this in another way, and would greatly appreciate some help.

推荐答案

我看到这是一个老问题,但是,因为没有任何答案,我想我会为任何搜索提供这个。

I see that this is an old question, but since there aren't any answers yet, I thought I would provide this for anyone searching.

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

这篇关于打印WebView的整个内容在Cocoa,不是显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆