Phpword: How to get the word document page?

Created on 23 May 2015  路  2Comments  路  Source: PHPOffice/PHPWord

I have a word document,now,I want to get number of pages in a Word document.What the phpword function can I use?

QA

Most helpful comment

There is no function to get the current page number. The only way is to use "addPreserveText" like:

$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.');

The documents you are programming with phpword are declarative. So you declare how the document should be structured and then an application, like Mircosoft Word, creates a view of this declaration.

When you add content like a textrun with a text that is two pages long, phpword doesn't programmatically know anything about the length.

All 2 comments

There is no function to get the current page number. The only way is to use "addPreserveText" like:

$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.');

The documents you are programming with phpword are declarative. So you declare how the document should be structured and then an application, like Mircosoft Word, creates a view of this declaration.

When you add content like a textrun with a text that is two pages long, phpword doesn't programmatically know anything about the length.

Thank you very much.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyrillkalita picture cyrillkalita  路  6Comments

btry picture btry  路  4Comments

jt6a74 picture jt6a74  路  5Comments

fishwolf picture fishwolf  路  4Comments

ahmednawazbutt picture ahmednawazbutt  路  3Comments