mlreportgen.report.FormalImage 类
命名空间: mlreportgen.report
超类: mlreportgen.report.Reporter
带题注的图像报告器
描述
为带有题注的图像创建报告器。
mlreportgen.report.FormalImage
类是一个 handle
类。
创建对象
描述
输入参量
要添加到报告中的图像源,指定为字符串或字符向量,或 DOM 图像对象。查看 Image
属性。
属性
要添加到报告中的图像源,指定为字符数组、字符串标量或 DOM 图像对象。如果使用字符串或字符数组,请指定图像文件的系统路径。
支持的图像格式有:
导入图像格式 | 支持 HTML | 支持 Word | 支持 PDF | 支持 PDF/A 格式 (自 R2025a 起) |
---|---|---|---|---|
Windows® 元文件 (.emf ) | 否 | 是 | 否 | 否 |
图形交换格式 (.gif ) | 是 | 是 | 是 | 是 |
JPEG 图片 (.jpg ) | 是 | 是 | 是 | 否 |
PDF (.pdf ) | 否 | 否 | 是 | 否 |
PDF/A (.pdf ) | 否 | 否 | 是 | 否 |
便携式网络图 (.png ) | 是 | 是 | 是 | 是 |
可缩放矢量图 (.svg ) | 是 | 是 | 是 | 是 |
TIFF 图片 (.tif ) | 否 | 是 | 是 | 是 |
注意
与 PDF 报告输出格式不同,PDF/A 格式不支持包含 PDF 或 PDF/A 图像。使用表中列出的图像格式之一将图像插入 PDF/A 报告。
该报告器将指定的图像插入到由报告器的模板指定的样式的段落中。段落样式决定图像相对于其题注的对齐方式和间距。要自定义对齐方式和间距,请为报告器自定义模板库中的 FormalImage
模板。
属性:
GetAccess | public |
SetAccess | public |
此正式图像的题注,指定为以下值之一:
字符串或字符向量
DOM 对象
1×N 或 N×1 字符串或 DOM 对象数组
由字符串、字符向量和/或 DOM 对象组成的 1×N 或 N×1 元胞数组
getCaptionReporter
方法返回的空位报告器
题注自动编号并位于图像下方。
内联内容是段落可以包含的内容。如果题注值是内联内容,报告器会使用存储在其模板库中的模板来格式化题注。模板使用取决于图像是位于编号章节还是未编号章节的格式自动对题注进行编号。
编号章节中的图像的标题文本前缀为
"Figure N.M"
,其中 N 为章节编号,M 为该章节中的图窗编号。例如,报告第二章第三幅图的前缀是图 2.3。未编号章节中的图像的标题文本前缀为
"Figure N"
,其中 N 代表报告中的第一张图像为 1,第二张图像为 2,以此类推。
在许多非英语地区,题注前缀会被翻译为该地区的语言和格式。请参阅 mlreportgen.report.Report
的 Locale 属性以获取翻译语言环境的列表。
属性:
GetAccess | public |
SetAccess | public |
数据类型: char
| string
此图像的宽度,指定为字符向量或字符串标量,包含一个数字后跟一个测量单位的缩写。例如,"10px"
指定 10 像素。有效的缩写是:
px
- 像素cm
- 厘米in
- 英寸mm
- 毫米pc
- 派卡pt
- 磅%
- 百分比
如果设置了图像宽度,但没有设置高度,则会缩放高度以保持图像的纵横比。
注意
此属性仅适用于您以图像路径指定其源的正式图像。
示例: 5in
属性:
GetAccess | public |
SetAccess | public |
数据类型: char
| string
此图像的高度,指定为字符向量或字符串标量,其中包含一个数字,后跟一个测量单位的缩写。例如,"10px"
指定 10 像素。有效的缩写是:
px
- 像素cm
- 厘米in
- 英寸mm
- 毫米pc
- 派卡pt
- 磅%
- 百分比
如果设置了图像高度,但没有设置宽度,则宽度会缩放以保持图像的纵横比。
注意
此属性仅适用于您以图像路径指定其源的正式图像。
属性:
GetAccess | public |
SetAccess | public |
数据类型: char
| string
是否缩放此正式图像,指定为逻辑值。此属性指定是否缩放图像以适合 Microsoft® Word 或 PDF 页面或表条目的边距。
属性:
GetAccess | public |
SetAccess | public |
数据类型: logical
此图像中的超链接区域图,指定为 mlreportgen.dom.ImageMap
对象。Map
属性仅适用于 HTML 和 PDF 报告。
请参阅创建图像映射。
属性:
GetAccess | public |
SetAccess | public |
数据类型: char
| string
该报告器的模板来源,以下列方式之一指定:
字符向量或字符串标量,指定包含此报告器模板的文件的路径
此报告器使用的模板或其模板库中包含此报告器模板的报告器或报告
文档对象模型 (DOM) 文档或文档部分,该报告器使用其模板或其模板库包含该报告器的模板
指定的模板必须与您附加此报告器的报告类型相同。例如,对于 Microsoft Word 报告,TemplateSrc
必须是 Word 报告模板。如果 TemplateSrc
属性为空,则此报告器将使用默认报告器模板作为报告的输出类型。
属性:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
此报告器的模板名称,指定为字符向量或字符串标量。该报告器的模板必须位于该报告器的 TemplateSrc
属性指定的模板的模板库中。
属性:
GetAccess | public |
SetAccess | public |
数据类型: char
| string
此报告器的超链接目标,指定为指定链接目标 ID 的字符向量或字符串标量,或 mlreportgen.dom.LinkTarget
对象。字符向量或字符串标量值转换为 LinkTarget
对象。链接目标在输出报告中紧接着此报告器的内容。
属性:
GetAccess | public |
SetAccess | public |
方法
方法 | 用途 |
---|---|
getImageReporter | 获取正式图像报告器 |
getCaptionReporter | 获取图像标题报告器 |
mlreportgen.report.FormalImage.createTemplate |
创建报告器模板 输入参量
返回值
有关更多信息,请参阅 |
mlreportgen.report.FormalImage.customizeReporter |
创建源自 返回值
有关更多信息,请参阅 |
mlreportgen.report.FormalImage.getClassFolder |
获取包含 返回值
有关更多信息,请参阅 |
copy | 创建报告器对象的副本,并对某些属性值进行深度复制 |
getImpl | 获取报告器的实现 |
示例
向报告中添加一个空的图像报告器,然后设置其来源、题注和高度。
import mlreportgen.report.* rpt = mlreportgen.report.Report('output','pdf'); chapter = mlreportgen.report.Chapter(); chapter.Title = 'Formal Image Reporter Example'; image = mlreportgen.report.FormalImage(); image.Image = which('ngc6543a.jpg'); image.Caption = 'Cat''s Eye Nebula or NGC 6543'; image.Height = '5in'; add(chapter,image); add(rpt,chapter); rptview(rpt);
向报告中添加图像。使用默认格式,但将题注的文本颜色更改为红色。
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report('output','pdf'); chapter = Chapter(); chapter.Title = 'Formal Image Reporter Example'; image = FormalImage(); image.Image = which('ngc6543a.jpg'); text = Text('Cat''s Eye Nebula or NGC 6543'); text.Color = 'red'; image.Caption = text; add(chapter,image); add(rpt,chapter); rptview(rpt);
向报告添加图像并覆盖其对齐方式、题注字体和边距。
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report('output','pdf'); chapter = Chapter(); chapter.Title = 'Formal Image Reporter Example'; image = FormalImage(); image.Image = which('ngc6543a.jpg'); image.Height = '5in'; para = Paragraph('System Design Description'); para.Style = {HAlign('left'),FontFamily('Arial'),... FontSize('12pt'),Color('white'),... BackgroundColor('blue'), ... OuterMargin('0in', '0in','.5in','1in')}; image.Caption = para; add(chapter,image); add(rpt,chapter); rptview(rpt);
创建一个在左上角定义图像区域的图像映射,并将该图像添加到报告中。如果您点击图像区域,它会显示与该区域相关的网页。
import mlreportgen.report.*; rpt = Report('test','pdf'); image = FormalImage(which('ngc6543a.jpg')); area = mlreportgen.dom.ImageArea('https://www.google.com',... 'Google',0,0,100,100); map = mlreportgen.dom.ImageMap; append(map,area); image.Map = map; add(rpt,image); close(rpt); rptview(rpt);
版本历史记录
在 R2017b 中推出MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)