Home / Alt manpages / dvipdf(1)

  • dvipdf(1)
  • User command
  • linux

Convert a TeX DVI file to PDF with dvipdf

This guide takes a TeX DVI file and produces a PDF beside it, with a deliberate check for the two programs that do the real work. Allow about five minutes if TeX Live is already installed, or longer if the DVI toolchain needs adding. The examples use Ghostscript 10.02.1, the version packaged on this machine.

Before you start

dvipdf is a wrapper, not a DVI interpreter on its own. It sends the DVI through dvips, then pipes the resulting PostScript to Ghostscript's pdfwrite device. You need a readable .dvi file, dvipdf, dvips, and gs on your PATH.

Run this ordinary, read-only check from the directory containing your input:

$ command -v dvipdf dvips gs
/usr/bin/dvipdf
/usr/bin/dvips
/usr/bin/gs

The exact paths can differ. If the command stops after dvipdf, do not start a conversion yet: this installation has the wrapper but not the TeX program it invokes. On Ubuntu, dvips is supplied by the texlive-binaries package. Installing packages changes the system, so confirm the package name and your normal change-control process first:

$ sudo apt update
$ sudo apt install texlive-binaries

There is no need for sudo for the conversion itself. Keep the input and destination in a directory where your user can read and write.

Checkpoint: inspect the wrapper's contract

Check the local usage text before relying on a remembered option:

$ dvipdf
Usage: dvipdf [options...] input.dvi [output.pdf]

The manual describes the same two positional arguments. The first is required. The second is optional and names the PDF to write. With one argument, the wrapper derives the destination by removing a final .dvi suffix and adding .pdf. For example, notes.dvi becomes notes.pdf. If the input has another extension, the wrapper uses its complete basename and appends .pdf.

1. Convert to the default PDF name

Use this when the derived name is safe and does not already contain a useful document:

$ dvipdf notes.dvi

For notes.dvi, check the result explicitly:

$ file notes.pdf
notes.pdf: PDF document, version 1.x, ...
$ test -s notes.pdf && echo 'PDF exists and is non-empty'
PDF exists and is non-empty

The version and the rest of file's description depend on the generated document, so do not treat the example line as a fixed byte-for-byte result.

2. Choose the output path

Give a second positional argument when the PDF belongs in another directory or needs a different name:

$ mkdir -p ./pdf-output
$ dvipdf notes.dvi ./pdf-output/notes-review.pdf
$ file ./pdf-output/notes-review.pdf

mkdir -p is harmless when the directory already exists, but dvipdf will not create a missing destination directory for you. It can overwrite an existing output path. Before running a command that names an existing PDF, check it first:

$ if test -e ./pdf-output/notes-review.pdf; then
>     echo 'Refusing to overwrite an existing PDF'
> else
>     dvipdf notes.dvi ./pdf-output/notes-review.pdf
> fi

If you did overwrite a file, dvipdf has no undo operation. Recover it from your backup or versioned storage. For routine work, choose a new output name or make a copy before conversion.

3. Pass options carefully

Options beginning with a hyphen are passed to Ghostscript, except options beginning with -R, which the wrapper passes to dvips. The manual confirms that command-line options reach Ghostscript and that the wrapper supplies quiet, non-interactive PDF-writing settings itself. This means an option intended for one program can fail in the other, so check man dvips or man gs before adding one.

For a first conversion, omit extra flags. The wrapper already runs Ghostscript with -dNOPAUSE, -dBATCH, and -sDEVICE=pdfwrite, then sets the output with -sOutputFile. The installed script also enables Ghostscript's safer mode. Do not copy options from an unrelated Ghostscript example without checking their effect on this pipeline.

4. Diagnose a failed conversion

First confirm that the input exists and is readable:

$ test -r notes.dvi && echo 'input is readable'
input is readable
$ ls -lh notes.dvi

Then check both dependencies again. A missing dvips commonly produces a shell error even though dvipdf itself is installed. A missing gs prevents the second half of the pipeline from running. Reinstall or repair the package that owns the missing command, then repeat the check.

A failed pipeline can leave a partial PDF at the destination. Treat that file as untrusted output: inspect its size and remove it only after confirming it is the failed conversion, not a previous document. The removal below is irreversible:

$ file ./pdf-output/notes-review.pdf
$ rm -- ./pdf-output/notes-review.pdf

Only use that cleanup command when the path is exactly the disposable output you intend to remove. If the input is malformed or the conversion reports a TeX font or PostScript error, keep the diagnostic text and fix the source or TeX installation before trying again.

Done means

  • command -v dvipdf dvips gs finds all three commands.
  • The intended DVI file is readable and was not changed.
  • The requested PDF path exists, is non-empty, and passes file as a PDF document.
  • You checked for an existing destination before allowing an overwrite.