Shrinking document size


How do you reduce the size of a document to fit the right most object and bottom most object. I get a lot of dead space when I manually rearrange the document objects to be closer together. It seems that the original location of the objects is still part of the overall document size. The main reason I want to do this is so that the scrollbars will be in-sync with what the user actually sees.

From the Document Coordinates and Size section of the User Guide.

The normal behavior is that the Size property is increased to accommodate objects that are placed beyond where they had been before. However, the Size property does not automatically shrink—not even when all of the objects in the document are removed and the document is empty. The Size property also always includes the (0, 0) point. If you want to find out how much coordinate space all of a document’s objects are actually taking, use the GoDocument.ComputeBounds method. This method calculates the union of the bounds of all of the document objects for which GoObject.CanView() is true, or for which GoObject.CanPrint() is true when the GoView.IsPrinting property is true. If you want to automatically shrink the document’s extent as objects are moved or removed, you will need to override GoDocument.OnChanged to notice when objects are removed, and override UpdateDocumentBounds to calculate any extent adjustments.

like this:

this.Document.Bounds = this.Document.ComputeBounds();