【问题标题】:How to draw horizontal line in fo-block?如何在fo-block中绘制水平线?
【发布时间】:2013-11-29 03:46:53
【问题描述】:

我需要实现下一个布局:

这是我的代码:

<fo:block text-align="center">United Nations Organisation</fo:block>                
<fo:block border-top-style="solid" text-align="center">(organisation)</fo:block>        
<fo:block border-top-style="solid" text-align="center">(department)</fo:block>

但实际上第二条水平线没有画出来。 我怎样才能做到这一点?我做错了什么?

提前致谢!

【问题讨论】:

  • 哪个 FO 处理器?我使用 RenderX 和 FOP 进行了测试,并且都按预期显示了两条水平线。
  • 也和我一起工作。你是用什么和什么距离查看 PDF 的?可能是您的 Adob​​e Reader “增强细线”(菜单选项)导致某些线条在某个缩放级别消失。

标签: xsl-fo


【解决方案1】:

您可以使用fo:leader

<fo:block text-align="center">United Nations Organisation </fo:block>   
<fo:leader leader-pattern="rule" leader-length="100%" rule-style="solid" rule-thickness="2pt"/>             
<fo:block text-align="center" font-size="8pt" margin-top="1mm">(organisation)</fo:block>        
<fo:leader leader-pattern="rule" leader-length="100%" rule-style="solid" rule-thickness="2pt"/>
<fo:block text-align="center" font-size="8pt" margin-top="1mm">(department)</fo:block>

【讨论】:

  • 就我而言,我必须将 标签封装在 中才能正常工作。
【解决方案2】:

您可以使用border-bottom-widthborder-bottom-style

我更改了margin-top 以匹配您的示例。

<fo:block 
  border-bottom-width="2pt" 
  border-bottom-style="solid" 
  border-bottom-color="black" 
  font-weight="bold" 
  text-align="center">
    United Nations Organisation 
</fo:block>            
<fo:block text-align="center" font-size="8pt" margin-top="1mm">
  (organisation)
</fo:block>        
<fo:block border-bottom-width="2pt" border-bottom-style="solid"margin-top="7mm">
</fo:block>
<fo:block text-align="center" font-size="8pt" margin-top="1mm">
  (department)
</fo:block>

希望这会有所帮助。

【讨论】:

  • 如果您的水平线位于页眉/页脚中,这是采用的解决方案。否则,您将收到 "fo:leader" is not a valid child of "fo:static-content"! 错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-11-29
  • 2021-09-24
  • 1970-01-01
  • 1970-01-01
  • 2022-06-30
  • 2015-04-04
  • 2015-09-14
相关资源
最近更新 更多