getStatistics

getStatistics

ADVANCED / PREMIUM TRIAL

Counts and prints the number of pages, words, characters, paragraphs, lines, tables and images of a DOCX.

Description
public getStatistics (string $source)

This method uses the conversion plugins (LibreOffice, MS Word or PHP native) to count and print the number of:

  • pages (LibreOffice and MS Word)
  • words (LibreOffice, MS Word and PHP native)
  • characters (LibreOffice, MS Word and PHP native)
  • paragraphs (LibreOffice, MS Word and PHP native)
  • lines (LibreOffice and MS Word)
  • tables (LibreOffice and PHP native)
  • images (LibreOffice and PHP native)

Indexer can extract additional information from the document.

Parameters

source

Path to the DOCX to get its statistics.

Return values

array

Code samples

Example #1

Example #2

Example #3

Release notes
  • phpdocx 17.0:
    • supported PHP native conversion plugin.
  • phpdocx 10.0:
    • supported MS Word conversion plugin.
    • return an Exception if the stats file can't be created.
  • phpdocx 5.5:
    • new method.