XSL FO内联对齐

时间:2008-12-24 16:24:43

标签: pdf xsl-fo

我需要在同一行上左右对齐文本。这应该是可能的,但我似乎找不到办法。我正在使用Apache FOP将xml转换为pdf。

有人可以帮助我做到这一点吗?

6 个答案:

答案 0 :(得分:43)

优雅不是规定的要求,但这应符合法案:

<fo:block text-align-last="justify">
  LEFT TEXT
  <fo:leader leader-pattern="space" />
  RIGHT TEXT
</fo:block>

这可以通过对块中文本的最后一行进行调整来实现,这样文本就从行的左边开始,到右边结束。通常在目录页面上使用的领导者伸展以填充左右文本之间的空间。通常它被用作<fo:leader leader-pattern="dots" />,它会产生一段时期,但在这种情况下它只是提供了一个空间。

答案 1 :(得分:12)

这样可以解决问题:

<fo:table>
  <fo:table-column />
  <fo:table-column />

  <fo:table-body>
    <fo:table-row>
      <fo:table-cell>
        <fo:block>LEFT TEXT</fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block text-align="right">RIGHT TEXT</fo:block>
      </fo:table-cell>
    </fo:table-row>
  </fo:table-body>
</fo:table>

答案 2 :(得分:4)

// Covert date input
$draft_to_deleted_delay = '00-00-00-00-10-00'; //YY-MM-DD-HH-MM-SS <-- year-month-day-hour-minute-second

$draft_to_deleted_delay     = explode('-', $draft_to_deleted_delay);
$draft_to_deleted_delay     = new DateInterval(
    'P'.$draft_to_deleted_delay[0].'Y'.
    $draft_to_deleted_delay[1].'M'.
    $draft_to_deleted_delay[2].'D'.
    'T'.$draft_to_deleted_delay[3].'H'.
    $draft_to_deleted_delay[4].'M'.
    $draft_to_deleted_delay[5].'S'
);

// Get current date
$now = new DateTime();

// Get all the unpublished posts
$unpublished_posts = new WP_Query(array(
    'posts_per_page'    => -1,
    'post_type'         => 'post',
    'meta_key'          => 'draftDate', //This value is saved as strftime('%F %T') when post gets status "draft"
    'post_status'       => 'draft'
));

while($unpublished_posts->have_posts()) {
    $unpublished_posts->the_post();
    $draft = get_post_meta(get_the_ID(), 'draftDate', true);
    if(!empty($draft)) {

        // Date comparison
        $dt = new DateTime($draft);
        $dt->add($draft_to_deleted_delay);
        if($dt < $now) {

            // Expiration date reached, change to any status, "pending" in this example
            wp_update_post(array('ID' => get_the_ID(), 'post_status' => 'pending'));
        }
    }
}

已验证使用FOP 2.0

答案 3 :(得分:0)

这可能我不确定确切的输出是什么,但你试过了吗?

<fo:block-container>
   <fo:block text-align="left">text</fo:block>
   <fo:block text-align="right">text</fo:block>
</fo:block-container >

我有一段时间没有完成XSLFO,但我当然可以推荐用于XSL-FO开发的Stylus Studio(以及一般的XML),应用内调试和预览在按时完成截止日期时保存了我的屁股。您也可以使用Stylus与Apache FOP处理器配合使用。

PS:如果我在家里也正确设置了Apache FOP等设备,我会仔细检查。

答案 4 :(得分:0)

我现在没有时间来测试这个,但请查看http://www.w3.org/TR/xsl/#fo_float

浮动一个右浮动另一个左 - 如果我想要做你正在描述的话,我会试一试

您也可以使用表格

除非右对齐和左对齐,否则你的意思是...... {/ p>

答案 5 :(得分:0)

我创建了两个块,在第二个块上我设置了这个属性:

margin-top="-4mm"

或者你的字体大小和边距是什么(只是看起来像是在同一条线上)

相关问题