[pdftex] Autoscaling included images

Jens-Uwe Morawski morawski at gmx.net
Thu Dec 13 12:46:57 CET 2001

On Tue, 11 Dec 2001 10:46:50 -0500 (EST)
Jona Aron Andersen <janders at deas.harvard.edu> wrote:

> When including an image in PDFTeX it occasionally happens that the image
> I'm trying to include is larger than the page, and thus overruns the
> margins.
> What I would like (PDF)TeX to do in case the image is too large, is scale
> the image so that it will fit on the page.

Maybe following can help you:



% set this lengths to required maximum values

% use \FitGraphics{<filename>} instead of
% \includegraphics{<filename>}
	\ifthenelse{\lengthtest{\maxWidth < \hasWidth}\or%
		    \lengthtest{\maxHeight < \hasHeight}}%
		 \ifthenelse{\lengthtest{\hasWidth < \hasHeight}}%

% an example how to use the macro \FitGraphics;
% replace "test" with a filename of an existing graphic
% and play with the lengths \maxHeight and \maxWidth

More information about the pdftex mailing list