SAVE2PDF saves a figure as a PDF as it appears on the screen. SAVE2PDF is stand-alone and simple--it does not require a separate installation of ghostscript. It saves figures as they appear on the screen, with the correct page size. It has the option to change the resolution to be print-quality.
SAVE2PDF is particularly useful for LaTex users who want to generate PDFs to include when compiling with pdftex. The vector art information is preserved.
This function simply augments the built in print-to-pdf functionality of Matlab by resizing the output PDF and shifting the displayed plot.
Gabe Hoffmann (2021). save2pdf (https://www.mathworks.com/matlabcentral/fileexchange/16179-save2pdf), MATLAB Central File Exchange. Retrieved .
What I was looking for... direct for Latex
It's very helpful , Thanks
It is what I'm looking for. Very helpful! Thank you.
Never mind my previous rating, I used the wrong renderer :)
Does not save pdfs with transparency and vectors, like the built-in export to pdf so no reason to use this.
good to convert to pdf file
That's absolutely amazing. I've searched on the web for a long time before I found this one. Solve my problem perfectly.
Great function, finally found what I needed.
Any ideas to make it work with bode plots as well. Presently, the x axis labels get messed up.
Great tool, easy to use, does the job!
Hello, I am new in this type of graphs. This code did not work in my graph. I have the next error message:
Error using validateHandleToPrint (line 36)
Can only print one page at a time.
Error in validate (line 17)
pj = validateHandleToPrint(pj);
Error in print (line 201)
pj = validate( pj );
Error in save2pdf (line 60)
Somebody can help me, pleaseeeeeeee
Love the program, but came across a bug, at least on my machine. Don't seem to be able to upload a pdf file, but hopefully if you run the code below you'll see the problem. In the title for the first subplot, save2pdf throws in a space that's not present in either the matlab figure or the pdf generated by matlab's print function. In the second and third subplot the modified titles don't have the same problem. Really wierd!
sig = 0;
saveTitle = 'save2pdfBug.pdf';
Title=['Word s_j=' num2str(sig) ];
Title=['Word s=' num2str(sig) ];
Title=['s=' num2str(sig) ];
This is amazing! I've been waiting my whole Matlab life for this. Saving to a pdf in Matlab is normally rife with difficulties, and this makes the process very simple.
Very handy function, thanks. Just a suggestion: force the 'paperOrientation' property to 'landscape' (that is usually the default); if it has been changed to 'landscape', the function will not produce the expected output.
really nice function, saves a lot of trouble, thanks
Excellent! One of the best utility I found on this forum.
Really helps when exporting a figure with transparency to PDF.
Great, I was able to adapt to other extension, i.e. pdf, eps ...
Thank you very much, searched in so many forums to solve exactly this problem!
Very good !
Great Job. Works a charm -- has probably saved me several hours of frustration.
Easy to use and 100% useful for Latex users.
I have got one question regarding dimensions of the saved file.
When I set figure position / size with:
set(gcf, 'Position', [400 400 600 100])
and then apply:
The dimensions of the image will be 450x75
Same with other values of width & height... al get resized to 75%
Does anybody know why this happens?
Great function, provided perfect solution first time around!
Excellent. Just what I was looking for.
Works good and helps a lot with mass-pdf-graph-generation ... pdf2ps in linux doesn't generate vectorized .ps from these pdfs, but that's not Gabe's fault.
Great stuff - just what I needed. Thanks!
Works great and I don't have to manually crop the pdfs.
The only problem I have is that the legend output is different whether you use the command line 'print' or select "save as" from the figure menu. Using 'print', the legend background color is lost and the black outline shows up even when set to white. However, this is a matlab bug, not this code's problem.
Nice and does what it says. But what I'm really interested in is how to save multiple figures to a multi-page pdf without ghostscript. Any thoughts?
Inspired: Equilibria of economical models with cost of change, Simulation of von Kármán viscoelastic plates, Save figures Shortcut, saveas2.m v1.1 (Sep 2009), Modeling and Design Analysis of a Permanent Magnet Linear Synchronous Generator
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!