WebView, NSPrintOperation and Leopard

  • Hi All,

    I'm the author of a relatively popular Automator action called
    "Download URLs as PDFs" and it no longer functions in Leopard.  I
    believe I have traced the problem, but I'm not sure how to fix it.

    When the user chooses to download a paginated PDF, the action
    calls NSPrintOperation on the documentView within the webView
    and dumps it to a file.  This worked fine in Tiger, but apparently
    NSPrintOperation in Leopard tries to lock the focus of the view it is
    printing, resulting in an assertion failure:

    11/1/07 8:09:03 PM Automator[3748] ** INTERNAL ERROR: Uncaught
    Exception **
    Exception: lockFocus sent to a view which is not in a window

    I tried using setHidden:YES on the view in question, which fixed
    the error, but it also resulted in blank PDFs.  I suppose I could add
    the webView to a window, but frankly I'm not sure how to work that
    out in Automator.

    Here are some snippets:

    // Webview Creation
    fakeWebView = [[WebView alloc] initWithFrame:NSZeroRect frameName:nil
    [fakeWebView setFrameLoadDelegate:self];
    [fakeWebView setMaintainsBackForwardList:NO];

    And later:

    // Print Routine
    NSPrintOperation *printOp;
    printOp = [NSPrintOperation printOperationWithView:printView
    [printOp setShowPanels:NO];
    [printOp runOperation]; // There error happens somewhere in here.

    My Cocoa has gotten extremely rusty, so forgive me if I'm missing
    something completely obvious.


previous month november 2007 next month
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today