Download the PHP package pandoc-php/pandoc without Composer

On this page you can find all versions of the php package pandoc-php/pandoc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pandoc

Pandoc PHP

A native PHP 8.4 port of the Pandoc document converter. This library converts documents between formats (Word .docx, Excel .xlsx, PowerPoint .pptx, HTML .html, Markdown .md, Jupyter .ipynb, BibTeX .bib → LaTeX) and exports LaTeX projects to EPUB 3 (see Converting ODT to LaTeX) without requiring the system-level Pandoc binary.

Features

Installation

Requires PHP 8.4 or higher.

Basic Usage

Converting a Word Document to LaTeX

Word equations (Office Math/OMML, Insert → Equation) are converted to LaTeX automatically — no extra setup required. An inline equation becomes a Math AST node of type InlineMath ($…$), and a standalone equation paragraph becomes DisplayMath (\[…\]):

Superscripts/subscripts, fractions, radicals, n-ary operators (∫, ∑, ∏, ⋃, …), delimiters, functions (sin, log, lim, …), matrices, and common Greek letters/operator symbols are all supported. See SUPPORTED_STRUCTURES.md for the full list and known limitations.

Converting Markdown to a LaTeX Fragment

Converting HTML to LaTeX

Converting an Excel Spreadsheet to LaTeX

Each sheet produces a level-2 header followed by a booktabs table. If the spreadsheet contains embedded images or charts, use the ZIP output pattern below.

Note: Only .xlsx (OOXML) is supported. Legacy .xls files must be converted first (e.g. via LibreOffice).

Chart extraction: Charts are exported as two companion files added to the MediaBag:

chart1.json — Chart.js-ready metadata:

chart1.csv — the data (categories + one column per series):

A comment marker is inserted in the LaTeX at the chart's position:

Your app reads the marker → loads the JSON → finds dataFile → loads the CSV → renders with Chart.js.

Per-sheet CSV export: Each worksheet is also exported as a standalone CSV file (e.g. sheet-Sales.csv) added to the MediaBag. Trailing empty rows and columns are stripped automatically.

Locale detection: The reader inspects docProps/core.xml for a <dc:language> tag and selects separators accordingly:

Language group Decimal sep. Thousands sep. Column delim.
en, ja, zh, pt-BR, … . , ,
fr, de, it, es, nl, pl, ru, … , . ;

When no language tag is present the file falls back to en-US conventions.

metadata.json: Always added to the MediaBag alongside the CSVs:

Utility script: export_xlsx_media.php converts any .xlsx file to a ZIP containing its CSVs and metadata.json:

Converting a PowerPoint Presentation to LaTeX

Each slide is wrapped in a slide environment (with the slide title as argument), and all slides are enclosed in a slider environment:

These are custom environments — define them in your LaTeX preamble to control rendering. All images (including slide master/template graphics) are extracted into the MediaBag.

Embedded videos are exported as a video environment:

Embedded audio is exported as an audio environment:

All media files (images, video, audio) are included in the ZIP output alongside the .tex.

Converting BibTeX to LaTeX

The output is a self-contained thebibliography block:

Converting Jupyter Notebooks to LaTeX

Converting LaTeX to EPUB

Turns a LaTeX source (an article, report or book using common packages) into an EPUB 3 file with real MathML equations, numbered sections, figures, tables and theorems, working cross-references (Fig. 3, Section A.1), footnotes, a bibliography and embedded images.

Requirements: PHP 8.4 with ext-zip and ext-dom. latex2mathml-php (MathML) is installed automatically by Composer.

From PHP

To send the file from a web script instead of saving it:

If you give read() a string of LaTeX instead of a path, there is no folder to search; pass the image folder to the writer: new EpubWriter(['resourcePath' => ['/projects/paper']]).

From the command line

The project must be unzipped first (the reader does not open archives), with the images beside the .tex file or in a \graphicspath folder. The web upload form in web/ does not offer EPUB yet.

Preparing the LaTeX source

Options

Pass them to the writer: new EpubWriter(['splitLevel' => 2, 'tocDepth' => 2]).

Option Default Meaning
splitLevel 1 Headings of this level or higher start a new chapter file
tocDepth 3 Deepest heading level in the table of contents
numberSections true Show section numbers in headings and the table of contents
titlePage true Generate a title page (title, authors, date, cover)
coverImage none Path of a cover image; overrides the document's \cover
language from babel, else en-US BCP 47 language tag
identifier derived UUID dc:identifier of the book
css built-in Replacement stylesheet contents
resourcePath ['.'] Folders searched for images not found next to the .tex
mathml true Convert math to MathML (falls back to the TeX source if a formula cannot be converted)
optimizeImages false Opt-in image compression with ext-imagick (CPU-heavy: about 12 s for 40 MB of images). Uses maxImageWidth (1600) and jpegQuality (85)

What to expect

Measured on an Apple M4 Max with images embedded unchanged: about 1 second for a 3,000-line survey with 20 figures (the EPUB is about the size of the images). Peak memory is 2 to 3 times the total image size, so allow headroom in memory_limit for very large projects.

The output has been checked for well-formed XML, working internal links and MathML, but not with a strict validator such as epubcheck; run it before distributing a book. See SUPPORTED_STRUCTURES.md for the full list of supported and unsupported LaTeX constructs.

Converting LaTeX to ODT

The same LatexReader output can be written as an OpenDocument Text file, which opens in LibreOffice, Apache OpenOffice and other ODF applications. It is produced in pure PHP (ext-zip, ext-dom); LibreOffice is not needed on the server.

From the command line: php latex2odt.php paper.tex [paper.odt] [--cover=cover.png] [--no-numbers].

