How to export figures as pdf without truncated borders.

163 views (last 30 days)
Update:
There is a solution now since 2019a and Save As will soon behave the same.
After filing a bug report (thanks Alex!) I got the following helpful eMail:
-----------------
Hello Frieder,
I am writing in reference to your Technical Support Case #03813750 regarding 'msaximizing plot in MS Windows and saving as pdf truncates'.
Starting with 19a you can use the axes toolbar for PDF export without cropping.
unnamed.png
I logged an enhancement to make SaveAs behave the same.
Further when using SaveAs you should also get a warning in MATLAB in the case things will get cut off including stating how to workaround:
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.
----------------------
orginal post:
I plot a figure, enlarge it, select File -> Save As and choose pdf as output format and the resulting PDF it is truncated left and right.
I've been using MATLAB for 10 years and this has been a constant annoyance.
Yes, I can use export_fig etc. but such a basic default future being buggy all those years is just frustrating.
In my opinion this needs to be put to the top of Mathworks priority list.

Answers (2)

Alex Pedcenko
Alex Pedcenko on 27 Sep 2019
This seems to happen when you are saving "maximized plot" window to PDF. MATLAB tries to fit figure into portrait page layout (when your figure in maximized window is more like "landscape"-like.
If you want to avoid "trim", make figure window smaller (e.g. "unmaximize" it), then PDF export does not seem to trim it (at least for me, R2017a).
Alex

Luis
Luis on 7 Sep 2020
The following worked for me:
set(gcf,'PaperType','A4')
  3 Comments

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by