2013-07-08 1 views
8

現在、私はCocoaアプリケーションのWebViewに読み込んだpdfを印刷しようとしています。スクロールする。問題は、それが印刷したときに、それだけでこのようなコードで、現在のWebViewではなくページ全体に表示されているものを印刷していることである:ココアのWebViewの全内容を表示するだけでは表示しない

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

私はちょうど、印刷しようとしていた場合、私はわからないんだけどそれの間違った部分、または別の方法でこれについて行く必要があり、いくつかの助けに非常に感謝します。

+0

は '[[[WebViewのメインフレーム] frameView] printDocumentView]'のようにprintDocumentView –

+0

てみ?何もしなかった、誤りでさえなかった。私はまた、問題がpdfsにのみ影響し、上記で編集すると判断したことに言及する必要があります。 – Zoz

答えて

14

これは古い質問ですが、まだ回答がないので、私はこれを検索する人に提供すると考えました。

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

私は 'NSLandscapeOrientation'の代わりに' NSPaperOrientationLandscape'を使用しなければなりません – Todd

+2

完全なHTMLを得るためには、documentView:yourWebView.mainFrame.frameView.documentView – SarahR

0

次スウィフトコード私の作品:

NSPrintOperation(view: webView.mainFrame.frameView.documentView).runOperation() 
関連する問題