⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 use.htm

📁 GhostScript的源代码
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<html>
<head>
<title>How to use Ghostscript</title>
<!-- $Id: Use.htm $ -->
<!-- Originally: use.txt -->
</head>

<body>
<!-- [1.0 begin visible header] -------------------------------------------- -->

<!-- [1.1 begin headline] -------------------------------------------------- -->

<p><table width="100%" border="0">
<tr><th align="center" bgcolor="#CCCC00"><font size=6>
How to use Ghostscript
</font>
</table>

<!-- [1.1 end headline] ---------------------------------------------------- -->

<!-- [1.2 begin table of contents] ----------------------------------------- -->

<h2>Table of contents</h2>

<blockquote><ul>
<li><a href="#Invoking">Invoking Ghostscript</a>
<ul>
<li><a href="#Help_command">Help at the command line: <b><tt>gs -h</tt></b></a>
</ul>
<li><a href="#Pipe_input">Input from a pipe</a>
<li><a href="#Output_device">Selecting an output device</a>
<ul>
<li><a href="#Printer_resolution">Printer resolution</a>
<li><a href="#File_output">Output to files</a>
<ul>
<li><a href="#One_page_per_file">One page per file</a>
<li><a href="#Pipe_output">Output to a pipe</a>
<li><a href="#Output_to_graphics">Output to graphics file formats</a>
</ul>
<li><a href="#Paper_size">Choosing paper size</a>
<li><a href="#Change_default_size">Changing the installed default paper size</a>
</ul>
<li><a href="#Finding_files">How Ghostscript finds files</a>
<ul>
<li><a href="#PS_resources">Finding PostScript Level 2 resources</a>
<li><a href="#Font_lookup">Font lookup</a>
<li><a href="#Temp_files">Temporary files</a>
</ul>
<li><a href="#Environment_variables">Summary of environment variables</a>
<li><a href="#PDF">Using Ghostscript with PDF files</a>
<ul>
<li><a href="#PDF_stdin">PDF files from standard input</a>
<li><a href="#PDF_switches">Switches for PDF files</a>
</ul>
<li><a href="#Platforms">Notes on specific platforms</a>
<ul>
<li><a href="#Unix">Unix</a>
<li><a href="#VMS">VMS</a>
<ul>
<li><a href="#VMS_X_Windows">Using X Windows on VMS</a>
</ul>
<li><a href="#DOS">DOS</a>
<li><a href="#X_Windows">X Windows</a>
<ul>
<li><a href="#X_resources">X resources</a>
<li><a href="#X_server_bugs">Working around bugs in X servers</a>
<li><a href="#X_fonts">X fonts</a>
</ul>
<li><a href="#SCO_Unix">SCO Unix</a>
</ul>
<li><a href="#Switches">Switches</a>
<ul>
<li><a href="#Normal_switches">Normal switches</a>
<ul>
<li><a href="#Input_control">Input control</a>
<li><a href="#File_searching">File searching</a>
<li><a href="#Parameters">Setting parameters</a>
<li><a href="#Quiet">Suppress messages</a>
</ul>
<li><a href="#Special_names">Special names (with <b><tt>-d</tt></b> and <b><tt>-s</tt></b>)</a>
</ul>
<li><a href="#Debugging">Debugging</a>
<li><a href="#Known_paper_sizes">Appendix: Paper sizes known to Ghostscript</a>
<li><a href="#X_font_mappings">Appendix: X default font mappings</a>
<ul>
<li><a href="#Standard_X_server_fonts">Standard X servers</a>
<ul>
<li><a href="#X_regular_fonts">Regular fonts</a>
<li><a href="#X_symbol_fonts">Symbol fonts</a>
<li><a href="#X_dingbat_fonts">Dingbat fonts</a>
</ul>
<li><a href="#OpenWindows_fonts">Sun OpenWindows</a>
</ul>
</ul></blockquote>

<!-- [1.2 end table of contents] ------------------------------------------- -->

<!-- [1.3 begin hint] ------------------------------------------------------ -->

<p>For other information, see the <a href="Readme.htm">Ghostscript
overview</a>, the new user's documentation on
<a href="New-user.htm#Previewers">previewers</a> and, if necessary, how to
<a href="Install.htm">install Ghostscript</a>.

<!-- [1.3 end hint] -------------------------------------------------------- -->

<hr>

<!-- [1.0 end visible header] ---------------------------------------------- -->

<!-- [2.0 begin contents] -------------------------------------------------- -->

<h1><a name="Invoking"></a>Invoking Ghostscript</h1>

<p><a name="Command_line"></a> The command line to invoke Ghostscript is
essentially the same on all systems, although the name of the executable
program itself may differ among systems.  For instance, to invoke
Ghostscript on Unix:

<blockquote>
<b><tt>gs</tt></b> [switches] {filename 1} ... [switches] {filename <em>N</em>} ...
</blockquote>

