PDFView's NSPrintPanel : Determine if Print / Cancel clicked?
PDFView's NSPrintPanel : Determine if Print / Cancel clicked?
- Subject: PDFView's NSPrintPanel : Determine if Print / Cancel clicked?
- From: Wilhelm Phillips <email@hidden>
- Date: Fri, 13 Jun 2008 16:28:02 -0700
Hi Everyone,
Problem:
I'm trying to determine what button a user clicks in PDFViews' print
dialog (i.e. Print, Cancel, etc.) so that I can adjust custom PDFPage
drawing after the page has printed successfully.
Calling [myPDFView printWithInfo:[NSPrintInfo sharedPrintInfo]
autoRotate:YES] provides no way to track the user interaction that
ends the NSPrintPanel.
PDFView's print tasks have no "didRunSelector" like NSOperation, so I
can't find a way to determine whether the user cancelled the dialog or
printed, etc.
Any thoughts?
Attempted alternative solutions:
Since the success of a print task is easy to determine using
NSOperation, I tried creating my own print operation as follows:
NSPrintInfo *myPrintInfo = [[NSPrintInfo sharedPrintInfo]
initWithDictionary:[[NSDictionary alloc] initWithObjectsAndKeys: @"0",
NSPrintBottomMargin, @"0", NSPrintTopMargin, @"0", NSPrintLeftMargin,
@"0", NSPrintRightMargin, NULL ]];
- (void)printDocument:(id)sender {
NSPrintOperation *printOp = [NSPrintOperation
printOperationWithView:[myPDFView documentView]
printInfo:myPrintInfo];
[printOp runOperationModalForWindow:_pdfWindow
delegate:self
didRunSelector:@selector(printOperationDidRun:success:contextInfo:)
contextInfo:NULL];
}
- (void)printOperationDidRun:(NSPrintOperation *)printOperation
success:(BOOL)success
contextInfo:(void *)info {
if (success) {
// Do something here.
}
}
Problems with this solution:
1. Only the visible pages in myPDFView get drawn correctly in the
NSPrintPanel's preview and thus print correctly. The rest are grayed
out.
2. Had to set margins to 0 in NSPrintInfo to preview correctly
3. Also I setDisplaysPageBreaks: to NO for myPDFDocument.
3. Probably missing some custom managing of printing that PDFView
does wonderfully (save not providing print job feedback)
Any ideas?
Thanks,
Will
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden