【问题标题】:xsl-fo absolute placement of imagesxsl-fo 图像的绝对位置
【发布时间】:2013-12-27 22:28:28
【问题描述】:

我正在尝试将图像放在页面的左上角。

无论我多么努力,我都无法正确放置图像。图片和页面顶部之间总是有 ca 1mm 的空间!

问题似乎出在外部图形的位置上。封闭块(黄色)放置正确,但图像向下移动。您可以在 pdf 中看到这一点,封闭的黄色块在灰色图像上方可见!

我尝试了一些属性组合,试图影响图像的位置(绝对位置、位置、前空间),但没有效果。

感谢您的帮助!

它是这样的: boxes.pdf

这是我的 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>

【问题讨论】:

    标签: pdf-generation css-position block xsl-fo apache-fop


    【解决方案1】:

    将带有图像的块的行高设置为“0”并再次测试。很可能图像是根据字体基线放置的。如:

                  <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>
    

    我用一些格式化程序对此进行了测试,图像显示在页面顶部。

    【讨论】:

    • 这几乎解决了问题;我添加了 font-size="0pt" 现在它可以完美运行了。
    • @orang:如果这个答案对您有帮助(即如果它让您走上正轨),请考虑接受这个答案 - 在左侧打勾。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多