Re: Printing a view + landscape printing
Re: Printing a view + landscape printing
- Subject: Re: Printing a view + landscape printing
- From: Keary Suska <email@hidden>
- Date: Mon, 21 Jan 2013 10:36:10 -0700
On Jan 21, 2013, at 8:17 AM, Jean Suisse wrote:
> I have a non-document based application to which I would like to add printing support.
> The main window (the one in the .xib created by default by Xcode) contains a split view.
>
> Currently, when printing, I get only the left pane of the split view (at best) or the control that has the focus (a textfield for instance) at worse.
This likely has to do with which view is the first responder, and so is receiving a -print: action that has a nil target. Although that is how the menu is wired by default, I rarely find it useful. I generally use a custom method (one not implemented by any NSResponder class), so you can capture the print request.
> What would be the minimum change to perform in order to get the view in the right side of the split view to print itself in landscape (I would like to offer landscape by default to the user) ? I am happy with the rest of the print flow the way it is.
IIRC, unless otherwise specified, all built-in printing methods will use +[NSPrintInfo sharedPrintInfo] to determine page settings. You can customize your own NSPrintInfo and call +setSharedPrintInfo:. Or you can create your own printing session and pass the print info to it.
> P.S.: I saw the Laying Out Page Content section in Printing Programming Guide, but I don't get how it is decided that the content of the view exceeds the size of a single page. I would prefer my view to be told to fit the selected page size (It is possible in my particular situation. I am printing graphics that can be resized to any size, to any ratio).
AFAIK, fit-to-page is not a Cocoa printing system feature. You will have to do that yourself. In theory, the easiest way would be to determine the scaling factor needed and set that in the NSPrintInfo. NSPrintInfo will tell you the paper size and margins, from which you can determine the printable area, then dividing that by the view frame or bounds.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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