2016-10-05 60 views
1

我正在使用PphPresentation库来创建powepoint演示文稿。Phppresentation createRichTextShape - 如何创建换行

我想创建一个换行符里面的文本形状。

这是代码

$currentSlide=$objPHPPresentation->createSlide(); 

$textRun = $shape->createTextRun('Estado de Fuerza: '.$personal['ef'].' Elementos. '.'Población: '.$personal['pb'].' hab. '.'Faltante: '.$personal['fal'].' Elementos.'); 

的一部分,我得到这样的:

Fuerza: 0 Elementos Población: 10987 hab. Faltante: -31 Elementos. 

但我想是这样的:

Fuerza: 0 Elementos 

Población: 10987 hab. 

Faltante: -31 Elementos. 

回答

0

我有同样的问题。我刚刚在样本中发现了这一点。我相信你需要分别添加每条线。我不得不重新写我如何建立我的数组,然后我会测试,但这里是示例代码:

$shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET); 



    $shape->createTextRun('A class library'); 
    $shape->createParagraph()->createTextRun('Written in PHP'); 
    $shape->createParagraph()->createTextRun('Representing a presentation'); 
    $shape->createParagraph()->createTextRun('Supports writing to different file formats'); 
+0

看看我的答案,它可以帮助你。 @ user2332467 – Maurocrispin

0

我已经意识到这个库中有它的方法。

我只是这样做了。

$textRun = $shape->createTextRun("Estado de Fuerza: ".$personal["ef"]." Elementos."); 
$textRun->getFont()->setSize(14)->setColor($colorBlack); 

$shape->createBreak(); 

$textRun = $shape->createTextRun("Población: ".$personal["pb"]." hab. "); 

$shape->createBreak(); 

$textRun = $shape->createTextRun("Faltante: ".$personal["fal"]." Elementos."); 

而且我得到了:

Fuerza: 0 Elementos 

Población: 10987 hab. 

Faltante: -31 Elementos. 

三种不同的线路在同一简报文本框。

1

获得新的生产线,同时具有对所有线路相同字体属性的另一种选择是使用段落:

$textParagraph = $shape->createParagraph(); 
$textParagraph->getFont()->setSize(14)->setColor($colorBlack); 

$shape->getActiveParagraph()->createTextRun("Estado de Fuerza: ".$personal["ef"]." Elementos."); 
$shape->getActiveParagraph()->createBreak(); 
$shape->getActiveParagraph()->createTextRun("Población: ".$personal["pb"]." hab. "); 
$shape->getActiveParagraph()->createBreak(); 
$shape->getActiveParagraph()->createTextRun("Faltante: ".$personal["fal"]." Elementos.");