saving graphic as pdf file not working "out of the box"

조회 수: 8 (최근 30일)
James McDaniel
James McDaniel 2025년 9월 26일
댓글: James McDaniel 2025년 9월 27일
The following code has produced a good output file since pdf was invented. I never had a problem. But the latest version has problems with THE MOST BASIC saving of a figure file.
Here is a MRE:
plot(1:10)
print -dpdf test.pdf
I get this warning:
Warning: The figure is too large for the page and will be cut off. Resize the figure, adjust the output size by setting the figure's
PaperPosition property, use the 'print' command with either the '-bestfit' or '-fillpage' options, or use the 'Best fit' or 'Fill page' options
on the 'Print Preview' window.
> In validate (line 167)
In
print (line 67)
In
test (line 3)
The resulting file is of course a highly clipped verion of the plot I wanted. Please help, this seems like a really basic malfunction of this release. Please do not tell me that I have to custom size each figure until the print command is happy with the size. That would be a lot of iteration on each figure and I make many figures per day.
  댓글 수: 3
DGM
DGM 2025년 9월 27일
Things are slow/dead on the weekend. I'd chime in, but the newest version I run is R2019b. I'm out of the loop.
That said, have you tried using exportgraphics() instead of just using print()? Again, I'm in R2019b, so I can't mess with that either.
There's this current bug in PDF export, but it doesn't appear to be related. There seem to be perennial Mac-related graphics issues that are also foreign to me.

댓글을 달려면 로그인하십시오.

답변 (1개)

Anton Kogios
Anton Kogios 2025년 9월 27일
All of these options work fine for me with no warnings/errors on R2025b using Windows 10:
plot(1:10)
print -dpdf test.pdf
saveas(gcf,'test.pdf')
exportgraphics(gcf,'test.pdf') % cropped

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

제품


릴리스

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by