How print image to landscape PDF with minimal margins?

29 vues (au cours des 30 derniers jours)
David W Purcell
David W Purcell le 2 Oct 2023
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')

Réponse acceptée

Akshat
Akshat le 2 Oct 2023
Modifié(e) : Akshat le 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.
  1 commentaire
David W Purcell
David W Purcell le 2 Oct 2023
That did the trick! Thank you very much. :)
DP

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by