1

I'm using PHPWord to generate a document. I'm a but stuck on what to do with my page numbers. Using addPreserveText('Page {PAGE}'); I can show my page number.

But I have a front page and I want page 2 to have page number 1, page 3 to have page number 2, etcetera.

Does anybody know what I have to do?

Thanks

HansElsen
  • 1,639
  • 5
  • 27
  • 47

1 Answers1

0

I am not sure which Version of PHPWord you are using and mine is heavily patched, so line numbers are surely not correct. This is very hardcoded. If you need a patch where you can set the start number from $phpWord->createSection() you have to wait a little bit. I'm implementing it right now:-)

In Writer/Word2007/Document.php -> private function _writeEndSection add the following lines:

$objWriter->startElement('w:pgNumType');
$objWriter->writeAttribute('w:start', '0');
$objWriter->endElement();

It should be in the w:sectPr Element. I added the snippet just before this line:

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

Change the w:start number to any value. Hope this helps.

Darryl Hein
  • 142,451
  • 95
  • 218
  • 261
mainguy
  • 8,283
  • 2
  • 31
  • 40