API documentation

API documentation

You will find in this section a complete list of the methods included in the latest version of the phpdocx library.

Here we include a brief description of each method for your convenience:

Word contents
  • addBibliography

    Inserts a bibliography into the Word document

  • addBookmark

    Inserts a bookmarks into the Word document

  • addBreak

    Inserts a line/column/page break into the Word document

  • addChart

    Inserts a chart into the Word document

  • addCitation

    Adds a citation into the Word document

  • addComment

    Adds a Word comment to the current Word document

  • addCrossReference

    Inserts a cross-reference into the Word document

  • addDateAndHour

    Allows to insert the current date and/or hour in different formats

  • addEndnote

    Inserts an endnote into the Word document

  • addExternalFile

    Adds an external DOCX, HTML, MHT, RTF or TXT file

  • addFootnote

    Inserts a footnote into the Word document

  • addFormElement

    Inserts form elements into the Word document

  • addHeading

    Inserts a heading into the Word document

  • addImage

    Inserts an image into the Word document

  • addLink

    Inserts a link into the Word document

  • addList

    Inserts (nested) lists into the Word document

  • addMathEquation

    Imports a math equation from another Word document or inserts a math equation in OMML or MathML format

  • addMergeField

    Adds a merge field to the Word document

  • addOLE

    Adds an OLE file

  • addOnlineVideo

    Adds an online video to the Word document

  • addPageNumber

    Inserts the current page number into the Word document

  • addShape

    Inserts different types of shapes into a Word document

  • addSimpleField

    Adds a simple field to the Word document

  • addSource

    Adds a source into the Word document

  • addStructuredDocumentTag

    Inserts different types of Structured Document Tags into the Word document

  • addSVG

    Inserts a SVG into the Word document

  • addTab

    Inserts a tab into a Word document

  • addTable

    Inserts a table into a Word document

  • addTableContents

    Inserts a Table of Contents (TOC) into the Word document

  • addTableFigures

    Inserts a Table of Figures into the Word document

  • addText

    Inserts a paragraph into a Word document

  • addTextBox

    Inserts a Text Box in the Word document

  • addWordFragment

    Inserts a WordFragment into the Word document

  • addWordML

    Inserts raw WordML code into the Word document

  • embedHTML

    Inserts HTML content into the Word document

Layout and settings
Format conversion

    Extracts the text contents from a Word document

  • enableRepairMode

    Enables repair features to fix common issues when working with LibreOffice

  • getStatistics

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

  • transformDocument

    Transforms documents into other formats (DOCX, PDF, (X)HTML, DOC, ODT, RTF, PNG, TXT)

  • transformDocAdvHTML

    Transforms DOCX documents into HTML using native PHP classes

  • transformOMMLToMathML

    Transforms OMML (Office MathML) equations to MathML


    Transforms plain text into WordML with custom styles

  • indexer

    Parses DOCX documents and return their contents (body, images, links, comments, headers...)

  • generateDOCXStructure

    Allows using a DOCX as template from any stream

  • optimizeTemplate

    Process a DOCX to get the best performance when using the document as a template

  • parseDocx

    Allows to serialize a DOCX in memory, database... to be reused later

  • zipStream

    Generates a DOCX stream without saving the document to the file system

Bulk processing
Digital signature
Artificial Intelligence
  • searchAndReplace

    Searches and replaces shared strings and cell values in an Excel document

  • removeSheet

    Removes sheets from an Excel document

  • splitXlsx

    Splits XLSX documents per sheet