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

📄 dest.html

📁 java类库详细讲解
💻 HTML
字号:
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Printing to a File
(Java Developers Almanac Example)
</TITLE>
<META CONTENT="Patrick Chan" NAME="AUTHOR">
<META CONTENT="Code Examples from The Java Developers Almanac 1.4" NAME="DESCRIPTION">
<META CONTENT="Addison-Wesley/Patrick Chan" NAME="OWNER">
<META CONTENT="3/20/02" NAME="revision">
<STYLE TYPE="text/css">
<!--     BODY CODE  {font-family: Courier, Monospace;           font-size: 11pt}    TABLE, BODY          {font-family: Verdana, Arial, Helvetica, sans-serif;           font-size: 10pt}    PRE   {font-family: Courier, Monospace;           font-size: 10pt}    H3    {font-family: Verdana, Arial, Helvetica, sans-serif;           font-size: 11pt}    A.eglink {text-decoration: none}    A:hover.eglink {text-decoration: underline}    -->
</STYLE>
</HEAD>
<BODY>
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR>
<TD rowspan="3"><A HREF="/?l=ex"><IMG BORDER="0" ALIGN="BOTTOM" HSPACE="10" SRC="/egs/almanac14a.jpg"></A></TD><TD VALIGN="top"><font face="Times" size="6"><b>The Java Developers Almanac 1.4</b></font>
<br>
        Order this book from <a href="/cgi-bin/scripts/redirect.pl?l=ex&url=http://www.amazon.com/exec/obidos/ASIN/0201752808/xeo">Amazon</a>.
    </TD>
</TR>
<TR>
<TD align="right" valign="bottom">
<FORM method="get" action="/cgi-bin/search/find.pl">
<INPUT size="25" name="words" type="text"><INPUT value="Search" type="submit">
</FORM>
</TD>
</TR>
</TABLE>
<HR color="#6666cc">
<DIV ALIGN="LEFT">
<A HREF="/">Home</A>
    &gt;
    <A HREF="../index.html">List of Packages</A>
    &gt;
    <B><A HREF="../javax.print.attribute.standard/pkg.html">javax.print.attribute.standard</A></B><font color="#666666" SIZE="-2">
        &nbsp;[3 examples]
        </font>
</DIV><P>
  <h3>
    e716.  
    Printing to a File</h3>

There are two ways to print to a file.  One way is to use a streaming
print service (see <a href="../javax.print/BasicStream.html" class="eglink"><font size="-1"><b>e705</b> The Quintessential Printing Program Using a Streaming Printing Service</font></a>) that writes to
an output stream that you supply.  The other is to request that the
print service write directly into a specified file.

This example demonstrates the latter, by using
a <code>Destination</code> print job attribute to specify the 
destination filename. The example prints to a file
called <code>e:\temp\out.ps</code>.

Print job attributes are delivered to the print service via 
the print request attribute set supplied to <code>DocPrintJob.print()</code>.
See <a href="../javax.print/BasicPrint.html" class="eglink"><font size="-1"><b>e704</b> The Quintessential Printing Program Using a Printing Service</font></a> to see how to set up a print job.  


<pre>
    try {
        // Set up destination attribute
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        aset.add(new Destination(new java.net.URI(<font color="#0066ff"><i>"file:e:/temp/out.ps"</i></font>)));
    
        // Print it
        <font color="#0066ff"><i>job</i></font>.print(<font color="#0066ff"><i>doc</i></font>, aset);
    } catch (PrintException e) {
    } catch (java.net.URISyntaxException e) {
    }
</pre>
<P><table width="600" CELLSPACING="0" CELLPADDING="2" BORDER="0">
<tr>
<td bgcolor="#6666cc" align="center"><font color="#ffffff">
            &nbsp;Related Examples
        </font></td>
</tr>
</table>


e714. <a class="eglink" href="Orient.html?l=rel">
    Setting the Orientation of a Print Job -- Portrait or Landscape
</a>
<br>

e715. <a class="eglink" href="NumCopies.html?l=rel">
    Setting the Number of Copies of a Print Job
</a>
<br>


<br>

<br>
<FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="0">
&copy; 2002 Addison-Wesley.
</FONT>
</BODY>
</HTML>

⌨️ 快捷键说明

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