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 false (or 0) does not scale the image. A setting of true (or 1) scales the image to fit between the margins of the page or within a table entry.

Data Types: logical

Output Arguments

expand all

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

Properties

expand all

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

Tag for the document element, specified as a character vector.

The DOM generates a session-unique tag when it creates the document element. Structure the tag as class:id, where class is the class of the element and id is the value of the Id property. You can specify a tag to replace the generated tag. Specifying your own tag can make it easier to identify where an issue occurred during document generation.

The possible values are:

  • false or 0 — Do not scale image.

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

Data Types: logical

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