我正在尝试创建示例PDF,我希望实现如下所示的内容[],即我的页面分为两半,一半包含图像(蓝色),仅包含内容在它旁边。但是我的代码正在生成下面显示的内容,即,内容从图片的下方开始,而不是从旁边开始。
下面是我的示例代码:-
<xsl:template match="SAMPLE">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="30cm" page-width="21cm" margin-top="0cm" margin-bottom="0.5cm" margin-left="0.2cm" margin-right="0.2cm">
<fo:region-body column-count="2" column-gap="5mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block-container>
<fo:block margin-left="3.5%" margin-right="3.5%" margin-top="4%" margin-bottom="2%" >
<fo:block margin-left="2cm">
<fo:external-graphic src="D:\PDF\Image1.jpg" width="5cm" height="6cm" scaling="uniform" content-height="scale-to-fit" content-width="scale-to-fit"/>
</fo:block>
<fo:block top="2%" color="#154360" margin-top="4%">
<xsl:value-of select="MyPage/ImageQuote/Quote"/>
</fo:block>
</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
有什么帮助我实现这一目标吗?
答案 0 :(得分:2)
正如凯文所说,目标并不明确。如果要在图像周围传递文本,则需要使用fo:float / @ float =“ start”。这是示例XSL-FO和格式化的图像:
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="30cm" page-width="21cm" margin-top="0.5cm" margin-bottom="0.5cm" margin-left="0.2cm" margin-right="0.2cm">
<fo:region-body column-count="2" column-gap="5mm" border="1pt solid black" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block-container margin-left="3.5%" margin-right="3.5%" margin-top="4%" margin-bottom="2%" >
<fo:block color="#154360" start-indent="0mm" end-indent="0mm">
<fo:float float="start">
<fo:block>
<fo:external-graphic src="Image1.jpg" width="3cm" content-width="scale-to-fit"/>  
</fo:block>
</fo:float>
<fo:block>
Aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa
Aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa
Aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa
Aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa
Aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa
Aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa
Aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaa
</fo:block>
</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
</fo:root>