Hello,
You need to query by section type. But it will only work if the template has more than one section.
We have moved the request to the dev team to add that information to the Indexer class (https://www.phpdocx.com/api-documentation/docxutilities/indexer-parse-word-documents-with-PHP).
We have generated a code to get that information from any existing DOCX:
<?php
require_once 'classes/CreateDocx.php';
$docxStructure = new DOCXStructure();
$docxStructure->parseDocx('template.docx');
$documentDOM = new DOMDocument();
$optionEntityLoader = libxml_disable_entity_loader(true);
$documentDOM->loadXML($docxStructure->getContent('word/document.xml'));
libxml_disable_entity_loader($optionEntityLoader);
$documentXpath = new DOMXPath($documentDOM);
$documentXpath->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$sectionEntries = $documentXpath->query('//w:sectPr/w:pgMar');
foreach ($sectionEntries as $sectionEntry) {
echo 'Top:' . $sectionEntry->getAttribute('w:top') . PHP_EOL;
echo 'Right: ' . $sectionEntry->getAttribute('w:right') . PHP_EOL;
echo 'Left: ' . $sectionEntry->getAttribute('w:left') . PHP_EOL;
echo 'Bottom: ' . $sectionEntry->getAttribute('w:bottom') . PHP_EOL;
}
The returned values are twips (Twentieths of a Point): http://officeopenxml.com/WPSectionPgMar.php
Regards.