← 返回命令列表

Linux command

ghostscript 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Convert PDF to images

gs -dNOPAUSE -dBATCH -sDEVICE=png16m -r300 -sOutputFile=[page-%d.png] [input.pdf]

Merge PDFs

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=[merged.pdf] [file1.pdf] [file2.pdf]

Compress PDF

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -sOutputFile=[small.pdf] [large.pdf]

Convert PS to PDF

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=[output.pdf] [input.ps]

Extract pages from PDF

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFirstPage=[2] -dLastPage=[5] -sOutputFile=[extract.pdf] [input.pdf]

说明

Ghostscript (gs) is an interpreter for PostScript and PDF. It renders documents to various output formats, converts between formats, and processes print jobs. It is the engine behind many PDF tools and print systems on Unix/Linux. The tool supports a wide range of output devices for rasterization, format conversion, and print processing. PDF manipulation includes merging, splitting, compressing, and converting between quality levels.

参数

-dNOPAUSE
Don't pause between pages.
-dBATCH
Exit after processing.
-sDEVICE _device_
Output device (pdfwrite, png16m, jpeg, etc.).
-sOutputFile _file_
Output filename (use %d for page numbers).
-r _resolution_
Resolution in DPI.
-dPDFSETTINGS _setting_
PDF quality: /screen, /ebook, /printer, /prepress.
-dFirstPage _n_
Start page.
-dLastPage _n_
End page.
-dCompatibilityLevel _ver_
PDF version (1.4, 1.5, etc.).
-q
Quiet mode; suppress startup messages.
-dSAFER
Restrict file operations for safety (default in recent versions).

FAQ

What is the ghostscript command used for?

Ghostscript (gs) is an interpreter for PostScript and PDF. It renders documents to various output formats, converts between formats, and processes print jobs. It is the engine behind many PDF tools and print systems on Unix/Linux. The tool supports a wide range of output devices for rasterization, format conversion, and print processing. PDF manipulation includes merging, splitting, compressing, and converting between quality levels.

How do I run a basic ghostscript example?

Run `gs -dNOPAUSE -dBATCH -sDEVICE=png16m -r300 -sOutputFile=[page-%d.png] [input.pdf]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -dNOPAUSE do in ghostscript?

Don't pause between pages.