Contenido principal

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

Whether to scale the image to fit the page, specified as a logical 1 (true) or 0 (false). When you specify:.

  • 1 (true) — Scale the image to fit between the margins or within a table entry.

  • 0 (false) — Do not scale the image.

Properties

expand all

Whether to scale the image to fit the page, specified as a logical 1 (true) or 0 (false). When you specify:.

  • 1 (true) — Scale the image to fit between the margins or within a table entry.

  • 0 (false) — Do not scale the image.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: logical

Tag, 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. Use this value to help identify where an issue occurs during document generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.

Attributes:

GetAccess
public
SetAccess
public
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