fo:external-graphic has a 'viewport' and a graphical object. The viewport describes the amount of space we want the graphic to use on the page.

Attributes

height / width:

Controls the size of the viewport.

  • auto (default)
    If set to "auto", viewport will expand to fill the containing block. This is annoying if your image content doesn't fill the viewport, because the image will appear centered in the viewport with a lot of space around it. I haven't found a way to control the image's alignment within the viewport.
    To avoid that problem, make the viewport smaller than the content-height and width, then alignment settings of the parent block will affect the image as expected.

content-height / content-width:

Controls the size of the content in the viewport.

Examples

Display image 2" tall, flexible width, center within 4" space if image is propotionally narrower than that.

<fo:external-graphic href="..." height="2in" width="4in" content-height="100%" content-width="resize-to-fit" />