getStyle(); if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) { return ''; } $css = array(); // Alignment if ('' !== $style->getAlignment()) { $textAlign = ''; switch ($style->getAlignment()) { case Jc::CENTER: $textAlign = 'center'; break; case Jc::END: case Jc::MEDIUM_KASHIDA: case Jc::HIGH_KASHIDA: case Jc::LOW_KASHIDA: case Jc::RIGHT: $textAlign = 'right'; break; case Jc::BOTH: case Jc::DISTRIBUTE: case Jc::THAI_DISTRIBUTE: case Jc::JUSTIFY: $textAlign = 'justify'; break; default: //all others, align left $textAlign = 'left'; break; } $css['text-align'] = $textAlign; } // Spacing $spacing = $style->getSpace(); if (!is_null($spacing)) { $before = $spacing->getBefore(); $after = $spacing->getAfter(); $css['margin-top'] = $this->getValueIf(!is_null($before), ($before / 20) . 'pt'); $css['margin-bottom'] = $this->getValueIf(!is_null($after), ($after / 20) . 'pt'); } else { $css['margin-top'] = '0'; $css['margin-bottom'] = '0'; } return $this->assembleCss($css); } }