There are many options to fill the paper size in the printed pdf file:
1. You can change the option "PaperPositionMode" to "auto". This will adjust the size of the printed figure:
h=gcf;
set(h,'PaperPositionMode','auto');
set(h,'PaperOrientation','landscape');
set(h,'Position',[50 50 1200 800]);
print(gcf, '-dpdf', 'test1.pdf')
2. A better solution as changing the "Position" itself would be adjusting the "PaperPosition" to the "PaperSize":
h=gcf;
set(h,'PaperOrientation','landscape');
set(h,'PaperPosition', [1 1 28 19]);
print(gcf, '-dpdf', 'test2.pdf');
Then the option "PaperPositionMode" wouldn't change the appearance even if it is set to "manual".
3. Alternatively you can set "PaperUnits" to "normalized" and "PaperPosition" to "[0 0 1 1]". This will also have the effect of filling the page in the pdf file automatically:
h=gcf;
set(h,'PaperOrientation','landscape');
set(h,'PaperUnits','normalized');
set(h,'PaperPosition', [0 0 1 1]);
print(gcf, '-dpdf', 'test3.pdf');
Best Answer