?? 430-432.html
字號:
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Ghostscript and Ghostview</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=24//-->
<!--PAGES=430-432//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="426-430.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="432-435.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>Redirecting Ghostscript Output</B></FONT></P>
<P>Ghostscript allows you considerable flexibility in redirecting output to other devices. On the command line you can specify a device such as a printer with the <TT>-sDEVICE</TT> option. For example, if you have a device called HPLaser, you could redirect the output of the <TT>gs</TT> command to that printer with the command:</P>
<!-- CODE SNIP //-->
<PRE>
gs -sDEVICE=HPLaser filename.ps
</PRE>
<!-- END CODE SNIP //-->
<P>If you issue this command, you won’t see any output in windows because the output has been redirected. If you specified multiple files on the command line, such as the following, all the files would have been sent to HPLaser:
</P>
<!-- CODE SNIP //-->
<PRE>
gs -sDEVICE=HPLaser file1.ps file2.ps file3.ps
</PRE>
<!-- END CODE SNIP //-->
<P>The redirection is in effect until the command terminates. Of course the device you are redirecting to must exist, or <TT>gs</TT> will return an “unknown device” message. You can see a list of all known devices with the command:</P>
<!-- CODE SNIP //-->
<PRE>
gs -h
</PRE>
<!-- END CODE SNIP //-->
<P>A good chunk of the screen (shown in Figure 24.4) lists the devices that Ghostscript knows about.
</P>
<P>You can use the order of the arguments to play with Ghostscript a little. Since the order in which arguments are given matters to Ghostscript, you can issue a command like the following, which displays <TT>file1.ps</TT> and <TT>file2.ps</TT> on your X session, and then sends <TT>file3.ps</TT> to the device HPLaser:</P>
<!-- CODE SNIP //-->
<PRE>
gs file1.ps file2.ps -sDEVICE=HPLaser file3.ps
</PRE>
<!-- END CODE SNIP //-->
<P>You can change the device on the command line multiple times if you want, so that this next command will send <TT>file1.ps</TT> to the device HPLaser and <TT>file2.ps</TT> to the device CanonBJet:</P>
<!-- CODE SNIP //-->
<PRE>
gs -sDEVICE=HPLaser file1.ps -sDEVICE=CanonBJet file2.ps
</PRE>
<!-- END CODE SNIP //-->
<P>In some cases it’s easier just to issue separate commands; otherwise the <TT>gs</TT> command line gets pretty complicated.</P>
<P>Several other features are built into Ghostscript for modifying output devices. If you have an older dot matrix printer with several resolutions (such as draft and final), you can define different options for Ghostscript to trigger each device. For example, the following command tells Ghostscript to print on the device Epson using the highest resolution (24 pin) available:</P>
<!-- CODE SNIP //-->
<PRE>
gs -sDEVICE=Epson -r360x180
</PRE>
<!-- END CODE SNIP //-->
<P>Since these older devices are disappearing, these command options are fading from general use.
</P>
<P>If for some reason you don’t want to use a printer or screen as output, you can redirect Ghostscript output with the option <TT>-sOutputFile</TT>, like this:</P>
<!-- CODE SNIP //-->
<PRE>
gs -sOutputFile out1.ps file1.ps file2.ps
</PRE>
<!-- END CODE SNIP //-->
<P>Although Linux lets you use pipes and redirection, which are much more capable, this capability was included for those operating systems that are not as powerful as Linux!
</P>
<P><FONT SIZE="+1"><B>Changing Paper Size</B></FONT></P>
<P>By default Ghostscript uses the paper sizes specified in the file <TT>gs_statd.ps</TT>, which is a configuration file for the printing utility. This file has a couple of dozen paper styles predefined for you, such as all the European and U.S. sizes. To use a size other than the default, use the <TT>-sPAPERSIZE</TT> option, followed by the <TT>gs_statd.ps</TT> name that indicates the size you want to use. For example, to use European A4 size, use the command:</P>
<!-- CODE SNIP //-->
<PRE>
gs -sPAPERSIZE=a4 -sDEVICE=HPLaser file1.ps
</PRE>
<!-- END CODE SNIP //-->
<P>If the paper size you want to use is not defined already in the <TT>gs_stats.ps</TT> file, you can modify one of the existing entries or create your own.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>Tip: </B><BR>Sometimes you’ll change the paper size with the <TT>-sPAPERSIZE</TT> option only to find Ghostscript has used another paper size. That’s because PostScript (and hence Ghostscript) allows a particular paper size to be embedded in the contents of a PostScript file. Even though you specify a paper size on the command line, the file’s contents overrule this setting. The only way to correct this problem is to manually edit the PostScript file.<HR></FONT>
</BLOCKQUOTE>
<P><FONT SIZE="+1"><B>Ghostscript Environment Variables</B></FONT></P>
<P>Ghostscript uses a set of environment variables that can alter its behavior. The environment variables used by Ghostscript and their functions are shown in Table 24.2.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 24.2.</B> Ghostscript variables and their meanings.
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="25%" ALIGN="LEFT">Variable
<TH WIDTH="75%" ALIGN="LEFT">What it does
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TD><TT>GS_DEVICE</TT>
<TD>Defines the default output device.
<TR>
<TD><TT>GS_FONTPATH</TT>
<TD>Specifies a list of directories that should be scanned for fonts.
<TR>
<TD VALIGN="TOP"><TT>GS_LIB</TT>
<TD>Provides a search path for initialization files and fonts. Directories in the search path are separated by colons.
<TR>
<TD VALIGN="TOP"><TT>GS_OPTIONS</TT>
<TD>Defines a list of command line arguments to be processed before the ones actually specified on the command line.
<TR>
<TD><TT>TEMP</TT>
<TD>Defines a directory name for temporary files.
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>The <TT>GS_OPTIONS</TT> variable can be used to change the way Ghostscript behaves. For example, the option <TT>GS_DEVICE</TT> can be used to set the device to some value without requiring you to specify it on each command line. <TT>GS_OPTIONS</TT> can contain both arguments and options.</P>
<P>The <TT>TEMP</TT> variable usually points to the <TT>/tmp</TT> directory on Linux systems, but you can change this. When Ghostscript creates a temporary file it starts the filename with <TT>gs_</TT>. Unfortunately, Ghostscript doesn’t always delete these files properly so you may occasionally have to go to your <TT>/tmp</TT> directly and erase any files starting with <TT>gs_</TT>. If you use Ghostscript a lot, the size of this directory can increase dramatically in short order, so keep an eye on it.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="426-430.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="432-435.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -