英文:
How to Insert and adjust over lapping images While Rendering My PDF Using XSLT FOP
问题
我想在我的PDF中显示两张图片,它们将位于相同的位置,重叠在一起;或者说一张图片将成为另一张图片/标志的背景,所以我尝试了下面的代码:
<fo:table table-layout="fixed" width="100%">
<fo:table-column column-width="proportional-column-width(4.5)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell column-number="2">
<fo:block-container background-image="file:///{$Logo}/Image2.png">
<fo:block>
<fo:external-graphic src="file:///{$Logo}/Image1.png" content-height="16mm" content-width="45mm" scaling="non-uniform"/>
</fo:block>
</fo:block-container>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
现在,Image2作为Image1的背景显示出来了,但我需要调整Image2的大小或位置;我可以使用哪些属性?
例如,假设:
- Image2应该显示在中间,即Image1的中心。
- 想要减小Image2的高度和长度。
我该如何做到这些?
我使用的方法是否正确,还是应该使用其他方法?
英文:
I want to display two images at the same position in my pdf where they will be overlapping to each other; or likely one image will be back ground of another image/logo so I tried below code:
<fo:table table-layout="fixed" width="100%">
<fo:table-column column-width="proportional-column-width(4.5)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell column-number="2">
<fo:block-container background-image="file:///{$Logo}/Image2.png">
<fo:block>
<fo:external-graphic src="file:///{$Logo}/Image1.png" content-height="16mm" content-width="45mm" scaling="non-uniform"/>
</fo:block>
</fo:block-container>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
Now that Image2 is coming as back ground for Image1 but I need to resize or fix the position for Image2 ; what all property I can use?
For example lets say
- Image2 should came in the middle/in the center as the Image1 back ground.
- Want to decrease the height and length of Image2.
How i can do all these things?
Is this the correct approach I am using or should I used any other approach ?
答案1
得分: 1
你可以使用 background-position
来定位背景图像(参见 https://www.w3.org/TR/xsl11/#background-position)。
XSL-FO示例集中有一个关于 background-position
的示例(https://www.antennahouse.com/xsl-fo-sample),可在 https://www.antennahouse.com/hubfs/xsl-fo-sample/structure/background-position-1.pdf 获取,但请注意,XSL 1.1 仅允许在另一个长度上使用长度,百分比上使用百分比,以及关键字上使用关键字。
XSL 1.1 没有用于调整背景图像大小的属性。FOP 提供了用于背景图像宽度和高度的扩展属性(参见 https://xmlgraphics.apache.org/fop/2.8/extensions.html#backgroundimages),但我从未尝试过它们。
英文:
You can position the background image using background-position
(see https://www.w3.org/TR/xsl11/#background-position).
There's a background-position
sample from the XSL-FO Samples Collection (https://www.antennahouse.com/xsl-fo-sample) available at https://www.antennahouse.com/hubfs/xsl-fo-sample/structure/background-position-1.pdf, but be aware that XSL 1.1 only allows a length to be used with another length, a percentage to be used with a percentage, and a keyword to be used with a keyword.
XSL 1.1 doesn't have a property for sizing the background image. FOP has extension properties for background image width and height (see https://xmlgraphics.apache.org/fop/2.8/extensions.html#backgroundimages), but I've never tried them.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论