主要内容

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

mlreportgen.dom.ScaleToFit 类

命名空间: mlreportgen.dom

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

描述

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

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

  • 条目 mlreportgen.dom.Height 属性中的 mlreportgen.dom.WidthStyle 对象

  • 父表 Height 属性中的 WidthTableEntriesStyle 对象

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

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

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

创建对象

描述

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

示例

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

输入参量

全部展开

是否将图像缩放以适应页面,指定为逻辑值 1 (true) 或 0 (false)。当您指定:

  • 1 (true) - 将图像缩放以使其适配页边距或表条目。

  • 0 (false) - 请勿缩放图片。

属性

全部展开

是否将图像缩放以适应页面,指定为逻辑值 1 (true) 或 0 (false)。当您指定:

  • 1 (true) - 将图像缩放以使其适配页边距或表条目。

  • 0 (false) - 请勿缩放图片。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: logical

标记,指定为字符向量或字符串标量。DOM API 在创建此对象的过程中生成一个会话唯一标记。生成的标记形式为 CLASS:ID,其中 CLASS 是对象类,ID 是对象的 Id 属性的值。使用此值来帮助确定在文档生成过程中出现的问题的位置。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: char | string

目标标识符,指定为字符向量或字符串标量。DOM API 在创建文档元素对象时会生成一个会话唯一标识符。

属性:

GetAccess
public
SetAccess
public
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 中推出