Question

I am using phppowerpoint to generate ppt files. I want to change default line height between lines in PPT.

ppt slide screen grab

here is bit of code I am using to generate ppt.

$shape->createParagraph()->getAlignment()->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT)->setVertical(PHPPowerPoint_Style_Alignment::VERTICAL_TOP);
$textRun = $shape->createTextRun($ppt_build[$i][$k]['text'][$j]['textrun']);
$textRun->getFont()->setBold($ppt_build[$i][$k]['text'][$j]['bold']);
$textRun->getFont()->setSize($ppt_build[$i][$k]['text'][$j]['size']); //setName
$textRun->getFont()->setName($ppt_build[$i][$k]['text'][$j]['name']); //setName
$textRun->getFont()->setColor(new PHPPowerPoint_Style_Color($ppt_build[$i][$k]['text'][$j]['color']));

then creating a line break

$shape->createBreak();

I tried using giving 2 line breaks but it is more than I need.

I also tried solution mentioned here

http://phppowerpoint.codeplex.com/discussions/273396

But with that solution it adds space only before and after the paragraph.

is there any cheat sheet or list that contains xml nodes/elements/names used in xml files generated for powerpoint

Was it helpful?

Solution

follow below steps to achieve this

Inside /* /powerpoint/PHPPowerPoint/Shape/RichText/Paragraph.php */

private $_spacing;

also

/**
 * Get spacing
 *
 * @return PHPPowerPoint_Style_Spacing
 */
public function getSpacing() {
    return $this->_spacing;
}

/**
 * Set spacing
 *
 * @param    PHPPowerPoint_Style_Spacing        $spacing
 * @throws     Exception
 * @return PHPPowerPoint_Shape_RichText_Paragraph
 */
public function setSpacing($spacing = '100000') {
    $this->_spacing = $spacing;
    return $this;
}

Then inside /PHPPowerPoint/Writer/PowerPoint2007/Slide.php

private function _writeParagraphs(PHPPowerPoint_Shared_XMLWriter $objWriter, $paragraphs) {

after

$objWriter->writeAttribute('lvl', $paragraph->getAlignment()->getLevel());

add

        if ($paragraph->getSpacing()) {
            $objWriter->startElement('a:lnSpc');
            $objWriter->startElement('a:spcPct');
            $objWriter->writeAttribute('val', $paragraph->getSpacing());
            $objWriter->endElement();
            $objWriter->endElement();
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top