Harry Torry
Harry Torry

Reputation: 373

PHPWORD Line numbering

how do I add line numbering to my document?

I added this;

$objWriter->startElement('w:lnNumTyp');
$objWriter->writeAttribute('w:start', '5');
$objWriter->writeAttribute('w:restart', '1');
$objWriter->endElement();

To my PhpWord\Writer\Word2007\Document.php script, immediately after;

$objWriter->startElement('w:sectPr');

Where am I going wrong?

Upvotes: 1

Views: 769

Answers (2)

ivanlanin
ivanlanin

Reputation: 141

Use the lineNumbering property of Section style that were available since 0.10.0.

Example: section = $phpWord->addSection(array('lineNumbering' => array()));

Upvotes: 2

Harry Torry
Harry Torry

Reputation: 373

Correct code is as follows;

$objWriter->startElement('w:lnNumType');
$objWriter->writeAttribute('w:countBy', '5');
$objWriter->writeAttribute('w:restart', 'continuous');
$objWriter->endElement();

It still goes after;

$objWriter->startElement('w:sectPr');

Upvotes: 3

Related Questions