fop-xsl 中文无法自动换行

没有检索到摘要

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前两天遇到个问题,郁闷了半天。简单的一个table 显示问题

<fo:block font-size="9pt" text-align="left">
      <fo:table width="175mm" table-layout="fixed"  border="solid">
      <fo:table-column column-width="63mm"/>
      <fo:table-column column-width="63mm"/>
      <fo:table-column column-width="63mm"/>
      <fo:table-body>
       <fo:table-row>
        <fo:table-cell  border="solid" text-align="left">
        <fo:block space-before="4mm" font-family="SimSun" start-indent="1mm" text-align="left" > 
        十年續保真智精選定期保險首年免繳附加契約
        </fo:block>
        </fo:table-cell>
        <fo:table-cell  border="solid">
        <fo:block space-before="4mm" font-family="SimSun" start-indent="1mm" text-align="left" > 
        十年續保真智精選定期保險首年免繳附加契約
        </fo:block>
        </fo:table-cell>
        <fo:table-cell  border="solid">
        <fo:block space-before="4mm" font-family="SimSun" start-indent="1mm" text-align="left" > 
        十年續保真智精選定期保險首年免繳附加契約
        </fo:block>
        </fo:table-cell>
       </fo:table-row>
      </fo:table-body>
      </fo:table>
     </fo:block>

生成的数据就是没有换行。

原来是少了一句:

<fo:block language="ZH">

加上后就可以换行了。

内容过长自动换行, <xsl:template match=“TableReport”> <fo:block > <fo:table text-align="left" border-collapse="collapse" letter-spacing="1px" width="100%" border-width="1pt" font-size="2.6mm"> <fo:table-column border-width="0pt" column-width="0.7cm"/> <fo:table-column border-width="0pt" column-width="0.8cm"/> <fo:table-column border-width="0pt" column-width="2.5cm"/> <fo:table-column border-width="0pt" column-width="1.5cm"/> <fo:table-column border-width="0pt" column-width="1cm"/> <fo:table-column border-width="0pt" column-width="1.6cm"/> <fo:table-column border-width="0pt" column-width="1.6cm"/> <fo:table-column border-width="0pt" column-width="3cm"/> <fo:table-column border-width="0pt" column-width="4.7cm"/> <fo:table-column border-width="0pt" column-width="0.8cm"/> <fo:table-column border-width="0pt" column-width="1.1cm"/> <fo:table-header> <fo:table-row height="5mm"> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block text-align="center">序号</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block text-align="center">组织</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block text-align="center">申请单号</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block text-align="center">类型</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block text-align="center">状态</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block text-align="center">工号</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block text-align="center">姓名</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block text-align="center">物料编码</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block text-align="center">物料描述</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block text-align="center">销数</fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block text-align="center">原数量</fo:block> </fo:table-cell> </fo:table-row> </fo:table-header> <!--表明细--> <fo:table-body> <xsl:apply-templates select="TableRow"/> </fo:table-body> </fo:table> </fo:block> <fo:block id="end"/> </xsl:template> <xsl:template match="TableRow"> <fo:table-row height="5mm"> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block><xsl:value-of select="no"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block><xsl:value-of select="orgCode"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style" font-size="2.2mm"> <fo:block><xsl:value-of select="requestNo"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block><xsl:value-of select="noteType"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block><xsl:value-of select="state"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block><xsl:value-of select="empNo"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style" font-size="2.2mm"> <fo:block><xsl:value-of select="empName"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style" font-size="2.2mm"> <fo:block><xsl:value-of select="itemCode"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style" font-size="2.2mm"> <fo:block wrap-option="wrap" language="zh"><xsl:value-of select="itemDesc"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style" font-size="2.2mm"> <fo:block wrap-option="wrap" language="zh"><xsl:value-of select="qty"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block><xsl:value-of select="holdQty"/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template>
08-02
itemCode过长会超出格子并且好像没换行,<xsl:template match="TableRow"> <fo:table-row height="5mm"> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block><xsl:value-of select="no"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block><xsl:value-of select="orgCode"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style" font-size="2.2mm"> <fo:block><xsl:value-of select="requestNo"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block><xsl:value-of select="noteType"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-left-style"> <fo:block><xsl:value-of select="state"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block><xsl:value-of select="empNo"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style" font-size="2.2mm"> <fo:block><xsl:value-of select="empName"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style" font-size="2.2mm"> <fo:block wrap-option="wrap"><xsl:value-of select="itemCode"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style" font-size="2.2mm"> <fo:block wrap-option="wrap" language="zh"><xsl:value-of select="itemDesc"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style" font-size="2.2mm"> <fo:block wrap-option="wrap" language="zh"><xsl:value-of select="qty"/></fo:block> </fo:table-cell> <fo:table-cell xsl:use-attribute-sets="border-cell-style"> <fo:block><xsl:value-of select="holdQty"/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template>
最新发布
08-02
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="w r"> <xsl:output method="xml" indent="yes"/> <!-- 根模板 --> <xsl:template match="/"> <fo:root> <fo:layout-master-set> <fo:simple-page-master master-name="A4" page-width="210mm" page-height="297mm" margin-top="1cm" margin-bottom="1cm" margin-left="2cm" margin-right="2cm"> <fo:region-body margin-top="1cm" margin-bottom="1cm"/> <fo:region-before extent="1cm"/> <fo:region-after extent="1cm"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="A4"> <fo:flow flow-name="xsl-region-body"> <xsl:apply-templates select="//w:body"/> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <!-- 正文处理 --> <xsl:template match="w:body"> <xsl:apply-templates select="*"/> </xsl:template> <!-- 段落处理 --> <xsl:template match="w:p"> <fo:block font-size="12pt" line-height="1.5" space-after="12pt"> <xsl:apply-templates select="w:r"/> </fo:block> </xsl:template> <!-- 文本运行处理 --> <xsl:template match="w:r"> <fo:inline> <xsl:if test="w:rPr/w:b"> <xsl:attribute name="font-weight">bold</xsl:attribute> </xsl:if> <xsl:if test="w:rPr/w:i"> <xsl:attribute name="font-style">italic</xsl:attribute> </xsl:if> <xsl:value-of select="w:t"/> </fo:inline> </xsl:template> <!-- 表格处理 --> <xsl:template match="w:tbl"> <fo:table table-layout="fixed" width="100%"> <xsl:for-each select="w:tblGrid/w:gridCol"> <fo:table-column column-width="{@w:w}dxa"/> </xsl:for-each> <fo:table-body> <xsl:apply-templates select="w:tr"/> </fo:table-body> </fo:table> </xsl:template> <!-- 表格行 --> <xsl:template match="w:tr"> <fo:table-row> <xsl:apply-templates select="w:tc"/> </fo:table-row> </xsl:template> <!-- 单元格 --> <xsl:template match="w:tc"> <fo:table-cell border="1pt solid black" padding="2pt"> <fo:block> <xsl:apply-templates select=".//w:p"/> </fo:block> </fo:table-cell> </xsl:template> <!-- 列表处理 --> <xsl:template match="w:numPr"> <fo:list-block> <xsl:apply-templates select="w:numId"/> </fo:list-block> </xsl:template> </xsl:stylesheet>在这个基础上添加一下对中文字体的支持
03-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值