필터 지우기
필터 지우기

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 CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by