Main Content

mlreportgen.dom.ScaleToFit Class

Namespace: mlreportgen.dom

Scale image to fit page or table entry

Description

Specifies whether to scale an image to fit between the margins of a Microsoft® Word or PDF page or within a table entry.

To use this format to scale an image to fit a table entry, you must specify the entry height and width by including either:

  • An mlreportgen.dom.Height or mlreportgen.dom.Width object in the entry Style property

  • A Height or Width object in the parent table TableEntriesStyle property

  • A Height object in the Style property of the parent table or table section

  • A Width object in the Style property of the parent row

The mlreportgen.dom.ScaleToFit class is a handle class.

Creation

Description

scaleToFitObj = ScaleToFit scales an image to fit between the margins of a page.

example

scaleToFitObj = ScaleToFit(value) scales an image if value is true.

Input Arguments

expand all

A setting of true (or 1) scales the image to fit between the margins of the page or within a table entry. A setting of false (or 0) does not scale the image.

Properties

expand all

The possible values are:

  • true or 1— Scale image to fit between the margins or in table entry.

  • false or 0 — Do not scale image.

Object identifier for the mlreportgen.dom.ScaleToFit object, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for the mlreportgen.dom.ScaleToFit object, specified as a character vector or string scalar. The DOM API generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

Examples

collapse all

This example inserts an image in a paragraph and in a table entry using the ScaleToFit property on the image. The table entry uses a Height and Width property. You need at least one of these properties on the entry or inherited from the row, section, or parent table.

import mlreportgen.dom.*

d = Document('Scale to Fit Example','pdf');
open(d);

% Insert explanatory text in report
p = Paragraph(['Set the image style to ScaletoFit with ',...
     'img.Style = {ScaleToFit(true)}']);
append(d,p);

% Create the image object and set ScaleToFit property
img = Image(which('ngc6543a.jpg'));
img.Style = {ScaleToFit};
append(d,img);

% Explanatory text
p = Paragraph(['Scale image to fit the table cell, Set the ',...
    'height and width on the table with:']);
p.Style = {PageBreakBefore};
append(d,p);

% Create the table, setting height and width
% Create the image object and set ScaleToFit property
append(d,'table.entry(1,1).Style = {Height(''1in''), Width(''1in'')}');
img = Image(which('ngc6543a.jpg'));
img.Style = {ScaleToFit};
table = Table({img, Paragraph('Entry 2')});
table.Border = 'solid';
table.Width = '2in';
table.entry(1,1).Style = {Height('1in'), Width('1in')};
table.entry(1,2).Border = 'solid';
append(d,table);

close(d);
rptview(d.OutputPath);

Version History

Introduced in R2014b