PHPackages                             vrok/tex-wrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. vrok/tex-wrapper

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

vrok/tex-wrapper
================

PDFLatex wrapper class

1.2.1(3y ago)3921[1 issues](https://github.com/j-schumann/tex-wrapper/issues)MITPHPPHP &gt;=7.4CI failing

Since Oct 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/j-schumann/tex-wrapper)[ Packagist](https://packagist.org/packages/vrok/tex-wrapper)[ Docs](https://www.vrok.de/)[ RSS](/packages/vrok-tex-wrapper/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

vrok/tex-wrapper
================

[](#vroktex-wrapper)

PHP class wrapping calls to PDFLaTeX/LuaLaTeX to generate PDF files from LaTeX generated by PHP itself.

Requires pdflatex/lualatex or another engine to be installed, e.g. in Debian package texlive-latex-base.

[![Build Status](https://camo.githubusercontent.com/e2770965d097ff5bfea90c39bd63371f535ccfc5b805223963e4c3beb606a1b6/68747470733a2f2f7472617669732d63692e6f72672f6a2d736368756d616e6e2f7465782d777261707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/j-schumann/tex-wrapper) [![Coverage Status](https://camo.githubusercontent.com/2881e1c0392658daf532d95927142d09f3d98aedce78cfa89d6dbcb15bd2202b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6a2d736368756d616e6e2f7465782d777261707065722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/j-schumann/tex-wrapper?branch=master)

Usage
-----

[](#usage)

```
// autogenerate filename for TeX file in temp dir
$wrapper = new TexWrapper\Wrapper();

// use existing TeX or store in custom path.
// the resulting PDF will have the same filename with ".pdf" appended
$wrapper = new TexWrapper\Wrapper('/my/path/texfile');

// generate the TeX file
$texContent = '\documentclass{article}
        \begin{document}
        \title{Introduction to \LaTeX{}}
        \author{Author Name}
        \maketitle
        \section{Introduction}
        Here is the text of your introduction.
        \end{document}';
$wrapper->saveTex($texContent);

// to customize log output or apply texfot to filter unnecessary messages
$wrapper->setCommand('texfot '.$wrapper->getCommand().' 2>&1');

// to use lualatex instead of pdflatex
$cmd = 'lualatex --file-line-error '
        .' --interaction=nonstopmode --output-directory=%dir% %file%';
$wrapper->setCommand($cmd);

// build PDF file in the same path where the TeX file lives
$result = $wrapper->buildPdf();
if ($result) {
    echo "PDF file ".$wrapper->getPdfFile()." was created!";
} else {
    echo "PDF file wasn't generated!";
}

// even when the PDF was generated there could be errors and the latex engine
// or the post-processing command exited with an error code > 0
// getErrors() returns an array, possible indexes are: engine, missingFonts,
// postProcessor
var_dump($wrapper->getErrors());

// pdflatex always generates output, some warnings like missing fonts do not
// generate errors, the output is always saved:
var_dump($wrapper->getLog()); // returns string

// if you don't need the TeX file anymore
// it is automatically deleted on Wrapper destruction if no initial filename
// was set
$wrapper->deleteTex();
```

### Post-Processing

[](#post-processing)

To apply post-processing to the created PDF, e.g. to reduce file size use `postProcess($cmd)`. The command must keep the PDF file in place, else `postProcess` will return false. The placeholder `%file%` points to the previously created PDF file, `%dir%` to the containing folder.

```
// Example: use ghostscript (debian package: ghostscript) to minimize PDF file
// size. Test first: very simple documents can get larger through this!
$postProcessor = 'gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4'
        .' -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH'
        .' -dDetectDuplicateImages -dCompressFonts=true -r150'
        .' -sOutputFile=%file%.tmp %file% && mv %file%.tmp %file%';
$result = $wrapper->postProcess($postProcessor);
if ($result) {
    echo "post-processed ".$wrapper->getPdfFile();
} else {
    echo "post-processing failed!";

    $errors = $wrapper->getErrors();
    var_dump($errors['postProcessor']);
}
```

### Note on texfot

[](#note-on-texfot)

Texfot tries to remove unnecessary lines from the LaTeX engine output. But while pdflatex/lualatex outputs everything including all errors to the stdout, texfot writes errors to stderr, so we have to include them in stdout by using "2&gt;&amp;1" in the command for the wrapper to log them. Texfot uses the temporary file /tmp/fot which is not deleted after execution so it can cause errors when used by different users which can not write the others files.

### Note on LuaLaTeX

[](#note-on-lualatex)

The lualatex command requires access to a working directory in $HOME, e.g. $HOME/.texlive2017, depending on the installation and version. Make sure to create it for the user executing PHP before using the script.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 86.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~644 days

Total

4

Last Release

1205d ago

PHP version history (3 changes)v1.0.0PHP &gt;=7.1

v1.2.0PHP ^7.4

1.2.1PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed9373b6806c33f512ca3b63214dd2a2b2621bcbddffcdb99acc66ae7f0324aa?d=identicon)[j-schumann](/maintainers/j-schumann)

---

Top Contributors

[![j-schumann](https://avatars.githubusercontent.com/u/114239?v=4)](https://github.com/j-schumann "j-schumann (19 commits)")[![kviolka](https://avatars.githubusercontent.com/u/976265?v=4)](https://github.com/kviolka "kviolka (3 commits)")

---

Tags

lualatexpdflatexphptexlivewrapperwrapperlatexpdflatex

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/vrok-tex-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/vrok-tex-wrapper/health.svg)](https://phpackages.com/packages/vrok-tex-wrapper)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.3k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M131](/packages/openspout-openspout)[fpdf/fpdf

FPDF Composer Wrapper

512.7M22](/packages/fpdf-fpdf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
