Forum


Replies: 5   Views: 5580
Page numbers: page x of y
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by slobwebsolutions  · 05-10-2014 - 18:20

I'm trying to add some page information to my header. Ideally I would like to have the text "Page X of Y" (X = current page, Y = total number of pages) As far as I can see the total number of pages is not supported. Is that correct? I'm also having some trouble getting "Page X" on the same line. With the following code there is always a break between: $headerPageNumber = new WordFragment($this->docx, 'defaultHeader'); $headerPageNumber->addText('Page', $pageNumberOptions); $headerPageNumber->addPageNumber('numerical', $pageNumberOptions); I also tried something like this: $numbering = new WordFragment($this->docx, 'defaultHeader'); $numbering->addPageNumber('numerical', $pageNumberOptions); $text = array(); $text[] = 'Pagina '; $text[] = $numbering; $headerPageNumber->addText($text); But that does not work at all. Anyone can help me how to get it on the same line?

Posted by admin  · 06-10-2014 - 08:02

Hello, Which version and license of phpdocx are you using? Regards.

Posted by slobwebsolutions  · 23-10-2014 - 18:45

Currently we are still testing with version phpdocx-trial-pro-4.1

Posted by digiwhite  · 21-12-2014 - 12:35

Is there a solution to this issue? I also like to add page x of Y where the Y is important to me. Thank you Regards, Raymond

Posted by h.ennser  · 26-12-2014 - 09:07

I use license 3.7 Pro+ and I also need a solution for this issue. Additionally I'd like to insert the page numbers into a html-table cell like page x of y into the Header or footer-section Thanks

Posted by admin  · 29-12-2014 - 12:59

Hello,

phpdocx 6.5 added the page-of option to insert numberings "page X of Y".

As it's explained on: http://www.phpdocx.com/api-documentation/word-content/insert-page-number-Word-document-with-PHP You can add a numerical or alphabetical page number. But the current version of phpdocx doesn't allow to add manually 'Page X of Y'; future version will add support. You can change the base template to fit your needs or use a custom DOCX as the base template. For example adding the page number you'd like to use. This is the signature of the construct of CreateDocx class : /** * Construct * * @access public * @param string $baseTemplatePath. Optional, basicTemplate.docx as default * @param $docxTemplatePath. User custom template (preserves Word content) */ public function __construct($baseTemplatePath = PHPDOCX_BASE_TEMPLATE, $docxTemplatePath = '')

Regards.