<blockquote><table cellpadding=0 cellspacing=0>
<tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">Ghostscript's name on different systems</font><hr>
<tr>	<th align=left>System
	<td>&nbsp;&nbsp;
	<th align=left>Ghostscript's name
<tr>	<td colspan=3><hr>
<tr>	<td>Unix
	<td>&nbsp;<td><b><tt>gs</tt></b>
<tr>	<td>VMS
	<td>&nbsp;<td><b><tt>gs</tt></b>
<tr>	<td>DOS &amp; MS Windows 3
	<td>&nbsp;<td><b><tt>gs386</tt></b>
<tr>	<td>MS Windows 95
	<td>&nbsp;<td><b><tt>gswin32</tt></b>
<tr>	<td>MS Windows 95 command line
	<td>&nbsp;<td><b><tt>gswin32c</tt></b>
<tr>	<td>OS/2
	<td>&nbsp;<td><b><tt>gsos2</tt></b>
</table></blockquote>

<p>
Note, though, that on a system with a windowed graphical user interface,
it's common to use Ghostscript through a previewer, so you should read the
<a href="New-user.htm#Previewers">section about previewers</a> in the
documentation for new users.

<p>
Ghostscript is capable of interpreting PostScript, encapsulated PostScript
(EPS), DOS EPS (EPSF), and -- if the executable was built for it -- Adobe
Portable Document Format (PDF).  The interpreter reads and executes the
files in sequence, using the method described under
"<a href="#File_searching">File searching</a>" to find them.  After doing
this, it reads further lines of PostScript language commands from the
primary input stream, normally the keyboard, interpreting each line
separately.  To quit the interpreter, type "<b><tt>quit</tt></b>".  The
interpreter also quits gracefully if it encounters end-of-file or
control-C.

<p>
The interpreter recognizes many <a href="#Switches">switches</a>. A switch
may appear anywhere in the command line, and applies to all files named
after it on the line. Many of the switches include "<b><tt>=</tt></b>"
followed by a parameter.  (However, with the DOS executable
<b><tt>gs386.exe</tt></b> in the standard Ghostscript distribution, you
must use "<b><tt>#</tt></b>" rather than "<b><tt>=</tt></b>", because of a
strange design decision in the Watcom C/C++ run-time library used to build
it.)

<h2><a name="Help_command"></a>Help at the command line: <b><tt>gs -h</tt></b></h2>

<p>
You can get a brief help message by invoking Ghostscript with the
<b><tt>-h</tt></b> or <b><tt>-?</tt></b> switch, like this:

<blockquote><b><tt>
gs -h<br>
gs -?
</tt></b></blockquote>

<p>
(Of course, for "<b><tt>gs</tt></b>" use the right
<a href="#Command_line">command for your system</a>.)  The message shows
for this executable

<ul>
<li>its version
<li>the format of the command to invoke it
<li>a few of the most useful switches
<li>the formats it can interpret
<li>the devices for which it can produce output
<li>where it looks for font files
<li>where and how to send bug reports
</ul>

<h1><a name="Pipe_input"></a>Input from a pipe</h1>

<p>
As noted above, one normally specifies input with file names on the command
line.  However, one can also "pipe" input into Ghostscript by using the
special file name "<b><tt>-</tt></b>", for instance

<blockquote>
{some program producing PS} <b><tt>| gs</tt></b> {...options...} <b><tt>-</tt></b>
</blockquote>

<p>
"<b><tt>-</tt></b>" differs from a named file in two respects:

<ol>
<li>When Ghostscript finishes reading from the pipe, it quits rather than
going into interactive mode.  Because of this, "<b><tt>-</tt></b>" is
really only useful as the last argument on the command line.

<li>"<b><tt>-</tt></b>" can't be used to pipe PDF input to Ghostscript.
See "<a href="#PDF">Using Ghostscript with PDF files</a>" below.
</ol>

<h1><a name="Output_device"></a>Selecting an output device</h1>

<p>
Ghostscript may be built to handle multiple output devices, and it normally
opens and directs output to the first one built in.  Ghostscript's
<b><tt>gs&nbsp;-h</tt></b> <a href="#Help_command">help message</a> lists
the output devices known to the executable.  Once you invoke Ghostscript
you can also find out what devices are available by
"<b><tt>devicenames&nbsp;==</tt></b>" at its command prompt.

<p><a name="Source_code"></a>

