How print image to landscape PDF with minimal margins?

31 ビュー (過去 30 日間)
David W Purcell
David W Purcell 2023 年 10 月 2 日
コメント済み: David W Purcell 2023 年 10 月 2 日
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')

採用された回答

Akshat
Akshat 2023 年 10 月 2 日
編集済み: Akshat 2023 年 10 月 2 日
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 件のコメント
David W Purcell
David W Purcell 2023 年 10 月 2 日
That did the trick! Thank you very much. :)
DP

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by