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.
Download pandoc-php/pandoc
More information about pandoc-php/pandoc
Files in pandoc-php/pandoc
Package pandoc
Short Description A native PHP 8.4 port of the Pandoc document converter.
License GPL-2.0-or-later
Homepage https://github.com/pandoc-php/pandoc
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) without requiring the system-level Pandoc binary.
Features
- Native PHP 8.4: Uses
readonlyclasses, Enums, and property hooks. - AST-Centric Architecture: Mirrors Pandoc's Abstract Syntax Tree for robust conversions.
- Modular Reader System: Factory pattern and
ReaderInterfacefor easy format expansion. - Deep Docx Parsing: Paragraphs, headers, tables, lists, images, bold/italic/underline/strikeout, superscript/subscript, text and background colors, hyperlinks (external
\href/\url, internal\hyperref), footnotes and endnotes (\footnote), math equations (Office Math/OMML → LaTeX, inline$…$and display\[…\]), automatic run-merging (consecutive runs with identical styling are collapsed into one command), and black-color suppression (spurious\textcolor[HTML]{000000}commands are dropped). - Excel (XLSX): All sheets as booktabs tables, shared strings, bold/italic, embedded images, chart extraction (JSON metadata + CSV data for Chart.js), per-sheet CSV export with locale-aware separators, and a
metadata.jsonsummary of document locale. - PowerPoint (PPTX): Each slide becomes a
slideenvironment, all slides wrapped in asliderenvironment. Images, embedded videos (\begin{video}...\end{video}), and audio (\begin{audio}...\end{audio}) extracted to MediaBag. - LaTeX Generation: Standalone documents or body fragments.
- Automatic ZIP Bundling: When a document contains images or chart data, output is a
.zipwith the.texand all media files in the same directory. Plain.texotherwise. - Full UTF-8: End-to-end UTF-8, supporting CJK, Cyrillic, Arabic, Thai, and all Latin-extended scripts.
- No External Dependencies: Pure PHP 8.4+.
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.xlsfiles 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:
- HTTP/HTTPS URLs are automatically wrapped in
\url{…}. - The
title,booktitle,journal,series, andpublisherfields are italicised with\emph{…}. - The
keywordsandabstractfields are silently omitted from the output. - BibTeX output is always produced as a fragment (
standalone: false); the web interface enforces this automatically.
Converting Jupyter Notebooks to LaTeX
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/.
- Point your web server to the
php-pandoc/web/folder. - Open
index.htmlin your browser. - Upload a
.docx,.xlsx,.pptx,.html,.ipynb,.md, or.bibfile. - Choose Standalone or Fragment output.
- Download the result — a plain
.texif the document has no media, or a.zipif it does.
Supported Structures
See SUPPORTED_STRUCTURES.md for a full feature list. Highlights:
- Word: Headers (H1–H6, Title), bold/italic/underline/strikeout/color, lists, tables, images, headers & footers, hyperlinks, footnotes/endnotes, math equations (OMML → LaTeX), automatic run-merging.
- Excel: Multi-sheet tables, cell formatting, embedded images, Chart.js-ready chart extraction, per-sheet CSV export with locale-aware separators.
- PowerPoint: Slide titles, body text, bullet/ordered lists, images, tables,
slide/sliderLaTeX environments. - HTML: Full block and inline element support.
- Jupyter: Markdown cells, code blocks, output images.
- BibTeX: Entries rendered as a
thebibliographyenvironment with\bibitemitems; URLs wrapped in\url{…}, title/journal/booktitle/series/publisher fields italicised with\emph{…}, andkeywords/abstractfields omitted.
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.