A little more information about devices appears near the beginning of the
files <b><tt>devs.mak</tt></b> (for Aladdin's own drivers) and
<b><tt>contrib.mak</tt></b> (for user-contributed drivers) used to build
Ghostscript.  (If you got Ghostscript under the Aladdin
<a href="Public.htm">Free Public License</a>, the person or place from
which you got it is also required to make the source code available to you;
if you got it under the GNU General Public License (GPL), see the GNU
<a href="http://www.gnu.org/copyleft/gpl.html">General Public License</a>
for more information.)

<p><a name="Device_output"></a>
To use device <em>xyz</em> as the initial output device, use the
command-line switch

<blockquote>
	<b><tt>-sDEVICE=</tt></b><em>xyz</em>
</blockquote>

<p>
Note that this switch must precede the name of the first input file, and
only its first use has any effect.  For example, for printer output in a
configuration that includes an Epson printer driver, instead of just
"<b><tt>gs&nbsp;myfile.ps</tt></b>" you might use

<blockquote>
	<b><tt>gs -sDEVICE=epson myfile.ps</tt></b>
</blockquote>

<p>
Alternatively, once you invoke Ghostscript and have its own command prompt
you can type

<blockquote><b><tt>
	(epson) selectdevice<br>
	(myfile.ps) run
</tt></b></blockquote>

<p>
All output then goes to the Epson printer instead of the display until you
do something to change devices.  You can switch devices at any time by
using the <b><tt>selectdevice</tt></b> procedure, for
instance like one of these:

<blockquote><b><tt>
	(vga) selectdevice<br>
	(epson) selectdevice
</tt></b></blockquote>

<p><a name="GS_DEVICE"></a>
A third possibility is to define an environment variable
<b><tt>GS_DEVICE</tt></b> with the name of your desired default device.
The order of precedence for these alternatives, highest to lowest, is:

<blockquote><table cellpadding=0 cellspacing=0>
<tr>	<td><b><tt>selectdevice</tt></b>
	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<td>Highest precedence
<tr>	<td>(command line)
	<td>&nbsp;
	<td>&nbsp;
<tr>	<td><b><tt>GS_DEVICE</tt></b>
	<td>&nbsp;
	<td>&nbsp;
<tr>	<td>(first device built in)
	<td>&nbsp;
	<td>Default; lowest precedence
</table></blockquote>

<h2><a name="Printer_resolution"></a>Printer resolution</h2>

<p>
Some printers can print at several different resolutions, letting you
balance resolution against printing speed.  To select the resolution on
such a printer, use the <b><tt>-r</tt></b> switch:

<blockquote>
	<b><tt>gs -sDEVICE=</tt></b><em>printer</em><b><tt> -r</tt></b><em>XRES</em><b><tt>x</tt></b><em>YRES</em>
</blockquote>

<p>
For example, on Epson-compatible printers you have these choices:

<blockquote><table cellpadding=0 cellspacing=0>
<tr>	<td><b><tt>gs -sDEVICE=epson</tt></b>
	<td>&nbsp;&nbsp;
	<td><b><tt>-r60x72</tt></b>
	<td>&nbsp;&nbsp;
	<td>9-pin
	<td>&nbsp;&nbsp;
	<td>lowest resolution
	<td>&nbsp;&nbsp;
	<td>fastest
<tr>	<td>&nbsp;
	<td>&nbsp;
	<td><b><tt>-r240x72</tt></b>
	<td>&nbsp;
	<td>&nbsp;
	<td>&nbsp;
	<td>highest
	<td>&nbsp;
	<td>slowest
<tr>	<td>&nbsp;
<tr>	<td>&nbsp;
	<td>&nbsp;
	<td><b><tt>-r60x60</tt></b>
	<td>&nbsp;
	<td>24-pin
	<td>&nbsp;
	<td>lowest
	<td>&nbsp;
	<td>fastest
<tr>	<td>&nbsp;
	<td>&nbsp;
	<td><b><tt>-r360x180</tt></b>
	<td>&nbsp;
	<td>&nbsp;
	<td>&nbsp;
	<td>highest
	<td>&nbsp;
	<td>slowest
</table></blockquote>

<h2><a name="File_output"></a>Output to files</h2>

<p>
If you select a printer as the output device, Ghostscript also allows you
to control where the device sends its output.  On DOS systems, output
normally goes directly to the printer (<b><tt>PRN</tt></b>);
on Unix or VMS systems normally to a temporary file for later printing.  To
send the output to a file, use the
<b><tt>-sOutputFile=</tt></b> switch (for compatibility with
older versions of Ghostscript, <b><tt>-sOUTPUTFILE=</tt></b>
also works).  For instance, to direct all output into the file
<b><tt>ABC.xyz</tt></b>, use

<blockquote><b><tt>
gs -sOutputFile=ABC.xyz
</tt></b></blockquote>

<h3><a name="One_page_per_file"></a>One page per file</h3>

<p>
You can also tell Ghostscript to put each page of output in a separate
file.  To send output to a series of files each representing a single page,
use in the filename the <b><tt>printf</tt></b> format specifier
"<b><tt>%d</tt></b>" (or its extended form like "<b><tt>%02d</tt></b>");
for instance

<blockquote><table cellpadding=0 cellspacing=0>
<tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">"%{n}d" in <b><tt>-sOutputFile=</tt></b></font><hr>
<tr valign=bottom>
	<th align=left>Output specification
	<td>&nbsp;&nbsp;&nbsp;
	<th align=left>Produces the series of 1-page files
<tr>	<td colspan=3><hr>
<tr valign=top>	<td><b><tt>-sOutputFile=ABC%d.xyz</tt></b>
	<td>&nbsp;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -