Andi R
Andi R

Reputation: 112

PhpWord roman numeral for page number

I'm using this phpword library: https://github.com/PHPOffice/PHPWord

And I have a trouble about roman numeral in page number, Is it possible for phpword to show page number in roman numeral instead of standard numeral?

i found this line of code in the library:

protected $fieldsArray = array(
        'PAGE' => array(
           'properties' => array(
               'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
           ),
           'options' => array('PreserveFormat'),
        ),
...
);

just wonder how i can get it.

Upvotes: 0

Views: 1898

Answers (1)

troosan
troosan

Reputation: 173

You can achieve this as follows

$phpWord = new PhpWord();
$section = $phpWord->addSection();
$footer = $section->addFooter();
$textRun = $footer->addTextRun(array('alignment' => Jc::CENTER));
$textRun->addField('PAGE', array('format' => 'ROMAN'));
$textRun->addText(' of ');
$textRun->addField('NUMPAGES', array('format' => 'ROMAN'));

Upvotes: 2

Related Questions