Main Content

本页采用了机器翻译。点击此处可查看最新英文版本。

mlreportgen.dom.ScaleToFit 类

命名空间: mlreportgen.dom

缩放图像以适合页面或表条目

描述

指定是否缩放图像以适合 Microsoft® Word 或 PDF 页面的边距或表条目内。

要使用此格式缩放图像以适合表条目,您必须通过以下方式指定条目的高度和宽度:

  • 条目 Style 属性中的 mlreportgen.dom.Heightmlreportgen.dom.Width 对象

  • 父表 TableEntriesStyle 属性中的 HeightWidth 对象

  • 父表或表节的 Style 属性中的 Height 对象

  • 父行的 Style 属性中的 Width 对象

mlreportgen.dom.ScaleToFit 类是一个 handle 类。

创建对象

描述

scaleToFitObj = ScaleToFit 缩放图像以适合页面边缘。

示例

如果值为 true,则 scaleToFitObj = ScaleToFit(value) 缩放图像。

输入参量

全部展开

true(或 1)设置会缩放图像,使其适合页面边缘或表条目的大小。false(或 0)设置不会缩放图像。

属性

全部展开

可能的值包括:

  • true1- 缩放图像以适合边距或表条目。

  • false0 - 不缩放图像。

mlreportgen.dom.ScaleToFit 对象的对象标识符,指定为字符向量或字符串标量。DOM API 在创建文档元素对象时会生成一个会话唯一标识符。您可以为 Id 指定自己的值。

属性:

NonCopyable
true

数据类型: char | string

mlreportgen.dom.ScaleToFit 对象的标签,指定为字符向量或字符串标量。DOM API 在创建此对象的过程中生成一个会话唯一标签。生成的标签形式为 CLASS:ID,其中 CLASS 是对象类,ID 是对象的 Id 属性的值。指定您自己的标签值,以帮助您确定在文档生成过程中出现问题时要查找的位置。

属性:

NonCopyable
true

数据类型: char | string

示例

全部折叠

此示例使用图像的 ScaleToFit 属 性在段落和表条目中插入图像。表条目使用高度和宽度属性。您至少需要条目上的这些属性之一,或者从行,节或父表继承的属性之一。

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

版本历史记录

在 R2014b 中推出