WebView (OSX) not rendering in print panel preview

匆匆过客 提交于 2019-12-06 01:47:06

Turns out that [[printView mainFrame] loadHTMLString: webviewHTMLString baseURL: tempImageURL]; doesn't block until the rendering is complete. Changed code as follows:

{   
    .
    .
    .

    // Load the frame, print it in the delegate when the load is complete   
    [printView setFrameLoadDelegate: self];
    [[printView mainFrame] loadHTMLString: webviewHTMLString baseURL: tempImageURL];
}

//  WebView has completed loading, so it can be printed now.
- (void) webView: (WebView *) printView didFinishLoadForFrame: (WebFrame *)frame
{
    NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];

    NSPrintOperation *printOp = [NSPrintOperation printOperationWithView: [[[printView mainFrame] frameView] documentView] printInfo: printInfo];
    [printOp setShowsPrintPanel: YES];
    [printOp runOperation];
    [printView release];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!