Why does Word not display Simulink images from Simulink Report Generator?

1 次查看(过去 30 天)
I have followed templates and guides for creating a Simulink Report and found limitations in the formatting with this so have created additional word Macros for resolving the limitations.
However when using my script to create a .pdf file, it looks as expected from the guides but when creating a .docx file all of the images of the systems are labelled "can't be displayed". Does Word have an issue with how the images are added onto it?
In addition when creating the .pdf and using Word's inbuilt converter the images end up altered with grey boxes all over them.
Using MATLAB 2021a and Word 2016 and am on a work system so cannot upgrade Word. Is this a known bug?
  2 个评论
Rahul Singhal
Rahul Singhal 2021-8-4
Hi Gideon,
If you are using slreportgen.report.Diagram reporter to create system snapshots, it creates an SVG image by default. Word provided support for SVG images starting in Word 2016, so I would expect the images to appear. In any case, can you try using any other image format, for e.g. EMF for the Word report.
For more information on this, see SVG support in Word reports.
-Rahul
Gideon Bergbaum
Gideon Bergbaum 2021-8-4
Thanks, very much that has solved the issue.
I'm also using BlockFinders and SystemDiagramFinder which returns DiagramResult. Is there a way of changing the properties of the finder/DiagramResult to achieve this.
Currently I am converting my Diagram Results into Diagrams and then adding in my new Diagrams to the report. It's functional but quite messy.

请先登录,再进行评论。

采纳的回答

Rahul Singhal
Rahul Singhal 2021-8-5
Hi Gideon,
As mentioned in my comments, the Diagram reporter by default creates SVG images. If the Word version being used doesn't support SVG, the reporter can be customized to specify other image file format, like EMF for Word. As you mentioned that you are using SystemDiagramFinder and currently you might be directly adding the returned DiagramResult objects to the report.
You are following the right process in order to customize the default behavior. You need to use the result's getReporter() method to get access to the Diagram reporter object and then use it's SnapshotFormat property to specify the custom snapshot file format. This customized Diagram reporter then can be added to the report. Below is a sample code:
finder = SystemDiagramFinder(model_name);
results = find(finder);
for result = results
% OLD code
% append(rpt,result);
% NEW code
diagReporter = getReporter(result);
diagReporter.SnapshotFormat = "emf";
append(rpt,diagReporter);
end
Thanks,
Rahul

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Report Generator 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by