Centering text in odt files

52 views Asked by At

I'm using odt file as a template for my transcripts and I'm using php to insert the transcript in the odt file which then outputs a correctly formated odt file but there is some text that I want to center horizontally for which I've written this code

$transcript .= "<text:p text:style-name=\"CenterText\">Proceedings</text:p>";

from liber office I have added a paragraph style called CenterText and I have set the alignment to center to make it work but for some reason the text proceedings is not even being rendered.

can somebody please tell me what might be wrong and how I can fix the issue

thanks

1

There are 1 answers

8
5px On

If you're going to create documents by hand, you're going to have a bad time. Use PHPWord to easily create .odt files. There you can use

$PHPWord->addParagraphStyle('CenterText', array('align'=>'both')

$section->addText($text, 'CenterText');

to center your text.