- Unix Commands Reference
- Unix Commands - Home
dvipdf Command in Linux
The Linux dvipdf command converts the TeX DVI file to PDF using the Ghostscript and DVI-to-Postscript tools (dvips).
The Device Independent file or DVI file is the output file format of TeX, LaTeX, and other text formatting programs. These files are converted to PDF for reading and printing purposes. However, they can also be viewed through DVI viewers.
Table of Contents
Here is a comprehensive guide to the options available with the dvipdf command −
- Prerequisites to Use the dvipdf Command
- Syntax of dvipdf Command
- Creating a DVI File
- dvipdf Command in Linux to Convert a DVI File to PDF
- dvipdfmx Command in Linux to Convert a DVI File to PDF
- Example of dvipdfmx Command in Linux
Prerequisites to Use the dvipdf Command
The dvipdf is a part of texlive binaries. It may not be installed on Linux. However, it can be easily installed.
To install texlive on Ubuntu, Debian and Debian-based distributions, use −
sudo apt install texlive-base
To install texlive on Fedora, use −
sudo dnf install texlive-scheme-basic
To install it on Arch Linux, use −
sudo pacman -S texlive-most
To verify the installation of dvipdf binary, execute the following command −
which dvipdf
Moreover, ensure that the DVI-to-Postscript and Ghostscript are also installed.
dvips --version ghostscript --version
If these tools are not installed, install them according to the distribution’s instructions.
Syntax of dvipdf Command
The syntax of the Linux dvipdf command is as follows −
dvipdf [file.dvi] [file.pdf](optional)
The [file.dvi] field is used to mention the dvi file name. While [file.pdf] is optional, it can only be used to save the PDF by a specific name.
Creating a DVI File
The DVI file is the output file of the LaTeX document. This file format is designed to be independent of the device. To generate the DVI file, compile a TeX or LaTeX document.
Ensure that LaTeX is installed on Linux by checking its version −
latex --version
If it shows a version, it means LaTeX is installed.
To create a DVI file of a TeX file, use the latex command −
latex testfile.tex
It will generate three files: .aux, .log, and .dvi.
dvipdf Command in Linux to Convert a DVI File to a PDF
This section demonstrates the usage of the dvipdf command in Linux −
Creating a PDF from a DVI File
To generate a PDF file, use the dvipdf command with the DVI filename.
dvipdf testfile.dvi
This command will generate a PDF file with the same name in the current working directory.
Creating a PDF from a DVI File with a Different Name
To generate the PDF file with a different name, mention the file name
dvipdf testfile.dvi testpdf.pdf
dvipdfmx Command in Linux to Convert a DVI File to PDF
The dvipdf has an enhanced version called dvipdfmx. To check its availability in Linux, use −
which dvipdfmx
The syntax of dvipdfmx is mentioned below −
dvipdfmx [options] [file.dvi] -o [file.pdf]
Unlike dvipdf, the dvipdfmx command offers various options to customize the PDF file output which can be specified in the [options] field. The -o option is used to specify the output file.
The options that can be used with dvipdfmx are listed below −
Options | Description |
---|---|
-c | It ignores colors to produce black and white document |
-h | --help | To display the help related to command |
-l | To generate PDF in landscape |
-m mag | To magnify the input file by mag |
-o filename | It is used to specify the output filename. |
-p paper | It is used to specify the paper size such as a3, a4, a5, letter, legal, ledger, tabloid |
-q | Producing PDF in quiet mode |
-r size | It is used to set the DPI; the default is 600 |
-v | -vv | To get the verbose output |
-x offset | To set the x-axis offset in pb, pt, cm and in (default left margin is 1in) |
-y offset | To set the y-axis offset in pb, pt, cm and in (default top margin is 1in) |
-z number | To set the compression level 0-9 using zlib (default is 9) |
--version | To display the command version |
Note − The options mentioned above cannot be used with the dvipdf command. These options can only be used with the dvipdfmx command.
Example of dvipdfmx Command in Linux
Examples of using the dvipdfmx command for DVI file conversion in Linux are mentioned below −
1. To set the custom page size of the PDF file, use the -p option with the page size. For example, to set the page size to A4, use −
dvipdfmx -p a4 testfile.dvi -o testpdf.pdf
Other page size options are a3, a5, letter, legal, ledger, and tabloid. The -o option is used to specify the output file name.
2. The default DPI is set to 600, to modify it use the -r option −
dvipdfmx -r 400 testfile.dvi -o testpdf.pdf
3. The default left and top margins are 1in, they can be modified using the -x and the -y options −
dvipdfmx -x 1.5in -y 1.5in testfile.dvi -o testpdf.pdf
The offset can be specified in pb, pt, and cm.
4. The dvipdfmx uses the highest compression level by default, however, it can be modified using the -z option −
dvipdfmx -z 4 testfile.dvi -o testpdf.pdf
The compression level can be set from 0 to 9. 0 means no compression while 9 means the highest compression.
5. To generate PDF in landscape mode, use the -l option −
dvipdfmx -l testfile.dvi -o testpdf.pdf
Conclusion
The dvipdf command in Linux converts the DVI file to PDF. The DVI stands for DeVice Independent, which means this file format can generate output for different devices or screens.
The dvipdf command is a basic command that simply generates a PDF from DVI files. It has an enhanced version called dvipdfmx. It comes with various options to modify the PDF documents, such as page size, DPI, and orientation.
In this tutorial, we covered the dvipdf command, its syntax, and usage through various examples.