pdftops Command in Linux


The pdftops command in Linux converts PDF files to PostScript (PS) format. The PostScript format makes them suitable for printing. Many printers and print servers use PostScript as their native language, so converting PDFs to PS ensures better compatibility and print quality.

Table of Contents

Here is a comprehensive guide to the options available with the pdftops command −

Syntax of pdftops Command

The syntax of the pdftops command in Linux is as follows −

pdftops [options] [pdfFile] [<psFile>]

In the above syntax, the [options] field is used to specify various options to change the output format. The [pdfFile] field is used to specify the PDF file that needs to be converted to PostScript format. The [<psFile>] field is optional and used to set the name of the output PostScript file. If not provided, the output PS file will have the same name as the input PDF file but with a .ps extension.

pdftops Command Options

The options of the Linux pdftops command are listed below −

Option Description
-f number Specifies the first page to convert.
-l number Specifies the last page to convert.
-level1 Generates Level 1 PostScript (monochrome, larger file size).
-level1sep Generates Level 1 separable PostScript (CMYK conversion).
-level2 Generates Level 2 PostScript (supports color and compression).
-level2gray Generates grayscale Level 2 PostScript.
-level2sep Generates Level 2 separable PostScript with CMYK conversion.
-level3 Generates Level 3 PostScript (adds CID font embedding).
-level3gray Generates grayscale Level 3 PostScript.
-level3sep Generates Level 3 separable PostScript (same as -level2sep).
-eps Generates Encapsulated PostScript (EPS) for single-page output.
-form Generates a PostScript form (single page).
-opi Generates OPI comments for images and forms with OPI info.
-noembt1 Disables embedding of Type 1 fonts.
-noembtt Disables embedding of TrueType fonts.
-noembcidps Disables embedding of CID PostScript fonts.
-noembcidtt Disables embedding of CID TrueType fonts.
-preload Converts PDF forms to PS procedures and preloads images.
-paper size Sets paper size (letter, legal, A4, A3, or match).
-paperw size Sets custom paper width in points.
-paperh size Sets custom paper height in points.
-nocrop Disables cropping to the PDF's CropBox.
-expand Expands smaller PDF pages to fill the paper.
-noshrink Prevents scaling down pages larger than the paper.
-nocenter Aligns pages to the lower-left instead of centering.
-pagecrop Treats the CropBox as the page size instead of MediaBox.
-userunit Honors UserUnit settings for page sizing.
-duplex Enables duplex printing for compatible printers.
-opw password Specifies the owner password to bypass security restrictions.
-upw password Specifies the user password for the PDF file.
-verbose Prints status messages while processing.
-q Suppresses messages and errors.
-cfg file Uses a custom configuration file instead of the default.
-v Displays version and copyright information.
-h Displays usage information.

Examples of pdftops Command in Linux

In this section, the usage of the pdftops command in Linux will be discussed with examples −

  • Converting a PDF File to PostScript Format
  • Converting Specific Pages of a PDF File to PostScript Format
  • Generating Level 1 PostScript
  • Disabling Font Embedding
  • Setting Paper Size
  • Expanding Smaller PDF Pages to Fit the Paper Size
  • Preventing Shrinking
  • Enabling Duplex Printing
  • Setting Custom Paper Size
  • Displaying Usage Help

Converting a PDF File to PostScript Format

To convert a PDF file to PostScript (PS) format, use the pdftops command in the following way −

pdftops file.pdf
pdftops Command in Linux1

The above command converts the PDF file and saves the converted file in the current working directory with the same name as the PDF file.

To save the PostScript (PS) file with a different name, specify it as an argument after the PDF file name −

pdftops file.pdf PostScriptFile.ps
pdftops Command in Linux2

Converting Specific Pages of a PDF File to PostScript Format

To convert the specific pages of the PDF file to PostScript (PS), use the -f and -l options for the first and last page, respectively. For example, to convert a PDF file from page 1 to 3, use the following command −

pdftops -f 1 -l 3 file.pdf
pdftops Command in Linux3

The above command converts only pages 1 to 3.

Generating Level 1 PostScript

To generate the level 1 PostScript file, use the -level1 option with the pdftops command −

pdftops -level1 file.pdf

Level 1 output is a monochrome PostScript file compatible with older printers, lacking color support and image compression.

pdftops Command in Linux4

Disabling Font Embedding

To disable the font embedding in the PostScript (PS) file, use the -noembt1 and -noembtt options −

pdftops -noembt1 -noembtt file.pdf

Setting Paper Size

To set the paper size of the output file, use the -paper option. For example, to set the A4 size, use the following command −

pdftops -paper A4 file.pdf

Other sizes that can be specified are listed below −

  • letter
  • legal
  • A3
  • match (uses the PDF's specified paper size)

Expanding Smaller PDF Pages to Fit the Paper Size

By default, the pages are not scaled. To expand PDF pages smaller than the paper to fill the paper, use the -expand option −

pdftops -expand file.pdf

Preventing Shrinking

By default, pages larger than the paper size are shrunk to fit. To prevent the shrinking, use the -noshrink option −

pdftops -noshrink file.pdf

Enabling Duplex Printing

If the printer supports duplex printing, the -duplex option generates a duplex-enabled PostScript file −

pdftops -duplex file.pdf

Duplex printing is printing on both sides of a sheet to save paper and reduce costs.

Setting Custom Paper Size

To set the custom paper size, use the -paperh and -paperw options. For example, to set the paper width as 720 and height as 1280 then use the pdftops command in the following manner −

pdftops -paperw 720 -paperh 1280 input.pdf

Displaying Usage Help

To display the usage help of the pdftops command, use the -h or --help option −

pdftops -h

Conclusion

The pdftops command in Linux is a useful tool for converting PDF files to PostScript format, ensuring better compatibility with printers and print servers. It offers various options to customize the output, such as selecting specific pages, setting paper size, adjusting scaling, and controlling font embedding. By using the appropriate options, different levels of PostScript can be generated, and features like duplex printing can be enabled.

In this tutorial, we covered the pdftops command, its syntax, options, and usage in Linux with examples.

Advertisements