`paper.scaleContentToFit([opt])`

Scale the paper content so that it fits the paper dimensions.

The function accepts an object with additional settings (all optional):

`opt.padding`

– a number or an object of the form`{ top?: [number], right?: [number], bottom?: [number], left?: [number], vertical?: [number], horizontal?: [number] }`

that specifies the width of additional padding that should be added around the resulting (scaled) paper content. Default is`0`

.`opt.preserveAspectRatio`

– should the original aspect ratio of the paper content be preserved in the scaled version? Default is`true`

.`opt.minScaleX`

,`opt.minScaleY`

,`opt.maxScaleX`

,`opt.maxScaleY`

– the minimum and maximum allowed scale factors for both axes.`opt.scaleGrid`

– a number to be used as a rounding factor for the resulting scale. For example, if you pass`0.2`

to this option and the scale factor is calculated as`1.15`

, then the resulting scale factor will be rounded to`1.2`

.`opt.useModelGeometry`

– should paper content bounding box be calculated from cell models instead of views? Default is`false`

. See the documentation of the`paper.getContentBBox`

function for more details.`opt.fittingBBox`

– an object of the form`{ x: [number], y: [number], width: [number], height: [number] }`

is the area of the paper that the content should be scaled to. By default`opt.fittingBBox`

is`{ x: 0, y: 0, width: paper.options.width, height: paper.options.height }`

, i.e. the bounding box of the paper in the paper coordinate system.`opt.contentArea`

– an object of the form`{ x: [number], y: [number], width: [number], height: [number] }`

is the area representing the content in local coordinate system that should be scaled to fit the`opt.fittingBBox`

. By default`opt.contentArea`

is`paper.getContentArea(opt)`

.

The function is illustrated in our paper demo.