Diewuxi

Belive tomorrow will be better, love science and technology, support communication and understanding, always ready for thought turn.

Blog / engineering_technology / computer / software / document / pdf / ghostscript 笔记

Blog


Article^ Parent

ghostscript 笔记


Date: 2020-03-16 00:00:00
Description: ghostscript 使用笔记。
Keywords: ghostscript, pdf
Category: engineering_technology/computer/software/document/pdf
Tag: ghostscript, note, pdf
Link: https://www.diewuxi.com/blog/article/77.html

Changelog

* 2020-08-18
    * Add grammer
* 2020-03-16
    * Add 压缩
                        

Grammer

gs [options] {filename 1} ... [options] {filename N} ...
                        

Here are some basic examples. The details of how these work are described below.

To view a file:

gs -dSAFER -dBATCH document.pdf
                        

You'll be prompted to press return between pages.

To convert a figure to an image file:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 \
    -sOutputFile=tiger.png tiger.eps
                        

To render the same image at 300 dpi:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 \
                -sOutputFile=tiger_300.png tiger.eps
                        

To render a figure in grayscale:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -sOutputFile=figure.png figure.pdf
                        

To rasterize a whole document:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pgmraw -r150 \
                -dTextAlphaBits=4 -sOutputFile='paper-%00d.pgm' paper.ps
                        

There are also a number of utility scripts for common to convert a PostScript document to PDF:

ps2pdf file.ps
                        

The output is saved as file.pdf.

压缩

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=foo-compressed.pdf foo.pdf
                        

CompatibilityLevel 用于控制pdf 的版本,默认1.4 一般不变

PDFSETTINGS 用于控制导出文件质量:

/screen 选择类似于Acrobat Distiller“屏幕优化”设置的低分辨率输出。(生成文件最小)
/ebook 选择类似于Acrobat Distiller“电子书”设置的中等分辨率输出。
/printer 选择类似于Acrobat Distiller“打印优化”设置的输出。
/prepress 选择类似于Acrobat Distiller“印前优化”设置的输出。
/default 选择意图在各种用途中有用的输出,这可能是以较大的输出文件为代价的。
                        

Last modified: 2020-08-18

Comments [0]

There is no comments now.

Write comment(* is necessary, and email is not shown to public)


Diewuxi 2017--2024