Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scale down to fit an image in FOP

I found this page here explaining how scaling works with XSL-FO.

Essentially, this is the snippet that I used to make it work:

<fo:external-graphic
    src="url('...')"
    width="100%"
    content-height="100%"
    content-width="scale-to-fit"
    scaling="uniform"
    xsl:use-attribute-sets="img"/>

I found that width="100%" was the missing piece in your own attempts. Hope this helps future visitors.


Defining the exact height and width of the "viewport": .

If you don't specify the viewport then FOP won't know what to scale your image to.

It can guess, but not know precisely.