Re: Problem printing a window
Re: Problem printing a window
- Subject: Re: Problem printing a window
- From: Rick Hoge <email@hidden>
- Date: Mon, 24 Oct 2005 23:22:33 -0400
Thanks - this got me somewhat further. It still seems odd that a
print: method is provided for NSWindow but it does not actually
work! There are times when I really would like to be able to print
out a screen grab of my window.
...
The portions of the window that are drawing themselves improperly
are probably making the poor assumption that they are rendering to
the screen. They then do something like undo the current context
transform and draw in that coordinate space which doesn't work when
you go to the printer.
Your best bet may be to do something like implement
printOperationWithSettings: on your document and then do something
like (code typed into mail):
- (NSPrintOperation *)printOperationWithSettings:(NSDictionary *)
printSettings error:(NSError **)outError
{
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
// Get the window from the first window controller (presumably
the document has only one window)
NSWindow *window = [[[self windowControllers] objectAtIndex: 1]
window];
NSView *printableView = [window contentView];
// Construct the print operation and setup Print panel
NSPrintOperation *printJob = [ NSPrintOperation
printOperationWithView:
printableView printInfo: printInfo];
return printJob;
}
This will give you only the content area of the window which may,
or may not be what you want. However, I suspect you can't rely on
the Window's structure view to draw itself properly to the printer.
Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden