Как выровнять 2 блока по вертикали с помощью лидеров

Мне нужно использовать fo:leader для создания таблицы с запросами и ответами, подобными этим:

Таблица лидеров, как это

Однако конечный результат таков:

Оба блока выравнивают сверху

Моя проблема в том, что когда левый блок имеет 2 строки, а правый блок имеет 2 строки, обе они выровнены сверху. Мне нужно выровнять левый блок сверху и правый блок снизу.

Это возможно?

Следуйте по обычному коду:

<fo:inline-container vertical-align="top" inline-progression-dimension="60%">
<fo:block start-indent="0.5em" text-indent="-0.5em" text-align-last="justify" margin-right="0.3cm"<xsl:value-of select="challenge/para|limitdesc/para|sopitem/para"/>
<fo:leader leader-pattern="dots"/</fo:block>
</fo:inline-container>
<fo:inline-container relative-position="relative" vertical-align="bottom" display-align="after" inline-progression-dimension="40%">
<fo:block start-indent="0.5em" text-indent="-0.5em" display-align="after"><xsl:value-of select="response/para|limitvalue/para|limittext/para|act/para"/></fo:block>
</fo:inline-container>

2 ответа

Решение

Я попытался использовать AH Formatter и нашел два решения.

[1] Использование baseline-shift для последнего fo:inline-container

<fo:block>
    <fo:inline-container vertical-align="top" inline-progression-dimension="60%">
        <fo:block start-indent="0.5em" text-indent="-0.5em" text-align-last="justify">
            [1] Text here text here text here text here text here text here text here
            <fo:leader leader-pattern="dots"/></fo:block></fo:inline-container><fo:inline-container baseline-shift="-1.44em" inline-progression-dimension="40%">
        <fo:block start-indent="0.5em" text-indent="-0.5em" display-align="after">
            Continued text here text here text here text here
        </fo:block>
    </fo:inline-container>
</fo:block>

Я указываю `baseline-shift="-1.44em". (Это зависит от используемого шрифта). Этот метод работает только тогда, когда счетчик первой строки равен 2.

[2] Использование fo:table вместо fo:inline-container

<fo:table width="100%">
    <fo:table-column column-number="1" column-width="60%"/>
    <fo:table-column column-number="2" column-width="40%"/>
    <fo:table-body>
        <fo:table-row>
            <fo:table-cell>
                <fo:block start-indent="0.5em" text-indent="-0.5em" text-align-last="justify">
                    [2] Text here text here text here text here text here text here text here
                    <fo:leader leader-pattern="dots"/></fo:block>
            </fo:table-cell>
            <fo:table-cell/>
        </fo:table-row>
        <fo:table-row>
            <fo:table-cell/>
            <fo:table-cell padding-before="-1.32em">
                <fo:block start-indent="0.5em" text-indent="-0.5em" display-align="after">
                    Continued text here text here text here text here
                </fo:block>
            </fo:table-cell>
        </fo:table-row>
    </fo:table-body>
</fo:table>

Этот метод не зависит от текстовых строк в первом fo:table-cell,

Два результата форматирования с использованием AH Formatter GUI:

Результат форматирования в графическом интерфейсе AH Formatter

Моя версия Formatter - 6.4. Но результат будет таким же.

Развивая ответ @tmakita, вы можете использовать alignment-baseline выровнять базовые линии двух fo:inline-container (см. обсуждение на https://www.w3.org/TR/xsl11/).

Ты можешь использовать last-line-end-indent (см. https://www.w3.org/TR/xsl11/), чтобы проект лидера заканчивался после конца текста, но вам также необходимо ограничить ширину текста. В этом примере я использовал fo:block-container внутри первого fo:inline-container:

<fo:block>
    <fo:inline-container vertical-align="top" inline-progression-dimension="60%" alignment-baseline="text-after-edge">
        <fo:block-container width="50%">
            <fo:block start-indent="0.5em" text-indent="-0.5em" text-align-last="justify" last-line-end-indent="-100%">
            [3] Text here text here text here text here text here text here text here text here text here text here text here text here text here Text here text here text here text here text here text here text here<fo:leader leader-pattern="dots" leader-length.minimum="50%" leader-length.optimum="50%"/></fo:block>
        </fo:block-container>
    </fo:inline-container><fo:inline-container inline-progression-dimension="40%">
                <fo:block start-indent="0.5em" text-indent="-0.5em">
                    Continued text here text here text here text here
                </fo:block>
            </fo:inline-container>
</fo:block>

Если вы не хотите, чтобы текст в последней строке мог выходить за рамки остальных, минимальная и оптимальная длина выноски должна составлять не менее ширины промежутка между двумя наборами текста.

Другие вопросы по тегам