我正在设计一个可以提供pdf输出的xsl。我的pdf输出是横向格式。 即使我按照以下方式更改简单页面主页,我也无法获得横向格式化输出,
我的pdf输出的高度仍然大于宽度。
嗨mzjn,我没有任何链接。附加了预期和结果的pdf输出, 还需要知道如何使用边框图像。尝试作为区域主体的背景图像并失败。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no"
indent="yes" />
<xsl:param name="versionParam" select="'1.0'" />
<xsl:template match="@*|node()">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- Start of page layout -->
<fo:layout-master-set>
<fo:simple-page-master master-name="A4"
page-width="8.27in" page-height="11.69in" margin-top="5mm"
margin-bottom="5mm" margin-left="5mm" margin-right="5mm"
reference-orientation="90">
<fo:region-body margin-top=".5cm" margin-bottom=".5cm"
margin-left=".5cm" margin-right=".5cm">
<xsl:if test="isPreview='true'">
<xsl:attribute name="background-image">file:///<xsl:value-of
select="pdfimagepath" />Preview Only1.JPG</xsl:attribute>
</xsl:if>
</fo:region-body>
<fo:region-before extent="0mm" />
<fo:region-after extent="0mm" />
</fo:simple-page-master>
</fo:layout-master-set>
<!-- End of page layout -->
<fo:page-sequence master-reference="A4">
<fo:static-content flow-name="xsl-region-before">
<fo:block>
<fo:leader></fo:leader>
</fo:block>
<fo:block text-align="right" font-size="9pt" font-weight="bold">
<xsl:value-of select="num" />
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="9pt" font-family="times" text-align="left">
<xsl:value-of select="xxx" />
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:table table-layout="fixed" width="100%">
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block text-align="center" padding-top="2pt">
<fo:external-graphic content-height="85%"
content-width="65%" scaling="uniform">
<xsl:attribute name="src">
<xsl:value-of select="pdfimagepath" />LogoCert.jpg
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block text-align="center">
<fo:external-graphic content-height="45%"
content-width="55%" scaling="non-uniform">
<xsl:attribute name="src">
<xsl:value-of select="pdfimagepath" />title.jpg
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block font-size="15.5pt" font-family="Arial"
color="Black" text-align="center" padding-before="5pt"
start-indent="10pt">
</fo:block>
<fo:block font-size="15.5pt" font-family="Arial"
color="Black" text-align="center" start-indent="5pt">xxxxxx:
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block font-size="16.5pt" font-family="Arial"
color="red" text-align="center" padding-before="8pt">
<xsl:value-of select="custname" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block font-size="13.5pt" font-family="Arial"
color="black" text-align="center" padding-before="10pt"
start-indent="10pt">
<fo:inline background-color="yellow">xxxx</fo:inline>xxxx
</fo:block>
<fo:block font-size="13.5pt" font-family="Arial"
color="black" text-align="center" start-indent="10pt"> xxxx
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-start="140pt" padding-end="140pt">
<fo:block font-size="10pt" font-family="Arial" color="black"
text-align="center" border-bottom="solid">
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell display-align="after"
padding-after="12pt" padding-before="2pt">
<fo:block font-size="15.5pt" font-family="Arial"
color="black" text-align="center"> xxxx
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-start="160pt" padding-end="160pt">
<fo:block font-size="10pt" font-family="Arial" color="black"
text-align="center" border-bottom="solid">
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-before="2pt"
display-align="before">
<fo:block font-size="15.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-before="10pt">
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center"> xxxx
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-before="5pt"
padding-start="60pt" padding-end="60pt">
<fo:block font-size="20pt" font-family="Arial" color="black"
text-align="center" border-bottom="solid">
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table table-layout="fixed" width="100%">
<fo:table-column column-width="40%" />
<fo:table-column column-width="60%" />
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-before="5pt">
<fo:block font-size="9.5pt" text-align="left"
font-weight="normal">
</fo:block>
</fo:table-cell>
<fo:table-cell padding-before="5pt">
<fo:block font-size="9.5pt" text-align="center">
</fo:block>
<fo:block font-size="9.5pt" text-align="center"
end-indent="10pt">
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table table-layout="fixed" width="100%">
<fo:table-column column-width="50%" />
<fo:table-column column-width="50%" />
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-before="5pt"
display-align="after" border="">
<fo:block font-size="10pt" text-align="left"
font-weight="normal">
</fo:block>
<fo:block font-size="13.5pt" text-align="center"
font-weight="normal">
</fo:block>
</fo:table-cell>
<fo:table-cell padding-before="5pt"
display-align="after" border="">
<fo:block text-align="center">
<fo:external-graphic content-height="60%"
content-width="40%" scaling="uniform">
<xsl:attribute name="src">
<xsl:value-of select="pdfimagepath" />sign.jpg
</xsl:attribute>
</fo:external-graphic>
</fo:block>
<fo:block padding-bottom="1pt" font-size="15pt"
text-align="center" font-weight="bold">
_____________________________
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell display-align="after" border="">
<fo:block font-size="8pt" text-align="left"
font-weight="normal">
</fo:block>
</fo:table-cell>
<fo:table-cell display-align="after" border=""
padding-before="1pt">
<fo:block font-size="8.5pt" text-align="center"
font-weight="normal">xxxxx
</fo:block>
<fo:block font-size="8.5pt" text-align="center"
font-weight="normal">yyyyy
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
附加代码示例
答案 0 :(得分:2)
我正在使用Apache FOP 1.1。首先你应该定义横向布局(A2)。例如
<fo:layout-master-set>
<fo:simple-page-master master-name="A2"
page-height="594mm" page-width="420mm" margin-left="0.2cm"
margin-right="0.2cm">
<fo:region-body margin-top="0.5cm" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A2">
<fo:flow flow-name="xsl-region-body">
**//your design and logic**
</fo:flow>
</fo:page-sequence>
谢谢。
答案 1 :(得分:0)
我不确定如何设置背景,但下面是我如何更改页面宽度和高度以导致横向方向。
我正在编辑DITA开放工具包附带的PDF2的xsl文件。我不确定文件名是否相同,但我在layout-masters-attr.xsl中找到了下面的代码块。注意我切换了页面宽度和页面高度变量。
<xsl-attribute-set name="simple-page-master">
<xsl-attribute name="page-width">
<xsl:value-of select="$page-height"/>
</xsl:attribute>
<xsl:attribute name="page-height">
<xsl:value-of select="$page-width"/>
</xsl:attribute>
</xsl:attribute-set>
这会将整个PDF文档设置为横向模式。此外,您可以找到定义变量的位置,并根据需要将其更改为其他值。