Why is the image I insert in a MATLAB generated report not centered?

I am trying to insert an image in the center of a page while generating a MATLAB report using the DOM API. But, the image is never centered. How do I go about fixing this issue?

 Accepted Answer

When inserting an image using the DOM API, the 'Image' object is created and is then nested inside a 'Paragraph' object. Since, the 'Paragraph' and 'Report' object properties are different, the image is not centered as the 'Paragraph' object's position is changing.
To resolve this issue, I would recommend using the 'mlreportgen.Report.FormalImage' reporter from the Report API. The following documented example provides an example code to achieve this workflow:
In the example, you can set the 'HAlign' style property to 'center' to center-align an inserted image.

More Answers (0)

Products

Release

R2022a

Community Treasure Hunt

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

Start Hunting!