📄 ch25.htm
字号:
number of options, but you don't have to use any of them. Most of the options are
there to override any X resources that you set in <TT>.Xdefaults</TT>. Let's look
at the main window, which consists of a main viewer and control menus, as shown in
Figure 25.3. Now look at the same PostScript file shown in Figure 25.2, and see how
it looks when viewed using ghostview. The difference between the two outputs is that
you can view PostScript files in a native X window with gs. With ghostview, you have
some more power to magnify or shrink the output, view multiple pages, and so on.
A typical zoomed output is shown in Figure 25.4.</P>
<P>Clicking anywhere within the viewport causes a zoom window to pop up. The window
is centered on the location that was clicked. Clicking with the left mouse button
pops up a low-resolution zoom window; with the center mouse button, a medium-resolution
zoom window; and with the right mouse button, a high-resolution zoom window.</P>
<P>The important point is that ghostview needs gs for its rendering. You cannot run
ghostview without gs. You can run gs without ghostview, but your viewing actions
are quite limited.
<H6></H6>
<P><A NAME="Heading10<A HREF="../art/25/25lnx03.jpg"><FONT COLOR="#000077">FIGURE
25.3.</FONT></A><FONT COLOR="#000077"><I> </I></FONT><I>Output from the ghostview
program.</I>
<H6></H6>
<P><A NAME="Heading11<A HREF="../art/25/25lnx04.jpg"><FONT COLOR="#000077">FIGURE
25.4.</FONT></A><FONT COLOR="#000077"> </FONT><I>Zoomed output from the ghostview
program.</I>
<H3 ALIGN="CENTER"><A NAME="Heading12<FONT COLOR="#000077">Output Devices</FONT></H3>
<P>The output from gs is in the native format of the device it thinks it's talking
to. You do not have to run X Window to be able to use the output from gs. The gs
program supports many different output devices. (You do, however, need to run X Window
to be able to use ghostview.)</P>
<P>To list all available devices, type <TT>devicenames ==</TT> in the interactive
environment.</P>
<P>The type of device for gs is set in its command-line argument, <TT>sDEVICE</TT>,
or via the environment variable, <TT>GS_DEVICE</TT>. For example, to set the device
to a deskjet, you would use something like this:</P>
<PRE><FONT COLOR="#0066FF">-sDEVICE=deskjet
</FONT></PRE>
<DL>
<DT><FONT COLOR="#0066FF"></FONT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading13<FONT COLOR="#000077"><B>NOTE:</B> </FONT>Command-line arguments
to gs can appear anywhere on the command line. After these arguments have been specified,
they apply to all subsequent files listed in the command line. These arguments do
not apply to any files specified before the argument. So if you have important arguments
like <TT>sDEVICE</TT>, specify these arguments before you specify the PostScript
file.
<HR>
</DL>
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading14<FONT COLOR="#000077"><B>TIP: </B></FONT>PostScript files
are usually specified with the <TT>.ps</TT> extension.
<HR>
</DL>
<P>The following command generates PostScript output for a specific device:</P>
<PRE><FONT COLOR="#0066FF">gs -sDEVICE=deskjet showme.ps
</FONT></PRE>
<P>In Linux, you do not have to be running X to be able to use gs. The device for
Linux is called <TT>linux</TT>. The device is really the svgalib driver, and you
must have permissions set for being able to write to your console. This is the command
to display a PostScript file on your console:</P>
<PRE><FONT COLOR="#0066FF">$ gs -sDEVICE=linux filename.ps
</FONT></PRE>
<P>You are likely to run into an error if your monitor does not support full color
at 1024x768, the default output resolution. You can change the resolution to a more
reasonable one with the <TT>-r</TT> option. Thirty options are listed in the help
docs for gs, ranging from 320x200x16 all the way to 1280x1024x64K. The one that works
best for text documents is 640x480x2 for a black-and-white rendering on a standard
VGA. Your mileage may vary. The command to render my PostScript then becomes:</P>
<PRE><FONT COLOR="#0066FF">$ gs -sDEVICE=linux -r=640x480x16 filename.ps
</FONT></PRE>
<P>The magnification factor can be set with the <TT>-dMAGSTEP</TT> option. A value
less than 1.0 shrinks the rendered image; a value greater than 1.0 expands it. For
example, to increase the magnification to 2 times the original output, you can use
the following command:</P>
<PRE><FONT COLOR="#0066FF">$ gs -sDEVICE=linux -r=640x480x16 -dMAGSTEP=2.0 filename.ps
</FONT></PRE>
<P>This command shrinks the image to half its size:</P>
<PRE><FONT COLOR="#0066FF">$ gs -sDEVICE=linux -r=640x480x16 -dMAGSTEP=0.5 filename.ps
</FONT></PRE>
<P>The image can be offset from the upper-left-corner default with the <TT>-dX0=</TT>
and <TT>-dY0=</TT> options. Values are given in inches, unless you append with <TT>cm</TT>
for centimeters, or with a percent (<TT>%</TT>) sign as a percentage of the drawing
area.
<H3 ALIGN="CENTER"><A NAME="Heading15<FONT COLOR="#000077">The Screen Blanker</FONT></H3>
<P>If you find that the screen blanks out after rendering its image, you have one
<TT>showpage</TT> directive too many in the PostScript file. A PostScript generating
program generates an extra showpage to force a printer to kick out its recently rendered
image. As far as gs is concerned, it prints a whole new screen for you. So if you
want to avoid this refresh, you should remove the last <TT>showpage</TT> directive
in your source file.</P>
<P>Devices do not have to be listed on the command line with the <TT>sDEVICE</TT>
option. You can define the <TT>GS_DEVICE</TT> environment variable to be your default
device name. This is the order of precedence for these device options:
<DL>
<DD><B>1. </B>Consider any device set in the interactive environment with the <TT>select
device</TT> command. If it's not set, move to the next step.<BR>
<BR>
<B>2. </B>Consider using the command-line argument to the <TT>-sDEVICE=</TT> option.
If it's not set, move to the next step.<BR>
<BR>
<B>3. </B>Use the setting in the <TT>GS_DEVICE</TT> environment variable. If it's
not set, move to the next step.<BR>
<BR>
<B>4.</B> If none of the three preceding options can be used, use the first device
in the list of linked devices.
</DL>
<H3 ALIGN="CENTER"><A NAME="Heading16<FONT COLOR="#000077">Sending Output to
a File</FONT></H3>
<P>You can save the output from gs to a file or pipe it to a device with the <TT>-sOUTPUTFILE=</TT>
or <TT>-sOutputFile=</TT> option. To send the output to a single file, <TT>mine.out</TT>,
with all the pages concatenated, use this command-line argument:</P>
<PRE><FONT COLOR="#0066FF">-sOutputFile=mine.out
</FONT></PRE>
<P>To send the output to a printer, use this argument:</P>
<PRE><FONT COLOR="#0066FF">-sOutputFile=\|lpr
</FONT></PRE>
<P>To send output to standard output, use this option:</P>
<PRE><FONT COLOR="#0066FF">-sOutputFile=-
</FONT></PRE>
<P>(In this case, you must also use the <TT>-q</TT> switch to prevent Ghostscript
from writing messages to <TT>stdout</TT>.)
<H3 ALIGN="CENTER"><A NAME="Heading17<FONT COLOR="#000077">Paper Size Configuration</FONT></H3>
<P>Ghostscript defaults the output page to a U.S. letter-size paper. The command
argument is <TT>-sPAPERSIZE=</TT>. The list of available paper sizes is listed in
<TT>/usr/lib/ghostscript/gs_statd.ps</TT>, which I could not get gs to display. Some
paper sizes that worked are -<TT>sPAPERSIZE=a4</TT>, <TT>-sPAPERSIZE=legal</TT>,
and <TT>-sPAPERSIZE=11x17</TT>. A file's specification overrides any command-line
argument specification for a page size.
<H3 ALIGN="CENTER"><A NAME="Heading18<FONT COLOR="#000077">Environment Variables
for Ghostscript</FONT></H3>
<P>Ghostscript uses the environment variables <TT>GS_LIB</TT>, <TT>GS_LIB_DEFAULT</TT>,
and <TT>GS_FONTPATH</TT> to find files. The names of locations are separated by colons
just as with the <TT>PATH</TT> variable. The gs program always looks in the current
directory for a file, and then it looks in the directories listed in the <TT>GS_LIB</TT>
variable. If nothing for the file is found via <TT>GS_LIB</TT>, it looks via <TT>GS_LIB_DEFAULT</TT>.
The <TT>GS_FONTPATH</TT> environment variable lists the locations of PostScript font
files to add to gs's fonts. You can override these paths with the <TT>-I</TT> command-line
argument to gs.</P>
<P>Temporary files for gs are created in the <TT>/tmp</TT> directory. gs leaves quite
a few dangling temporary files at times. The names of such files begin with <TT>gs_</TT>.
If you see too many of these files in <TT>/tmp</TT> space, you can delete them by
using the <TT>rm /tmp/gs_*</TT> command.
<H3 ALIGN="CENTER"><A NAME="Heading19<FONT COLOR="#000077">Configuring for
X Window</FONT></H3>
<P>Ghostscript looks for the resources under the program name ghostscript and class
name Ghostscript in the <TT>.Xdefaults</TT> file. To set a resource, put the resource
in <TT>.Xdefaults</TT> in the following form:</P>
<PRE><FONT COLOR="#0066FF">Ghostscript*resourceName: value
</FONT></PRE>
<P>Force the server to use these values with this command:</P>
<PRE><FONT COLOR="#0066FF">% xrdb -merge ~/.Xdefaults
</FONT></PRE>
<CENTER>
<P><FONT SIZE="4"><B>Table 25.1 lists the available resources. Table 25.1. Ghostscript
resources. </B></FONT>
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><I>Name</I></TD>
<TD ALIGN="LEFT"><I>Class</I></TD>
<TD ALIGN="LEFT"><I>Default</I></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>background</TT></TD>
<TD ALIGN="LEFT"><TT>Background</TT></TD>
<TD ALIGN="LEFT"><TT>white</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>foreground</TT></TD>
<TD ALIGN="LEFT"><TT>Foreground</TT></TD>
<TD ALIGN="LEFT"><TT>black</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>borderColor</TT></TD>
<TD ALIGN="LEFT"><TT>BorderColor</TT></TD>
<TD ALIGN="LEFT"><TT>black</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>borderWidth</TT></TD>
<TD ALIGN="LEFT"><TT>BorderWidth</TT></TD>
<TD ALIGN="LEFT"><TT>1</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>geometry</TT></TD>
<TD ALIGN="LEFT"><TT>Geometry</TT></TD>
<TD ALIGN="LEFT"><TT>NULL</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>xResolution</TT></TD>
<TD ALIGN="LEFT"><TT>Resolution</TT></TD>
<TD ALIGN="LEFT"><TT>calculated</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>yResolution</TT></TD>
<TD ALIGN="LEFT"><TT>Resolution</TT></TD>
<TD ALIGN="LEFT"><TT>calculated</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>useExternalFonts</TT></TD>
<TD ALIGN="LEFT"><TT>UseExternalFonts</TT></TD>
<TD ALIGN="LEFT"><TT>true</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>useScalableFonts</TT></TD>
<TD ALIGN="LEFT"><TT>UseScalableFonts</TT></TD>
<TD ALIGN="LEFT"><TT>true</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>logExternalFonts</TT></TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -