slreportgen.report.ElementDiagram Class
Namespace: slreportgen.report
Superclasses: slreportgen.report.Reporter
Element diagram snapshot and caption reporter
Description
Create a Simulink® or Stateflow® element diagram reporter. When added to a report, the
ElementDiagram reporter creates a snapshot of an element. The reporter adds
the snapshot to the report in the form of an image with a caption. Use the Source property to specify the
desired element.
Note
To use an ElementDiagram reporter in a report, you must create the
report using the slreportgen.report.Report class.
The slreportgen.report.ElementDiagram class is a handle class.
Creation
Description
creates an empty
element diagram reporter. Set its properties to capture a Simulink or Stateflow element snapshot.diagram = ElementDiagram
creates a diagram reporter for an element of a block diagram or chart specified by
diagram = ElementDiagram(source)source. Adding this reporter to a report creates a snapshot of
the diagram of the element and adds the snapshot, with a caption, to the report. The
snapshot image file is stored in the temporary folder of the report. When the report is
closed, the image file is copied into the report and the temporary folder is deleted. To
prevent the deletion, use the Debug property of the report. See
mlreportgen.report.Report.
Input Arguments
See the Source property.
Properties
Diagram element source, specified as one of these values:
Character vector or string scalar that contains the path to a Simulink block or Stateflow chart block
Handle to a Simulink block or Stateflow chart block
Stateflow object
Simulink Identifier (SID) of a block, annotation, or Stateflow object
Note
Simulink.Port objects are not valid sources for this
reporter.
Attributes:
GetAccess | public |
SetAccess | public |
Snapshot reporter, specified as an mlreportgen.report.FormalImage object. Use the properties of the
FormalImage object to specify the caption for the snapshot image
or to customize the size of the image.
Note
The reporter initializes the Snapshot property. Do not clear
or modify this property.
Attributes:
GetAccess | public |
SetAccess | public |
Snapshot image format, specified as one of these formats:
| Import Image Format | File Extension | Supported in HTML | Supported in Word | Supported in PDF | Supported in PDF/A (since R2025a) |
|---|---|---|---|---|---|
| Windows® metafile | .emf | No | Yes | No | No |
| Graphics Interchange Format | .gif | Yes | Yes | Yes | Yes |
| JPEG image | .jpg | Yes | Yes | Yes | No |
.pdf | No | No | Yes | No | |
| PDF/A | .pdf | No | No | Yes | No |
Portable Network Graphics
(.png) | .png | Yes | Yes | Yes | Yes |
| Scalable Vector Graphics | .svg | Yes | Yes | Yes | Yes |
| TIFF image | .tif | No | Yes | Yes | Yes |
Note
Unlike the PDF report output format, the PDF/A format does not support including PDF or PDF/A images. Use one of the image formats listed in the table to include an image in a PDF/A report.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
Resolution of the rasterized diagram snapshot, specified as a positive integer in dots per inch (DPI). The default value of this property is the current DPI resolution of the screen. Higher DPI values increase pixel count and preserve detail when scaling to a target width or height, but also increase memory usage and report size.
Note
Very high DPI can make lines appear too thin. If this occurs, reduce the DPI or increase the line width.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: double
Scaling options for the snapshot image, specified as "auto",
"custom", or "zoom". This property controls
the size of the snapshot image in the image file. Supported scaling options are:
"auto"— For PDF or Word (DOCX) output, use this option to scale the snapshot image to fit the current page layout while maintaining its aspect ratio. First, the reporter scales the snapshot image to the page width. If the image height exceeds the page height, the reporter scales the image down again. This additional scaling ensures that the image fits the current page with an extra one inch spacing. Scaling does not apply to HTML output."custom"— Use this option to scale the snapshot image based on the values of theHeightandWidthproperties."zoom"— Enlarges or reduces the element image size to the percent value specified by theZoomproperty. To specify the maximum image height and maximum image width, use theMaxHeightandMaxWidthproperties, respectively.
Note
The "auto" and "custom" options use the MATLAB®
print command to resize the figure. If the figure is too large to fit
in the specified space, the print command crops the snapshot image. To
avoid cropping, set the Scaling property to "none" and use the reporter specified by the
Snapshot property to size the image. Because the reporter reduces
the size of the text with the rest of the image, fine details may not be legible unless you
zoom the image. See Resize Figure Snapshot Image.
Note
A java.lang.OutOfMemoryError can occur when either of these
combinations of property settings occur:
Scalingset to"zoom", andZoom,MaxHeight, andMaxWidthproperties set to large valuesScalingset to"custom", andHeightandWidthproperties set to large values
To avoid this error, for zoom Scaling, use smaller
Zoom, MaxHeight, and
MaxWidth property values. For Scaling is set
to "custom", use smaller Height and
Width property values.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
Height of the snapshot image, specified as a character vector or string scalar that contains
a number followed by an abbreviation for a unit of measurement. For example, "2in" specifies two inches. The default
snapshot is 6 inches. Valid abbreviations are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
Note
For a PDF image, the size limit is 10000px for width and height. For all other image types, the size limit is the screen size.
Example: "2in"
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
Width of the snapshot image, specified as a character vector or string scalar that contains
a number followed by an abbreviation for a unit of measurement. For example, "2in" specifies two inches. The default
snapshot width is 6.5 inches. Valid abbreviations are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
Note
For a PDF image, the size limit is 10000px for width and height. For all other image types, the size limit is the screen size.
Example: "2in"
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
Amount to zoom the snapshot image, specified as a string. The
Zoom format is "value%",
where value is the percentage by which the snapshot image is enlarged
or reduced.
Example: "100%"
Data Types: char | string
Maximum height for zoom scaling, specified as a character vector or string scalar that contains
a number followed by an abbreviation for a unit of measurement. For example, "10px" specifies 10 pixels. Valid
abbreviations are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
Note
This property applies only if Scaling is set to
"zoom"
Example: "5in"
Data Types: char | string
Maximum width for zoom scaling, specified as a character vector or string scalar that contains
a number followed by an abbreviation for a unit of measurement. For example, "10px" specifies 10 pixels. Valid
abbreviations are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
Note
This property applies only if Scaling is set to
"zoom"
Example: "5in"
Data Types: char | string
Source of the template for this reporter, specified in one of these ways:
Character vector or string scalar that specifies the path of the file that contains the template for this reporter
Reporter or report whose template this reporter uses or whose template library contains the template for this reporter
Document Object Model (DOM) document or document part whose template this reporter uses or whose template library contains the template for this reporter
The specified template must be the same type as the report to which you
append this reporter. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template.
If the TemplateSrc property is empty, this reporter uses the
default reporter template for the output type of the report.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Dependent | true |
Name of the template for this reporter, specified as a character vector or string scalar.
The template for this reporter must be in the template library of the template specified by
the TemplateSrc property of this reporter.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
Hyperlink target for this reporter, specified as a character vector or string scalar
that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A character vector or string scalar
value converts to a LinkTarget object. The link target immediately
precedes the content of this reporter in the output report.
Attributes:
GetAccess | public |
SetAccess | public |
Methods
| Method | Purpose |
|---|---|
getSnapshotImage | Element diagram snapshot image file location |
slreportgen.report.ElementDiagram.createTemplate |
Create reporter template
Input Arguments
Return Values
For more information, see the method
for the |
slreportgen.report.ElementDiagram.customizeReporter |
Create reporter from
Input Arguments
Return Values
For more information, see the method
for the |
slreportgen.report.ElementDiagram.getClassFolder |
Get location of folder that contains
Return Values
For more information, see the method
for the |
copy |
Create copy of reporter object and make deep copies of property values
Input Arguments
Return Values
For more information, see the method
for the |
getImpl |
Get implementation of reporter
Note You cannot add content to the reporter after calling this method. Input Arguments
Return Values
For more information, see the method
for the |
Examples
import slreportgen.report.* import mlreportgen.report.* openExample("f14"); rpt = slreportgen.report.Report("output","pdf"); open(rpt); chap = Chapter(); chap.Title = "Element Diagram Reporter Example"; diag = ElementDiagram("f14/Actuator Model"); diag.Snapshot.Caption = "f14 Simulink Model - Actuator Model block"; add(chap,diag); add(rpt,chap); close(rpt); rptview(rpt);

