Choosing Native PDF Output in pdfTeX: A Practical Decision Guide
Decide between pdfTeX’s native PDF output and the dvips/pstopdf pipeline, compare options, and validate the result with a practical example.
12 Sept 2026, 20:00 UTC

Decision: Native PDF vs. PostScript Pipeline
When you need a PDF from a TeX source, you can either let pdfTeX write the PDF directly or route the DVI through dvips and pstopdf. The choice affects build time, compatibility, and the ability to embed advanced PDF features.
Constraints and Goals
- Target format: PDF only (no PostScript output required).
- Need to embed PDF specials (e.g., custom annotations or transparency).
- Prefer a single‑pass build to reduce build time in continuous‑integration pipelines.
- Maintain compatibility with older TeX installations that may lack native PDF support.
Options Overview
| Engine | Output Path | Required Packages | Special Features | Compatibility | Typical Use‑Case |
|---|---|---|---|---|---|
| pdfTeX (native) | Direct PDF | None (built‑in) | Page‑level \\special{pdf: ...} for transparency, forms, etc. | All recent TeX Live / MiKTeX (≥ 2008) | Fast builds, advanced PDF features, minimal external tools. |
| dvips + pstopdf | PostScript → PDF | None (requires dvips and pstopdf) | Only what PostScript offers; limited PDF specials. | Older TeX distributions or when PostScript output is also needed. | Legacy workflows, when PDF specials are not required. |
| XeTeX | Direct PDF (via --pdf) | None (built‑in) | Unicode, OpenType font handling; limited PDF specials compared to pdfTeX. | Modern TeX Live (≥ 2016) | Unicode‑heavy documents, system fonts. |
| LuaTeX | Direct PDF (via --pdf) | None (built‑in) | Full Lua scripting; supports pdf.* primitives. | Modern TeX Live (≥ 2016) | Complex layout scripting, custom PDF manipulation. |
Trade‑offs
- Build Speed: Native pdfTeX is one pass; dvips/pstopdf adds two passes.
- Feature Set: pdfTeX specials give fine control over PDF objects; XeTeX/LuaTeX have similar primitives but differ in syntax.
- Compatibility: Native pdfTeX works on almost all TeX installations; dvips/pstopdf is required on very old systems.
- Toolchain Complexity: Relying on external tools increases maintenance (e.g., ensuring
dvipsandpstopdfare in PATH). - Debugging: Errors in specials can corrupt the PDF; careful catcode handling is needed.
Concrete Implementation
Below is a minimal example that demonstrates native PDF output and embeds a PDF form field using \\special{pdf: ...}. The example also shows how to verify that pdfTeX produced a PDF directly.
\\documentclass{article}
\\pdfoutput=1 % Enable native PDF output
\\begin{document}
Hello, native PDF!
% Embed a PDF textbox field named "name"
\\special{pdf: beginobj 1 0 R}
\\special{pdf: << /Type /Annot /Subtype /Widget /FT /Tx /T (name) /Rect [100 700 300 720] >>}
\\special{pdf: endobj}
\\end{document}
Run the build from a shell:
pdflatex -interaction=nonstopmode test.tex
Verification steps:
- File header: Open
test.pdfin a hex editor or usehead -c 10 test.pdf; the first line should read%PDF-indicating a PDF file. - Producer field: Use
pdfinfo test.pdf | grep Producer; the output should containProducer: pdfTeX(or a similar pdfTeX identifier). - Log inspection: In
test.log, look for lines likepdfTeX (pdf output) 3.14159265andPDF code generation. Absence of such lines may mean the build fell back to PostScript.
Note: If you see a dvips or pstopdf invocation in the log, you are not using native PDF output.
Limitations and Practical Checks
- Specials are catcode‑sensitive; if you load packages that change catcodes around your
\\speciallines, the PDF code may break. Wrap specials in a\\begingroup ... \\endgroupto localise catcode changes. - Not all PDF features are supported via specials; for complex forms or JavaScript, consider using the
hyperrefpackage withpdftexdriver. - Older pdfTeX releases (<2008) may not support
\\pdfminornameand\\pdfmajornameprimitives, affecting scripts that query the engine version. - When cross‑platform builds are required, test on the target OS to confirm that the native output path is available.
Summary
If your workflow requires fast, single‑pass PDF generation and you need to embed low‑level PDF objects, enabling \\pdfoutput=1 in pdfTeX is the most straightforward choice. The dvips/pstopdf pipeline adds unnecessary complexity unless you must produce PostScript or are constrained to an old TeX distribution. XeTeX and LuaTeX offer native PDF output with different feature sets; choose them when Unicode or scripting is a priority. Always validate the resulting PDF header and Producer field to confirm that you are indeed using pdfTeX’s native PDF engine.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.