我正在使用PphPresentation库来创建powepoint演示文稿。
我正在尝试在textshape中创建一个换行符。
这是代码的一部分
$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.发布于 2017-11-17 14:45:44
当所有行都有相同的字体属性时,获得新行的另一种选择是使用段落:
$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.");发布于 2016-10-07 10:05:11
我也有同样的问题。我刚在样本里发现了这个。我认为您需要单独添加每一行。我必须重写如何构建我的数组,然后我将对其进行测试,但以下是示例代码:
$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');发布于 2016-10-08 00:23:02
我已经意识到这个库有自己的方法。
我就是这样做的。
$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.同一Powerpoint文本框中的三行不同行。
https://stackoverflow.com/questions/39882704
复制相似问题