Based on this question Append image to PDF report , I was wondering is it possible to snapshot the axes in app designer in order to save them in PDF report?
I tried the code below but I get an error
Error:
Undefined function 'getSnapshotImage' for input arguments of type 'matlab.ui.control.UIAxes'.
Code:
function ButtonPushed(app, event)
import mlreportgen.dom.*;
import mlreportgen.report.*
folder = 'E:/';
file = 'shapes2.png'
fullFileName = fullfile(folder, file);
I= imread(fullFileName);
level = graythresh(I);
BW = imbinarize(I,level);
imshow( BW ,'Parent', app.UIAxes)
filter = {'*.pdf'};
[file, pathPDF] = uiputfile([folder,filter{1}])
if file ~= 0
d = Document('myPDF','pdf');
d.OutputPath = [pathPDF,file];
figure = app.UIAxes;
snap = Image(getSnapshotImage(app.UIAxes,d));
img1 = Image(fullFileName);
img1.Style = [img1.Style {ScaleToFit}];
close(d);
end
end