mlreportgen.dom.Image class
Package: mlreportgen.dom
Image to include in report
Description
Use an object of the mlreportgen.dom.Image
class to include an image in
a report.
The mlreportgen.dom.Image
class is a handle
class.
Class Attributes
ConstructOnLoad | true |
HandleCompatible | true |
For information on class attributes, see Class Attributes.
Creation
Description
creates an imageObj
= mlreportgen.dom.Image(imagePath)mlreportgen.dom.Image
object with the Path property set to the
path of an image.
Note
The contents of the specified image file are copied into the output
document when the document is closed. Do not delete or overwrite the
image file before closing the document. If you create an image file and
the corresponding mlreportgen.dom.Image
object in a loop,
for each loop iteration, use a unique file name for the image
file.
Input Arguments
imagePath
— Path of image file
character vector | string scalar
Path of an image file to include in a report, specified as a character vector or string scalar. You can use the image formats in the table.
Image Format | File Extension | Supported Document Type | ||
---|---|---|---|---|
HTML | Word | |||
Windows® bitmap | .bmp | ![]() | ![]() | ![]() |
Windows metafile | .emf | ![]() | ||
Graphics Interchange Format | .gif | ![]() | ![]() | ![]() |
JPEG image | .jpg | ![]() | ![]() | ![]() |
.pdf | ![]() | |||
Portable Network Graphics | .png | ![]() | ![]() | ![]() |
Scalable Vector Graphics | .svg | ![]() | ![]() | ![]() |
TIFF image | .tif | ![]() | ![]() |
Properties
Path
— Path of image file
character vector
Path of the image file, specified as a character vector. This property is read-only.
Height
— Image height
character vector | string scalar
Image height, specified as a character vector or string scalar that
consists of a number followed by an abbreviation for a unit of measurement.
For example, "2in"
specifies two inches. Valid
abbreviations are:
px
— pixels (default)cm
— centimetersin
— inchesmm
— millimeterspc
— picaspt
— points%
— percent
When the Image
object is created, the
Height
property is set to a value based on the
image file specified by the Path
property.
Width
— Image width
character vector | string scalar
Image width, specified as a character vector or string scalar that
consists of a number followed by an abbreviation for a unit of measurement.
For example, "2in"
specifies two inches. Valid
abbreviations are:
px
— pixels (default)cm
— centimetersin
— inchesmm
— millimeterspc
— picaspt
— points%
— percent
When the Image
object is created, the
Width
property is set to a value based on the image
file specified by the Path
property.
Map
— Map of hyperlink areas in image
mlreportgen.dom.ImageMap
object
Map of hyperlink areas in this image, specified as an mlreportgen.dom.ImageMap
object. The Map
property applies to only HTML and PDF
reports.
See Create Image Maps.
StyleName
— Name of image style
character vector | string scalar
Name of image style, specified as a character vector or string scalar. The
StyleName
value must be a style in the style sheet
of the document or document part to which this image is appended. Format
objects in the Style
property of this
Image
object override the style in the style
sheet.
Note
The StyleName
property is ignored for Word
output.
Style
— Formats that define image style
cell array of DOM format objects
Formats that define the style of this image, specified as a cell array of
DOM format objects. The formats override the corresponding formats defined
by the style specified by the StyleName
property. See
Create and Format Images.
CustomAttributes
— Custom attributes of document element
array of mlreportgen.dom.CustomAttribute
objects
Custom attributes of this document element, specified as an array of mlreportgen.dom.CustomAttribute
objects. The custom attributes must be
supported by the output format.
Parent
— Parent of image
document element object
Parent of this image, specified as a document element object. This property is read-only.
Children
— This property is ignored
array of document element objects
This property is ignored.
Tag
— Tag for this document element
character vector | string scalar
Tag for this document element, specified as a character vector or string scalar.
The DOM generates a session-unique tag as part of the creation of this object. The
generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value
of the Id
property of the object. Specifying your own tag value can
help you to identify where an issue occurred during document generation.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char
| string
Id
— ID for this document element
character vector | string scalar
ID for this document element, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char
| string
EmbedSVG
— Whether to embed an SVG file
false (default) | true
Whether to embed an SVG file, specified as true
or
false
. When this property is
false
, the report renders SVG images using CSS. When this
property is set to false
, you cannot search for images.
If true
, the generated HTML report file includes the
generated HTML report file includes a copy of the SVG file. When this
property is true
, you can search for images, but SVG
images that rely on CSS formatting may render incorrectly.
Note
The EmbedSVG
property applies only to HTML
reports.
Methods
Public Methods
Method | Purpose |
---|---|
| Do not use this method. Appending content to an
|
|
To append the same image to different parts
of a document, use the |
Examples
Include Image in a Report
Use an mlreportgen.dom.Image
object to specify an image that you want to include in a report. Include the image in the report by appending the Image
object to the report.
Import the DOM package so that you do not have to use long, fully qualified class names.
import mlreportgen.dom.*
Create a report and add a title for the image using an mlreportgen.dom.Paragraph
object.
d = Document("myImageReport","docx"); p = Paragraph("Plot 1"); p.Bold = true; append(d,p);
Save a plot as an image file.
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y);
saveas(gcf,"myPlot_img.png");
Create an mlreportgen.dom.Image
object that specifies the path of the image file. Specify that the width and height are 4 inches. Append the Image
object to the report.
plot1 = Image("myPlot_img.png"); plot1.Width = "4in"; plot1.Height = "4in"; append(d,plot1);
Close and view the report.
close(d); rptview(d);
Here is the image in the generated report:
Version History
Introduced in R2014bR2019b: SVG image support for Word reports
Starting in R2019b, you can include Scalable Vector Graphics (SVG) images in Word
reports. Word reports that contain SVG images require Microsoft® Word 2016 or a later version. To generate reports with images that are
compatible with earlier versions of Word, create
mlreportgen.dom.Image
objects from images that have a format
other than SVG.
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)