gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 16:05:12 33 4
gpt4 key购买 nike

所以我目前正在尝试打印一个已加载到 Cocoa 应用程序中的 WebView 中的 pdf,该 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的全部内容,而不仅仅是显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17529126/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com