public static void ResizeToFitContents(IVisio.Page page, Geometry.Size padding) { // first perform the native resizetofit page.ResizeToFitContents(); if ((padding.Width > 0.0) || (padding.Height > 0.0)) { // if there is any additional padding requested // we need to further handle the page // first determine the desired page size including the padding // and set the new size var old_size = VisioAutomation.Pages.PageHelper.GetSize(page); var new_size = old_size + padding.Multiply(2, 2); VisioAutomation.Pages.PageHelper.SetSize(page, new_size); // The page has the correct size, but // the contents will be offset from the correct location page.CenterDrawing(); } }