31

I am using FOP version 1.0 to create PDFs. In one of the pages I'd like to display an image (2552 x 4200 pixel) and scale it down if it doesn't fully fit on the page. As far as I could see on the mailing list the recommended way of doing this would be following:

<fo:external-graphic inline-progression-dimension.maximum="100%" 
                     content-height="scale-down-to-fit" 
                     content-width="scale-down-to-fit" 
                     src="..."/>

Unfortunately, that still doesn't display the whole image. The lower part of the image is cut off. Can anyone give me a hint on what I am potentially doing wrong?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Benjamin Muschko
  • 32,442
  • 9
  • 61
  • 82

2 Answers2

18

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.

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
3

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.

WonderWorker
  • 8,539
  • 4
  • 63
  • 74