Skip to content

Commit

Permalink
Ensure savePanel is closed before generating PDF file. fixes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
superfell committed Aug 8, 2015
1 parent f1747ac commit 719bcfb
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions AppExplorer/ReportDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,13 @@ - (IBAction)saveAsPdf:(id)sender {

NSWindow *window = [[[self windowControllers] objectAtIndex:0] window];
[sp beginSheetModalForWindow:window completionHandler:^(NSInteger result) {
[self savePanelDidEnd:sp returnCode:result contextInfo:nil];
if (NSFileHandlingPanelOKButton == result) {
[sp orderOut:nil];
NSView *docView = [[[webview mainFrame] frameView] documentView];
NSData *pdf = [docView dataWithPDFInsideRect:[docView bounds]];
[pdf writeToURL:[sp URL] atomically:YES];
}
}];
}

- (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
if (NSFileHandlingPanelOKButton == returnCode) {
NSView *docView = [[[webview mainFrame] frameView] documentView];
NSData *pdf = [docView dataWithPDFInsideRect:[docView bounds]];
[pdf writeToURL:[sheet URL] atomically:YES];
}
}

@end

0 comments on commit 719bcfb

Please sign in to comment.