pdftex
Create PDF files from TeX source
TLDR
Compile a PDF document
Compile a PDF document, specifying an output directory
Compile a PDF document, exiting on each error
SYNOPSIS
pdftex [OPTION]... [TEXFILE|
]
or
pdftex [OPTION]... \COMMANDS
The command typically takes a TeX source file as an argument. If no file is specified, it enters interactive mode.
PARAMETERS
--help
Display help message and exit.
--version
Display version information and exit.
--output-directory=DIR
Write output files (PDF, log, aux) to DIR.
--jobname=NAME
Use NAME for output file names instead of the input file's base name.
--fmt=FORMAT
Use FORMAT as the name of the format file to be preloaded.
--interaction=MODE
Set the interaction mode (e.g., batchmode, nonstopmode, scrollmode, errorstopmode).
--shell-escape
Enable `\write18` (shell escape) command, allowing TeX to execute external commands. Use with caution.
--no-shell-escape
Disable `\write18` (shell escape) command. This is often the default for security reasons.
--file-line-error
Print error messages in the format `file:line:error`.
--halt-on-error
Exit with an error code upon the first error encountered during processing.
--include-directory=DIR
Add DIR to the search path for input files.
--kpathsea-debug=VALUE
Set Kpathsea debugging flags.
DESCRIPTION
pdftex is the core program that compiles TeX source files directly into PDF documents. Developed by Hàn Thế Thành, it is an extension of the original TeX engine by Donald Knuth, specifically designed to produce PDF output without an intermediate DVI file. It reads TeX (or LaTeX, ConTeXt, etc.) source code and typesets it, handling fonts, layout, and graphics inclusion, finally writing the typeset document as a PDF file.
While pdftex is the underlying engine, users commonly interact with it via format-specific wrappers like pdflatex or pdfetex, which load pre-compiled TeX formats (like LaTeX) before invoking the pdftex engine. pdftex offers enhanced graphics capabilities, direct embedding of PostScript and TrueType fonts, and various PDF features. It's a fundamental component of modern TeX distributions like TeX Live and MiKTeX.
CAVEATS
--shell-escape poses a security risk as it allows arbitrary external commands to be executed during compilation. It should be used with caution, especially when processing untrusted TeX files.
Memory limits: pdftex has internal memory limits (e.g., `main_memory`, `extra_mem_bot`) that can be exceeded by very complex documents or large fonts, leading to "TeX capacity exceeded" errors. These limits can often be configured in `texmf.cnf`.
Multiple passes: Many LaTeX documents, especially those with cross-references, bibliographies, or indices, require multiple pdftex runs (e.g., `pdflatex file.tex`, `bibtex file.aux`, `pdflatex file.tex`, `pdflatex file.tex`) to resolve all references and ensure correct output.
ENGINE VS. FORMAT
pdftex is the engine (the program that does the actual typesetting). pdflatex is a script or wrapper that calls the pdftex engine with the LaTeX format preloaded. Similarly, pdfetex is an extended version of the pdftex engine, offering more primitives.
KPATHSEA
pdftex relies heavily on the Kpathsea library for searching files (TeX sources, fonts, style files, etc.) within the TeX Directory Structure (TDS). This library handles the complex logic of finding required files based on environment variables and configuration files like `texmf.cnf`.
HISTORY
pdftex was developed by Hàn Thế Thành as part of his PhD thesis (1999-2001) at Masaryk University. It aimed to provide a direct path from TeX source to PDF output, bypassing the intermediate DVI format and addressing limitations of older methods like `dvips` + `ps2pdf`.
It became an integral part of the `web2c` distribution (a port of TeX to C) and was quickly adopted as the default engine for PDF generation in major TeX distributions like TeX Live and MiKTeX. Its introduction significantly simplified the workflow for creating high-quality PDF documents from TeX sources and laid the groundwork for further TeX engine developments like XeTeX and LuaTeX.