Question

I am trying to put an image in the left upper corner of the page.

However hard I try, i cannot place the image correctly. There is always ca 1mm space between the image and the top of the page!

The problem seems to be in the placement of the external-graphic. the enclosing block (yellow) is placed correctly but the image is shifted down. you can see this in the pdf, the enclosing yellow block is visible above the gray image!

I tried some combinations of attributes trying to influence the placement of the image (absolute-position, position, space-before) but with no effect.

appreciate your help!

here is how it looks like: boxes.pdf

here is my fo.xml:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:r="http://xml.lazalab.com/reditor" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" language="DE">
 <fo:layout-master-set>
  <fo:simple-page-master  fox:scale="1" fox:crop-offset="5mm" fox:crop-box="media-box" fox:bleed="5mm" margin-right="0mm" margin-left="0mm" margin-bottom="0mm" margin-top="0mm" master-name="MASTERsite1" page-width="214mm" page-height="301mm">
   <fo:region-body background-color="green" margin="0mm"/>
   <fo:region-before background-color="yellow" precedence="true" extent="0mm"/>
   <fo:region-after background-color="cyan" precedence="true" extent="0mm"/>
   <fo:region-start background-color="pink" extent="0mm"/>
   <fo:region-end background-color="gold" extent="0mm"/>
  </fo:simple-page-master>
 </fo:layout-master-set>

 <fo:page-sequence master-reference="MASTERsite1">
  <fo:flow reference-orientation="0" border-collapse="collapse" flow-name="xsl-region-body">         

   <fo:block-container absolute-position="absolute" width="214mm" height="301mm" background-color="cyan">
    <fo:block-container overflow="hidden" width="100mm" height="200mm" background-color="cyan">
        <fo:block  top="0mm" left="0mm" padding="0mm" margin="0mm" background-color="yellow">
            <fo:external-graphic  line-height="0mm" padding="0mm" margin="0mm"  width="100mm" height="200mm" background-color="grey" src="#"/>
        </fo:block>
    </fo:block-container>
   </fo:block-container>

  </fo:flow>
 </fo:page-sequence> 
</fo:root>
Was it helpful?

Solution

Set line-height on the block with the image to "0" and test again. It is likely the image is placed according to the font baseline. As in:

              <fo:block  top="0mm" left="0mm" padding="0mm" margin="0mm" background-color="yellow" line-height="0mm" >
                    <fo:external-graphic  padding="0mm" margin="0mm"  content-width="100mm" height="200mm" background-color="grey" src="test.jpg"/>
                </fo:block>

I tested this with a few formatters and the image goes to the top of the page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top