Clear Filters
Clear Filters

How print image to landscape PDF with minimal margins?

32 views (last 30 days)
Hello,
I've read several examples here, but I can't quite get my image to print to PDF with minimal or no margins. I would like to maintain my aspect ratio (from a Canon SLR camera). I would like the page to be landscape orientation 11 inches wide by 8.5 inches tall. My output PDF is landscape, but the margins are too large. My code is below, but it doesn't quite achieve my goal. Thank you for any suggestions, DP
mf=figure;
imshow(thisImg);
set(mf, 'PaperOrientation','landscape');
set(mf, 'PaperUnits','Inches');
set(mf, 'PaperSize',[11 8.5]);
set(mf, 'PaperPosition', [0 0 11 8.5]);
%print('test','-dpdf','-fillpage') %didn't help
print('test','-dpdf')

Accepted Answer

Akshat
Akshat on 2 Oct 2023
Edited: Akshat on 2 Oct 2023
I understand that you want to print image to landscape PDF with minimal margins while maintaining the aspect ratio. As you mentioned, you have already tried using the '-fillpage' option, but it did not help. To address this issue, you can try incorporating the following changes in the code snippet, which sets the 'PaperPositionMode' option for the figure and adjusts the 'Position' attribute for the axes.
mf = figure;
imshow(thisImg);
set(mf, 'PaperOrientation', 'landscape');
set(mf, 'PaperUnits', 'inches');
set(mf, 'PaperSize', [11 8.5]);
set(mf, 'PaperPositionMode', 'manual');
set(mf, 'PaperPosition', [0 0 11 8.5]);
set(gca, 'Position', [0 0 1 1]); % ensure the image fills the entire figure
print('test', '-dpdf', '-r0'); % use '-r0' for maximum resolution
In the above code, '-r0' format option is being leveraged to specify the screen resolution.
Have a look at the below references for better understanding
I hope this helps.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!