Print only UIPanel object to PDF

18 visualizaciones (últimos 30 días)
Austin Burritt
Austin Burritt el 25 de En. de 2022
Respondida: Austin Burritt el 27 de En. de 2022
I have an app that displays multiple figures, and I'd like for the user to be able to print off a page of these figures. exportapp() gets me close, but I'm hoping I can cut out all the extra widgets and buttons that are also on the app and print just the axes to a pdf. Unfortunately none of the print functions seem to interact with UIPanel objects, which is where all my graphs are located. Anyone know how to print just what is shown in a panel to a pdf? Or perhaps another way to group my UIAxes objects so that they print as they are shown in my app?
Thanks for the help as always.

Respuestas (1)

Austin Burritt
Austin Burritt el 27 de En. de 2022
To any who stumble upon the same problem as I did, here was my solution using the getframe function and its rect argument:
pos = app.Panel.Position;
%Changing the height and width ensures that the position arguments are
% within the bounds of the app window, I had issues with the panel position
% showing as out of bounds when calling getframe(). There is probably a
% cleaner way to avoid this issue.
pos(3) = app.UIFigure.Position(3)-pos(1)-1;
pos(4) = min(app.UIFigure.Position(4)-pos(2)-1, pos(4));
printFig = figure(Visible="off");
appFrame = getframe(app.UIFigure, pos);
imshow(appFrame.cdata)
exportgraphics(printFig, filepath)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by