XSL-FO table center

只谈情不闲聊 提交于 2020-01-03 15:40:10

问题


currently I am working on the XSL-FO for generating the PDF files. Infact I am directly writing the FO object instead of separating the XML and XSL. That is our requirement currently. We are able to align the text properly. But, when we are making the table, while keeping it in center not showing the complete table. What could be the problem. Here I am posting the code I have tried:

<fo:block>
            <fo:table width="80%"
                border-style="solid"
                border-width="1pt"
                border-color="#69468D"
                table-layout="fixed"
                space-before="10px"
                space-after="10px"
                text-align="start">
                <fo:table-header line-height="10pt"
                    font-size="6pt"
                    background-color="#69468D"
                    color="white"
                    padding-top="3pt">
                    <fo:table-row>
                        <fo:table-cell border-top-color="solid pruple" border-left-color="solid pruple" border="1pt solid white">
                            <fo:block>text</fo:block>
                        </fo:table-cell>
                        <fo:table-cell border="0.5pt solid pruple" padding="4pt">
                            <fo:block>text</fo:block>
                        </fo:table-cell>
                        <fo:table-cell border="0.5pt solid pruple" padding="4pt">
                            <fo:block>text</fo:block>
                        </fo:table-cell>
                        <fo:table-cell border="0.5pt solid pruple" padding="4pt">
                            <fo:block>text</fo:block>
                        </fo:table-cell>
                        <fo:table-cell border="0.5pt solid pruple" padding="4pt">
                            <fo:block>text</fo:block>
                        </fo:table-cell>
                        <fo:table-cell border="0.5pt solid pruple" padding="4pt">
                            <fo:block>Text</fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                </fo:table-header>
                <fo:table-body line-height="5pt"
                    font-size="6pt">
                    <fo:table-row padding-top="3pt">
                        <fo:table-cell text-align="center">
                            <fo:block> 
                                hi
                            </fo:block>
                        </fo:table-cell>
                        <fo:table-cell text-align="center">
                            <fo:block> 
                            hi
                            </fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                </fo:table-body>
            </fo:table>
        </fo:block>

回答1:


I believe that the solution would be absolute measurements instead of percentage.




回答2:


If we have five columns then we can center table as follows

<fo:table width="100%">
    <fo:table-column column-width="20%"/>
    <fo:table-column column-width="20%"/>
    <fo:table-column column-width="20%"/>
    <fo:table-column column-width="20%"/>
    <fo:table-column column-width="20%"/>
</fo:table>


来源:https://stackoverflow.com/questions/12119172/xsl-fo-table-center

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!