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

本文关键字:IPD 一个 最佳 | 更新日期: 2023-09-27 18:01:18

当尝试使用Fo执行渲染时,我得到这个错误(标题)。Net创建PDF时。

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

我发现了另一个关于这个主题的帖子(对于Java而不是c#,因为我正在使用,但我认为这是相同的错误,具有相同的原因):必须在表- XSL-FO Apache FOP上指定最小,最佳或最大IPD中的至少一个。问题是我找不到下面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>

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

我将此标记为回答并参考@lfurini的第一条评论。至于最后一个问题@lfurini,当我认为我已经设置了表宽度时,我正在看错误的表。所以总结一下,如果有人也想知道这个问题;如果在fo:table中设置了宽度,那么在其中一列上设置宽度就足够了,其他列将进行调整。

相关文章: