I have created a GUI with GUIDE, and I would like to let app users print an image of the app with a button. How can I do this?
Prashant Kumar answered .
2025-11-20
f = getframe(gcf); % Get an image of the app in pixel color values
toShow = figure('Visible','off'); % Create a new invisible figure
warning('off','images:initSize:adjustingMag') % Turn off a specific imshow warning that sometimes may appear
imshow(f.cdata); % Display the pixel data.
warning('on','images:initSize:adjustingMag') % Turn the warning back on
set(toShow,'PaperOrientation','landscape',...
'PaperUnits','normalized','PaperPosition',[0,0,1,1]); % Set some size preferences for printing
printdlg(toShow); % Open print menu
close(toShow) % Close the invisible figure