dsdqpdjpq16640651 2016-11-25 11:36
浏览 129

$ textrun->在$ footer-> addText内容之前处理的addText内容

I want to have a footer that contains 3 lines of text, with a vertical space (like a blank line) between lines 2 and 3. Because line 3 contains bold and normal text, I have to implement it as a textrun. But there should be a line break between lines 1 and 2, so I use addText for both of these.

Unfortunately, the order in which the footer content is displayed is as follows:

  • textrun

    footerText1
    footerText2

The textrun gets processed first and appears above the other lines!

How do I get the order right?

My footer code is:

// create footer
$footer = $section->addFooter();

// textrun declaration removed from here

// create footer content
$footerText1 = "Blah blah blah.";

$footerText2 = "Ipsum loret Ipsum loret Ipsum loret.";


// define font styles  
$smallFontStyleName = 'smallText';
$phpWord->addFontStyle($smallFontStyleName, array(
    'name' => 'Helvetica',
    'size' => 8,
));

$boldSmallFontStyleName = 'BoldSmallText';
$phpWord->addFontStyle($boldSmallFontStyleName, array(
    'bold' => true,
    'name' => 'Helvetica',
    'size' => 8,
));


// define paragraph spacing styles
$phpWord->addParagraphStyle('line1FooterStyle', array( 'spaceAfter'=>20));

$phpWord->addParagraphStyle('line2FooterStyle', array( 'spaceAfter'=>380));


// add content
$footer->addText($footerText1, 
    array('name' => 'Helvetica', 'size' => 8),
    array('space' => array('after' => 20))
);

$footer->addText($footerText2, 
    array('name' => 'Helvetica', 'size' => 8), 
    array('space' => array('after' => 380))
);

// textrun relocated to here

$textrun = $footer->addTextRun();

$textrun->addText('T', $boldSmallFontStyleName);
$textrun->addText(' ++353 1 555 0001 ', $smallFontStyleName); 
$textrun->addText('E', $boldSmallFontStyleName);
$textrun->addText(' abc.def@ghk.ie ', $smallFontStyleName);
$textrun->addText('W', $boldSmallFontStyleName);
$textrun->addText(' abcd.ie/wxz', $smallFontStyleName);
  • 写回答

1条回答 默认 最新

  • duanpanbo9476 2016-11-28 14:35
    关注

    OK, I saw the problem and fixed it. I had declared the textrun before the $footer->addText lines. Which means the textrun code was inserted first, incorrectly. D'oh!

    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