What you get: outline-level headings (so LibreOffice's Navigator works) with section numbers, paragraph and character styles, bulleted and numbered lists, footnotes as real footnotes, tables with column widths fitted to their content and booktabs-style rules, figures with numbered captions (sub-figures are laid out side by side, as in the PDF), algorithms as indented pseudocode, internal links and citations as working links, and equations as embedded MathML objects, which stay editable in LibreOffice. \cover{file} places the cover image centred above the title, as in the EPUB.

Option Default Meaning
numberSections true Write the section numbers in headings
titlePage true Title, authors and date at the top (with the cover, if any)
coverImage none Path of a cover image; overrides the document's \cover
language from babel, else en-US BCP 47 language tag of the document
resourcePath ['.'] Folders searched for images not found next to the .tex
mathml true Embed equations as MathML objects (otherwise the TeX source is written as text)

Notes:

Converting ODT to LaTeX

Or from the command line: php odt2latex.php paper.odt [paper.tex] [--fragment] [--compact-tables] (writes the pictures next to the .tex). The same OdtReader is used when you upload an .odt to web/convert.php.

The LaTeX uses the kernel plus amsmath/amssymb, graphicx, hyperref, booktabs, xcolor, soul, and subcaption or babel only when the document needs them; pdflatex is enough. It is also readable by this library's LatexReader, so ODT → LaTeX → EPUB works.

Converting reStructuredText (Sphinx) to LaTeX

RstReader reads reStructuredText, including the usual Sphinx additions, into the same AST as the other readers, so LatexWriter (and the EPUB and ODT writers) can write it. It follows Pandoc's RST reader: heading levels come from the order of the underline styles, admonitions become Divs, figures become Figures, footnotes become notes, and smart punctuation is on.

Supported: sections, paragraphs, bullet, enumerated, definition, field and option lists, line blocks, literal and doctest blocks, block quotes, transitions, grid, simple, list-table and csv-table tables, footnotes, citations, hyperlink targets (external, internal, indirect, anonymous, implicit section titles), substitutions, inline roles, and the directives include, literalinclude, code-block/code, image, figure, admonition and the named admonitions, versionadded/versionchanged/deprecated, seealso, sidebar, topic, rubric, container, raw, math, toctree, configuration-block, tabs, only and role. Sphinx roles :ref:, :doc:, :class:, :method:, :phpfunction: and the like are resolved or written as code. Unknown directives keep their content in a Div whose class is the directive name, and $reader->warnings lists unresolved references and unknown directives or roles.

A whole Sphinx tree becomes one book with SphinxProject: documents are put in toctree order, the headings of each one are shifted by its depth, and :ref: / :doc: links across files become internal links.

The command line does the same: php rst2latex.php page.rst page.tex, or php rst2latex.php --project DOCS_DIR --class book --engine xelatex --orphans book.tex. Compile with xelatex (twice, for the references). The Symfony documentation (431 files) converts in about 15 seconds and compiles to a PDF of roughly 3,700 pages.

LatexWriter options used for this: documentClass (book/report write level-1 headings as chapters), codeStyle (fancyvrb wraps long lines and labels the language; listings highlights), wrapTables (longtables with wrapping columns), breakInlineCode, fitImages, engine (xelatex/lualatex load fontspec; mainFont, monoFont) and preamble. Admonitions are written as tcolorbox boxes; \usepackage lines are added only when the document needs them.

Converting to reStructuredText

RstWriter writes the AST of any reader as reStructuredText, following Pandoc's RST writer: headings underlined with =, -, ~, ^, '; bullet and numbered lists; definition lists; line blocks; block quotes; images as substitutions; notes as auto-numbered footnotes written at the end; simple tables when every cell is one line of text and grid tables (with column and row spans) otherwise. An empty .. comment is added where two lists or a list and a quote would merge.

Or from the command line, for any supported input: php convert2rst.php paper.tex paper.rst [--columns N] [--grid].

What RstReader produces is written back as the same constructs: admonitions, versionadded/versionchanged/deprecated, sidebar, topic, toctree, configuration-block, figure, code-block with its options, and the roles :ref:, :class:, :method:, :phpfunction:, :sup:, :sub:, :math: and the like. Internal links become :ref: with a .. _label: before the target. Options: columns (wrap width, 0 = no wrapping, default 72), codeDirective (code-block or code) and tableStyle (auto or grid).

Checked on the Symfony documentation: reading each of the 430 pages, writing it, and reading the result gives an identical structure for 415 of them (the others hold constructs RST cannot express, such as literal text containing a double backtick, or malformed source), and docutils reports no structural error in the written files.

Output: Plain .tex or .zip

When a document contains images, charts, or other media, you need to bundle them alongside the .tex file. The MediaBag tells you whether there are any attachments:

All media files (images, chart JSON/CSV) are stored at the root of the ZIP, so \includegraphics{image.png} and chart references resolve correctly when the .tex is compiled or processed from the same directory.

Web Interface

The project includes a web-based demonstration tool in web/.

  1. Point your web server to the php-pandoc/web/ folder.
  2. Open index.html in your browser.
  3. Upload a .docx, .xlsx, .pptx, .html, .ipynb, .md, or .bib file.
  4. Choose Standalone or Fragment output.
  5. Download the result — a plain .tex if the document has no media, or a .zip if it does.

Supported Structures

See SUPPORTED_STRUCTURES.md for a full feature list. Highlights:

Development and Testing

Credits

This project is a port of Pandoc, originally created by John MacFarlane.

License

GPL v2 or later, mirroring the original Pandoc license.


All versions of pandoc with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
latex2mathml/latex2mathml-php Version ^1.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pandoc-php/pandoc contains the following files

Loading the files please wait ...