Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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 document element, specified as a character vector.

A session-unique ID is generated as part of document element creation. The generated tag has the form CLASS:ID, where CLASS is the class of the element and ID is the value of the Id property of the object. You can specify a tag to replace the generated tag.

For example, to make it easier to identify where an issue occurred during document generation, you can specify your own tag value.

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

expand 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);
Was this topic helpful?