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

8 views (last 30 days)
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 Comments
DGM
DGM on 27 Sep 2025
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.

Sign in to comment.

Answers (1)

Anton Kogios
Anton Kogios on 27 Sep 2025
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

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!