使标题仅与居中表格上的表格一样宽

问题描述

我将 XSL-FO 与 Antennahouse FO 格式化程序一起使用。

如何使 fo:caption 元素中的 fo:table-and-caption 仅与 fo:table 一样宽?

本质上,我正在寻找与此 HTML 等效的 FO:

<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Image with Caption – CENTERED</title>
  </head>
  <body> 
    <div style="border:2px solid blue;">
      <table style="border:1px solid green; margin-left:auto; margin-right:auto;">
        <caption style="caption-side:bottom; text-align:left; border:1px solid red;"><p style="font-size:9pt;">Sourceline (left edge should match up with table's left edge,and line breaking should occur at right edge of table)</p></caption>
        <tr>
          <td><p>&lt;- The table runs only this wide. -></p></td>
        </tr>
      </table>
    </div>
    <p>BLUE = wrapper-DIV</p>
    <p>GREEN = table</p>
    <p>RED = caption</p>
  </body>
</html>

看起来像这样:

HTML rendering of above code

我拥有的 XSL-FO 代码是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:layout-master-set>
    <fo:simple-page-master margin-bottom="58px" margin-left="120px" margin-right="120px" margin-top="50px" master-name="content-page" page-height="11in" page-width="8.5in">
      <fo:region-body margin-bottom="44px" margin-top="50px" region-name="xsl-region-body" />
    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="content-page">
    <fo:flow flow-name="xsl-region-body">

      <fo:block>
        <fo:table-and-caption border="2px solid blue" text-align="center">
        <fo:table-caption border="1px solid red" caption-side="bottom">
          <fo:block font-size="8pt" text-align="left">Sourceline (left edge should match up with table's left edge,and line breaking should occur at right edge of table)</fo:block>
        </fo:table-caption>
        <fo:table border="1px solid green">
          <fo:table-column/>
          <fo:table-body>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>&lt;- The table runs only this wide. -></fo:block>
              </fo:table-cell>
            </fo:table-row>
          </fo:table-body>
        </fo:table>
        </fo:table-and-caption>
      </fo:block>

      <fo:block>BLUE = fo:table-and-caption</fo:block>
      <fo:block>GREEN = fo:table</fo:block>
      <fo:block>RED = fo:caption</fo:block>

    </fo:flow>
  </fo:page-sequence>
</fo:root>

呈现如下:

PDF rendering of above code

我如何强制(在 XSL-FO 中)表格标题仅与表格一样宽(这可能是任意复杂的,包括 fo:table-footer 和表格或单元格上的表格边框),并从其关联表格的左边缘(就像在 HTML 渲染中一样)?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...