Region Printing

I got a request to add in 2 new print buttons to my app. First is Print Selected and 2nd is Print whatever is currently visible. I implemented it by creating a temporary GoView and putting copies of the objects I want to print into it. It seems like my solution is a little overkill, is there a simpler way to accomplish it?
thanks, Jake

“Print whatever is visible” is easy to implement by overriding GoView.ComputeDocumentBounds:
public override RectangleF ComputeDocumentBounds() {
if (this.PrintsOnlyInView) // should be true IFF in your “Print Whatever Is Visible” command
return this.DocExtent;
return base.ComputeDocumentBounds();
You can also set GoView.PrintsViewObjects to true if you want to print selection handles and other objects that belong to the view instead of being part of the document.
“Print Selected” could be done several different ways. I’m not sure what’s best for your application.
You could toggle GoObject.Printable temporarily to false for everything that isn’t selected. Or maybe override GoObject.CanPrint (this is probably less convenient to implement).
Another possibility is to add a GoLayer to your document, move all selected objects into that layer, and make all other layers not Printable. The problem is that you’ll afterwards need to move all those selected objects back into their original layers, which may or may not be trivial in your application.