必须在表格中指定最小,最佳或最大IPD中的至少一个

时间:2015-07-07 10:20:58

标签: c# xml xslt xsl-fo

我在创建PDF时尝试使用Fo.Net执行渲染时收到此错误(标题)。

    [MethodImpl(MethodImplOptions.Synchronized)]
    public static void MakePdf(XmlDocument xslFoDocument, Stream outputStream)
    {
        FonetDriver driver = PdfPrinterDriver.InitFonetDriver();
        driver.Render(xslFoDocument, outputStream);
    }

我发现了关于这个主题的另一篇文章(对于Java而不是C#,因为我正在使用,但我认为它是相同的错误,原因相同):At least one of minimum, optimum, or maximum IPD must be specified on table - XSL-FO Apache FOP。问题是,我无法在xsl文件中的任何位置找到未设置大小的位置。谁知道可能出错了什么?下面是完整的XSL样式表文件

编辑:进一步故障排除后,我设法本地化表,导致抛出异常。我仍然无法看到我在哪里错过了宣称的大小。

                    <fo:table-column column-width="7cm"/>
                    <xsl:for-each select="$units">
                        <xsl:variable name="bgcolor">
                            <xsl:choose>
                                <xsl:when test="position() mod 2 = 0">white</xsl:when>
                                <xsl:otherwise>#F4F2F0</xsl:otherwise>
                            </xsl:choose>
                        </xsl:variable>
                        <fo:table-column background-color="{$bgcolor}"/>
                    </xsl:for-each>
                    <fo:table-body>

                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>

                                </fo:block>
                            </fo:table-cell>
                            <xsl:for-each select="$units">
                                <fo:table-cell text-align="center">
                                    <xsl:choose>
                                        <xsl:when test="not(contains($hiddenGroups, 'image'))">
                                            <fo:block margin-top="3mm" margin-left="4mm" margin-right="4mm" margin-bottom="-0.8mm">               

                                                <fo:external-graphic content-width="500mm" width="100%" src="{$apiurl}ImageFiles/{Attributes/Attribute[@id='Image']/FileInfo/@id}/Data?apikey={$apikey}"/>                            
                                            </fo:block>
                                            <fo:block background-color="white" font-weight="600" padding-top="2mm" padding-bottom="2mm" margin-left="4mm" margin-right="4mm" margin-bottom="3mm">
                                                <xsl:value-of select="@name"/>
                                            </fo:block>
                                        </xsl:when>
                                        <xsl:otherwise>                                            
                                            <fo:block background-color="white" font-weight="600" padding-top="2mm" padding-bottom="2mm" margin-top="3mm" margin-left="4mm" margin-right="4mm" margin-bottom="3mm">
                                                <xsl:value-of select="@name"/>
                                            </fo:block>    
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </fo:table-cell>
                            </xsl:for-each>
                        </fo:table-row>

                        <xsl:for-each select="$general_attributes">
                            <xsl:variable name="attribute_id" select="@id"/>
                            <xsl:variable name="attribute_type" select="@attributeDefinitionType"/>
                            <xsl:if test="not(contains(@id, 'HIDE_COMP'))">
                                <fo:table-row keep-with-previous="always" border-bottom-style="solid" border-bottom-width="thin" border-bottom-color="#D0D0D0">
                                    <fo:table-cell display-align="center" padding-top="2mm" padding-bottom="2mm">
                                        <fo:block margin-left="2mm" margin-right="2mm">
                                            <xsl:value-of select="@name"/>:
                                        </fo:block>
                                    </fo:table-cell>
                                    <xsl:for-each select="$units">
                                        <fo:table-cell padding-top="2mm" padding-bottom="2mm" padding-left="4mm" padding-right="4mm" display-align="center" border-left-style="solid" border-right-style="solid" border-width="0.1mm" border-color="#D0D0D0">
                                            <xsl:call-template name="show-attribute">
                                                <xsl:with-param name="type" select="$attribute_type"/>
                                                <xsl:with-param name="attribute" select="Attributes/Attribute[@id=$attribute_id]"/>
                                                <xsl:with-param name="count" select="count($units)"/>
                                            </xsl:call-template>
                                        </fo:table-cell>
                                    </xsl:for-each>
                                </fo:table-row>
                            </xsl:if>
                        </xsl:for-each>

                       <xsl:if test="not(contains($hiddenGroups, 'Enkät'))">
                        <xsl:for-each select="$specific_attributes">
                            <xsl:variable name="attribute_id" select="@id"/>
                            <xsl:variable name="attribute_type" select="@attributeDefinitionType"/>

                            <xsl:if test="not(@group = preceding-sibling::*/@group)">
                                <fo:table-row>
                                    <fo:table-cell padding-top="10mm" padding-bottom="5mm" number-columns-spanned="{1 + count($units)}">
                                         <fo:block font-size="13" font-weight="bold" color="white" background-color="#0191ac" padding-top="2mm" padding-bottom="1.5mm" margin-bottom="2mm"> 
                                            <fo:inline padding-left="4mm"><xsl:value-of select="@group"/></fo:inline>                                               
                                        </fo:block>                                           
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:if>
                            <fo:table-row keep-with-previous="always" border-bottom-style="solid" border-bottom-width="thin" border-bottom-color="#D0D0D0">
                                <fo:table-cell display-align="center" padding-top="2mm" padding-bottom="2mm">
                                    <fo:block margin-left="2mm" margin-right="2mm">
                                        <xsl:value-of select="@name"/>
                                    </fo:block>
                                </fo:table-cell>
                                <xsl:for-each select="$units">
                                    <fo:table-cell padding-top="2mm" padding-bottom="2mm" padding-left="4mm" padding-right="4mm" display-align="center" border-left-style="solid" border-right-style="solid" border-width="0.1mm" border-color="#D0D0D0">
                                        <xsl:call-template name="show-attribute">
                                            <xsl:with-param name="type" select="$attribute_type"/>
                                            <xsl:with-param name="attribute" select="Attributes/Attribute[@id=$attribute_id]"/>
                                            <xsl:with-param name="count" select="count($units)"/>
                                        </xsl:call-template>
                                    </fo:table-cell>
                                </xsl:for-each>
                            </fo:table-row>
                        </xsl:for-each>
                       </xsl:if>

                    </fo:table-body>
                </fo:table>

1 个答案:

答案 0 :(得分:1)

我将此标记为对@lfurini的第一条评论的回答和引用。至于最后一个问题@lfurini,当我以为我已经设置了表格宽度时,我正在查看错误的表格。所以总结其他人也对此感到疑惑;如果宽度在fo:table中设置,它足以在其中一列上设置宽度,其余的将调整。