mlreportgen.dom.ScaleToFit class

Package: mlreportgen.dom
Superclasses:

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 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

Construction

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

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.

Output Arguments

expand all

Scale image to fit page, returned as an mlreportgen.dom.ScaleToFit object.

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.

ID for this document element, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Tag for this document element, specified as a character vector or string scalar.

The DOM 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. Specifying your own tag value can help you to identify where an issue occurred during document generation.

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);