【问题标题】:Text with a background image with FOP带有 FOP 的背景图像的文本
【发布时间】:2015-04-07 09:11:53
【问题描述】:

我正在使用带有 XSL 的 FOP api 来生成 PDF。

我的要求是在背景图片上写一些文字。建议的任何可能方式都会有所帮助。

【问题讨论】:

  • 您应该提供更多详细信息,例如背景全页大小或更小的内容。位置是固定的还是流动的?

标签: xslt xsl-fo apache-fop


【解决方案1】:

您可以使用background-image 属性:

<fo:block background-image="image.png">Lorem ipsum.</fo:block>

您可以使用background-repeatbackground-position-horizontalbackground-position-vertical 控制图像的重复和位置:

<fo:block background-image="image.png" background-repeat="no-repeat">Lorem ipsum.</fo:block>

<fo:block background-image="image.png" background-repeat="no-repeat" background-position-horizontal="center">Lorem ipsum.</fo:block>

【讨论】:

  • 如果答案有用,请考虑 accepting it 作为对未来有类似问题的用户的有用提示;如果没有用,您可以尝试adding some more details to your question 以吸引更好的答案。
  • 这没有帮助,因为 属性“背景图像”不可用。我需要使用最近的罐子吗?这只是一个假设..不确定...
  • @user2498307 您使用的是哪个版本的 FOP?您是否收到警告/错误消息?我尝试了trunk,1.1甚至0.20.5,background-image被正确实现了。
  • @lfurini:- 已经在块中尝试了背景图像.. 但它显示Image Not Found
  • 我在“fo:region-body”标签中使用了你的建议来生成水印效果。它工作完美。非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多