Borrar filtros
Borrar filtros

Empty pdf if table is saved as pdf

5 visualizaciones (últimos 30 días)
Chris Pruefert
Chris Pruefert el 7 de Jun. de 2024
Respondida: Milan Bansal el 7 de Jun. de 2024
I am trying save the table t1 by uisng the suggested table-to-figure mathod. However, the saved pdf remains empty.
t1=table(ones(5));
fig = uifigure('Name','Numbers');
t = uitable(fig,'Data',t1);
exportapp(fig,'Peak_assigments.pdf')

Respuestas (2)

Ganapathi Subramanian R
Ganapathi Subramanian R el 7 de Jun. de 2024
Hi Chris,
The following code worked for me in saving the uitable along with its contents as a pdf file.
t1=ones(5);
fig = figure('Name','Numbers');
t = uitable(fig,'Data',t1);
saveas(gcf,'Peak_assignments','pdf')
I hope this helps.
Thanks

Milan Bansal
Milan Bansal el 7 de Jun. de 2024
Hi Chris Pruefert,
I understand that you want to export a table create in MATLAB as a pdf but are facing issues with it.
Instead of using exportapp, you can use the print function and set the format type as "-dpdf". Please refer to the following code snippet for the implementation.
% Sample data for the table
data = {'Apple', 52; 'Banana', 89; 'Cherry', 50};
columnNames = {'Fruthe it', 'Calories'};
% Create the figure
f = figure('Position', [100, 100, 400, 200]);
% Create the table
t = uitable('Parent', f, 'Data', data, 'ColumnName', columnNames, 'Position', [20, 20, 360, 160]);
% Set the figure properties for better output
set(f, 'PaperPositionMode', 'auto');
set(f, 'InvertHardcopy', 'off');
set(f, 'Color', 'w');
% Save the figure as a PDF
print(f, 'table_output', '-dpdf');
Please refer to the following documentation link to learn more about print function.
Hope this helps!

Categorías

Más información sobre Tables en Help Center y File Exchange.

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by