how to save an image in pdf format without blank space. i,e; size of pdf should be same as the size of the image

62 Ansichten (letzte 30 Tage)
  2 Kommentare
Parveiz Lone
Parveiz Lone am 11 Mär. 2020
above comment ....saveas(gca, 'file.pdf');
could not help me
then i need to save image 'a' as pdf, but size of pdf should be same as size of image.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Parveiz Lone
Parveiz Lone am 25 Nov. 2021
%% This can work good
set(h,'papersize',[5.1 3.2]);

Weitere Antworten (1)

Ameer Hamza
Ameer Hamza am 10 Mär. 2020
Although Friedrich's answer here: provides a clean solution, It still leave some extra white spaces.
I personally prefer to print the file to eps format. It leaves absolutely no extra space
print(gcf, 'filename', '-depsc')
And then export the eps file to pdf using epstopdf (command-line tool available with the installation of latex). If you don't have epstopdf installed, you can use this link: to convert the files to pdf.
The following image shows the difference between both methods. First is according to Friedrich's answer, second, when it is created using the above method.


Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by