In an HTML or PDF report, you can specify areas of an image as links. Clicking the link area in an image in an HTML browser opens the target. You can map different areas in an image to different link targets.
Create an mlreportgen.dom.ImageArea
object for each image area
that is to serve as a link. You can specify text to display if the image is not
visible.
You can specify an image area to have one of these shapes:
Rectangle
Circle
Polygon
For details, see mlreportgen.dom.ImageArea
.
Create an mlreportgen.dom.ImageMap
object to associate the link
areas with the image. Append the ImageArea
objects to the
ImageMap
object.
For example, you can create a link from a plot image to documentation about plotting.
import mlreportgen.dom.* d = Document('imageArea','pdf'); open(d); % Set page size to A4 pageSize = d.CurrentPageLayout.PageSize; pageSize.Height = '297mm'; pageSize.Width = '230mm'; % Set margins to 0 pageMargins = d.CurrentPageLayout.PageMargins; pageMargins.Top = '0mm'; pageMargins.Bottom = '0mm'; pageMargins.Left = '0mm'; pageMargins.Right = '0mm'; % Create a plot and save it as an image file x = 0:pi/100:2*pi; y = sin(x); plot(x,y); annotation('textbox', [0.2,0.4,0.1,0.1],... 'string', 'Help on plot function'); saveas(gcf,'plot_img.png'); % Create the DOM image object and append it to your document plot1 = Image('plot_img.png'); append(d,plot1); % Define the area and link target using ImageArea target = ['https://www.mathworks.com/help/matlab/ref/' ... 'plot.html?searchHighlight=plot']; area1 = ImageArea( target, ... 'plot function help',160,340,383,392); % Create the image map object and append the area to it map = ImageMap(); append(map,area1); plot1.Map = map; close(d); rptview(d.OutputPath);