Empty pdf if table is saved as pdf
5 次查看(过去 30 天)
显示 更早的评论
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')
0 个评论
回答(2 个)
Ganapathi Subramanian R
2024-6-7
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
0 个评论
Milan Bansal
2024-6-7
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!