Index: src/document.cpp =================================================================== --- src/document.cpp (revision 19897) +++ src/document.cpp (working copy) @@ -552,10 +552,19 @@ double const h = rect.height(); double const old_height = sp_document_height(this); + double const old_width = sp_document_width(this); + SPRoot *root = SP_ROOT(this->root); SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX)); sp_document_set_width(this, w, &px); sp_document_set_height(this, h, &px); + /* Modify viewbox to fit in with new height/width */ + if (root->viewBox_set){ + root->viewBox.x0 = root->viewBox.x0 * (w / old_width); + root->viewBox.x1 = root->viewBox.x1 * (w / old_width); + root->viewBox.y0 = root->viewBox.y0 * (h / old_height); + root->viewBox.y1 = root->viewBox.y1 * (h / old_height); + } Geom::Translate const tr(Geom::Point(0, (old_height - h)) - to_2geom(rect.min())); SP_GROUP(root)->translateChildItems(tr);