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

8 次查看(过去 30 天)
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