フィルターのクリア

How do I export my app to a pdf without clipping?

50 ビュー (過去 30 日間)
David Holmburg
David Holmburg 2024 年 5 月 14 日
編集済み: mala 2024 年 7 月 4 日 12:09
I want to export my app to a pdf report. I am using the code below (straight from the example for "exportapp":
% Button pushed function: ExportDataButton
function ExportDataButtonPushed(app, event)
filter = {'*.jpg';'*.png';'*.tif';'*.pdf'};
[filename,filepath] = uiputfile(filter);
if ischar(filename)
exportapp(app.VisionMetricsUIFigure,[filepath filename]);
end
end
When I choose a file name as an image, everything displays as expected. When I create a pdf, it clips off the right/bottom of the app.
I initially thought it might be related to the app size, so I tried to shrink it to the area that was displayed, but it still clipped in the same area.
Original Size: 952x761
New Size: 876x638
How can I get everything to display when saved as a pdf?

採用された回答

T.Nikhil kumar
T.Nikhil kumar 2024 年 5 月 15 日
編集済み: T.Nikhil kumar 2024 年 5 月 15 日
Hello David,
As per your question, I get that you’re trying to export your app to a pdf file using the ‘exportApp’ function, but some part of the app is clipped off in the generated PDF file.
I too am facing the same issue of clipping while exporting to PDF format with MATLAB R2024a. Though this doesn’t seem to be the case with previous releases of MATLAB since the generated PDF looks fine in MATLAB R2023b.
I would suggest you to try using MATLAB R2023b for this purpose. If not, you can also try the below method as a workaround where you can export the app to an image and convert it to a PDF using MATLAB:
1. Export app to an image format (say PNG)
exportapp(f, 'test.png');
2. Read the image and display it in a figure:
% Create a figure
fig = figure;
% Use imshow to display the image
imshow(imread('test.png'));
% Turn off the axis
axis off;
3. Adjust properties for PDF and specify output path
% Adjust figure properties for PDF output
set(fig, 'Units', 'Inches', 'Position', [0, 0, 8.5, 11], 'PaperPositionMode', 'auto');
% Specify the output PDF file path
outputPDFPath = 'output_path_and_filename.pdf'; % Update this path
4. Use the ‘print’ function to print the figure
% Print the figure to a PDF
print(fig, '-dpdf', outputPDFPath);
% Close the figure
close(fig);
Hope this helps you proceed with your work!
  2 件のコメント
David Holmburg
David Holmburg 2024 年 5 月 15 日
I guess this is a known bug for 2024a. Thanks for your help on the workaround!
mala
mala 2024 年 7 月 4 日 12:08
編集済み: mala 2024 年 7 月 4 日 12:09
but its not working for me can you give a whole code ?

サインインしてコメントする。

その他の回答 (1 件)

Masood Salik
Masood Salik 2024 年 6 月 27 日 19:45
Use this command
print(gcf, '-dpdf', outputPDFPath,'-bestfit');

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by