openExample("f14"); modelsys = "f14/Aircraft Dynamics Model"; rpt = slreportgen.report.Report("output","pdf"); open(rpt) chapter = mlreportgen.report.Chapter(); chapter.Title = "Element Snapshots"; diag = slreportgen.report.ElementDiagram(modelsys); add (chapter,diag) blkfinder = slreportgen.finder.BlockFinder(modelsys); blks = find(blkfinder); for blk = blks blkDiag = slreportgen.report.ElementDiagram... (blk.Object); blkDiag.Snapshot.Caption = strcat(blk.DiagramPath,... "/", blk.Name); add(chapter,blkDiag) % Add diagram element image add(chapter,blk) % Add property table end add(rpt,chapter) close(rpt) rptview(rpt)

Version History
Introduced in R2018bUse the SnapshotResolution property to specify the resolution, in dots
per inch (DPI), for rasterized diagram snapshots.
Report Generator no longer supports BMP (bitmap) as an output image format. This affects
snapshots, images from files, and watermarks in both the Report Explorer and the Report,
DOM, and PPT APIs. See print for more information.
Starting in R2019b, Scalable Vector Graphics (SVG) images are supported for Word reports.
For all report types (HTML, PDF, and Word), the default value of the
SnapshotFormat property is 'svg' and a value of
'auto' indicates 'svg'. In previous releases, the
default value of the SnapshotFormat property was
'auto', which indicated 'svg' for HTML and PDF
reports and 'emf' or 'png' for Word reports, depending
on the platform.
Word reports that contain SVG images require Word 2016 or a later version. In MATLAB R2019b or a later release, to generate a report with images that are
compatible with earlier versions of Word, set the SnapshotFormat
property to a value other than 'svg'. To specify the image format used by
default in earlier releases of MATLAB, set SnapshotFormat to:
"emf"for a Windows platform"png"for a UNIX® or Mac platform
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)