← 返回命令列表

Linux command

gs 命令

文件

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

常用示例

View

gs -dQUIET -dBATCH file.pdf

Reduce

gs -dNOPAUSE -dQUIET -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -sOutputFile=output.pdf input.pdf

Example

gs -dQUIET -dBATCH -dNOPAUSE -sDEVICE=jpeg -r150 -sOutputFile=output_%d.jpg input.pdf

Example

gs -dQUIET -dBATCH -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=3 -sOutputFile=page%d.jpg input.pdf

Merge

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

Example

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

Example

gs -h

说明

gs (Ghostscript) is an interpreter for Adobe PostScript and PDF languages. It can convert between formats, render to various output devices, and process PDF and PostScript files. Ghostscript is widely used for PDF manipulation including merging, splitting, compressing, and converting to image formats. The -dPDFSETTINGS preset controls quality and file size: /screen (lowest), /ebook, /printer, /prepress (highest).

参数

-sDEVICE=DEVICE
Select output device (pdfwrite, jpeg, png16m, etc.)
-sOutputFile=FILE
Specify output filename (use %d for page numbers)
-r RES or -rXRESxYRES
Set output resolution in DPI
-dPDFSETTINGS=SETTING
PDF quality preset (/screen, /ebook, /printer, /prepress)
-dNOPAUSE
Do not pause between pages
-dBATCH
Exit after processing files
-dQUIET or -q
Suppress normal output messages
-dSAFER
Restrict file operations (default)
-dFirstPage=N
Start from page N
-dLastPage=N
Process through page N
-sPAPERSIZE=SIZE
Set paper size (a4, letter, legal, etc.)
-I DIRECTORIES
Add library search paths
-h or -?
Display help and available devices

FAQ

What is the gs command used for?

gs (Ghostscript) is an interpreter for Adobe PostScript and PDF languages. It can convert between formats, render to various output devices, and process PDF and PostScript files. Ghostscript is widely used for PDF manipulation including merging, splitting, compressing, and converting to image formats. The -dPDFSETTINGS preset controls quality and file size: /screen (lowest), /ebook, /printer, /prepress (highest).

How do I run a basic gs example?

Run `gs -dQUIET -dBATCH file.pdf` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -sDEVICE=DEVICE do in gs?

Select output device (pdfwrite, jpeg, png16m, etc.)