使用 apache FOP,想要创建一个 header ,其中 Logo 左对齐,三行地址右对齐,两者都顶部对齐。
如果在流程内部完成,则以下工作正常,但在静态内容标题('xsl-region-before')中它得到左右正确但对齐地址 block 下方的 Logo ,就好像表定义是被完全忽略。
我尝试了其他选项,例如尝试将两者内联或使用 float ,结果相似。标题只是将它们视为单独的 block 并将它们堆叠起来。有人有什么建议吗?
我发现另一个问题询问关于页脚的相同问题,可惜没有回复: Need instream-foreign-object and text to both align to the bottom in XSL-FO
相关片段如下:
<fo:layout-master-set>
<fo:simple-page-master page-height="8.5in" page-width="11in" master-name="only" margin=".5in .5in .5in .5in">
<fo:region-body region-name="xsl-region-body" margin-top="1in" margin-bottom=".5in"/>
<fo:region-before region-name="xsl-region-before"/>
<fo:region-after region-name="xsl-region-after"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="only">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="7pt">
<fo:table width="10in">
<fo:table-column/>
<fo:table-column/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>
<fo:external-graphic src="img/print_logo.png" content-width="2in"/>
</fo:block>
</fo:table-cell>
<fo:table-cell display-align="center">
<fo:block text-align="right">
123 Credibility Street
</fo:block>
<fo:block text-align="right">
Chicago, IL 60606
</fo:block>
<fo:block text-align="right">
312-123-4567
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:static-content>
最佳答案
我设法通过将两个元素放在两个独立的 block 容器中并使用绝对定位来达到预期的效果:
<fo:static-content flow-name="xsl-region-before">
<fo:block-container position="absolute">
<fo:block>
<fo:external-graphic src="img/print_logo.png" content-width="2in"/>
</fo:block>
</fo:block-container>
<fo:block-container position="absolute">
<fo:block text-align="right">
123 Credibility Street
</fo:block>
<fo:block text-align="right">
Chicago, IL 60606
</fo:block>
<fo:block text-align="right">
312-123-4567
</fo:block>
</fo:block-container>
</fo:static-content>
关于static - xsl-fo header - 左侧图像,右侧三行文本,顶部对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3040240/