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

📄 在java中轻松打印文档__天极yesky1.htm

📁 java swing DocumentRenderer,all jdk。
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0038)http://www.yesky.com/237/1709237.shtml -->
<HTML lang=zh-CN xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>在Java中轻松打印文档__天极Yesky</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META http-equiv=Content-Language content=zh-CN>
<META content=all name=robots>
<META content="index, follow" name=googlebot>
<META content="MSHTML 6.00.2800.1561" name=GENERATOR>
<META content="天极Yesky | 全球中文IT第一门户" name=author>
<META content="天极Yesky | 全球中文IT第一门户" name=Copyright>
<META 
content=Java,在Java中轻松打印文档,本文就将介绍这样一个对象――DocumentRenderer,它将一个文档作为方法中的一个参数并处理指定任务来完成打印,在Java中轻松打印文档 
name=description></META>
<META content=Java,硬件,软件,数码,游戏,e时代,下载,社区,评测,笔记本; name=keywords><LINK media=all 
href="在Java中轻松打印文档__天极Yesky1.files/y_newcontent.css" type=text/css 
rel=stylesheet>
<SCRIPT language=JavaScript 
src="在Java中轻松打印文档__天极Yesky1.files/newcontentjs.js"></SCRIPT>
</HEAD>
<BODY><!--头部-->
<SCRIPT src="在Java中轻松打印文档__天极Yesky1.files/y_newcontenthead_0608.js"></SCRIPT>
<!--当前位置开始-->
<DIV id=currentposition><SPAN>您现在的位置: <A 
href="http://www.yesky.com/">天极Yesky</A> &gt; <A 
href="http://soft.yesky.com/">软件</A> &gt; <A 
href="http://dev.yesky.com/">开发者网络</A> </SPAN><SPAN 
style="PADDING-LEFT: 240px"><SPAN id=ad2></SPAN></SPAN></DIV><!--当前位置结束--><!--正文开始-->
<DIV id=contentarea><!--左部开始-->
<DIV id=contentleft><!--左部的右部开始-->
<DIV id=contentright1><!--文章内容开始-->
<DIV class="left fontsize2">在Java中轻松打印文档</DIV>
<DIV class=fontclear></DIV><BR>
<DIV class=left><SPAN class=span>作者:sadly</SPAN><SPAN 
class=span>出处:论坛</SPAN><SPAN class=span>责任编辑:<A title=向本编辑提问 
href="http://comments.yesky.com/t/·&frac12;&Ouml;&Ucirc;/6,324/1709237.shtml"> 方舟 </A></SPAN><SPAN 
class=span>[ 2003-06-20 12:39 ]</SPAN></DIV>
<DIV class=fontclear></DIV>
<DIV 
class="left fontsize3">本文就将介绍这样一个对象――DocumentRenderer,它将一个文档作为方法中的一个参数并处理指定任务来完成打印</DIV>
<DIV class=fontclear></DIV>
<HR class=hr1>

<CENTER><SPAN id=ad9></SPAN></CENTER>
<DIV class="left fontsize4">
<DIV class=guanggao><SPAN id=ad3></SPAN></DIV>
<DIV class=guanggao><SPAN id=contentAdv></SPAN></DIV><IFRAME 
src="在Java中轻松打印文档__天极Yesky1.files/dell-240200.htm" frameBorder=0 width=578 
scrolling=no 
height=62></IFRAME><BR><BR>  有关在Java中实现文档打印的典型说法描述了一个复杂的过程,它要求对字体进行测定、对文本进行解析并将结果绘制到一个Graphics对象中。这个过程似乎执行起来相当困难,并且它和用于文档视频显示的高级编程方法不一致。如果你想要花费大量的精力来完成这个过程,那么你就不会首先想到要在Java中编程。<IFRAME 
align=right marginWidth=0 marginHeight=0 
src="在Java中轻松打印文档__天极Yesky1.files/develop_java.htm" frameBorder=0 width=360 
scrolling=no height=300></IFRAME> 
<P>  你一定不想自己完成测定、解析和绘制过程,而是希望通过简单地将文档发送到一个能为你处理所有事情的对象中来完成这个任务。本文就将介绍这样一个对象――DocumentRenderer,它将一个文档作为方法中的一个参数并处理指定任务来完成打印。比如,用这个类来显示一个HTML文档需要两个步骤:构造一个DocumentRenderer类的实例并将HTML文档作为参数发送到print(HTMLDocument)方法中。DocumentRenderer类用于处理打印该文档所必需的开销,包括显示一个打印对话框以及格式化文本。</P>
<P>  我们设计了这个DocumentRenderer类以便利用这个已经在Java中可用的高级文本性能。 
根据可重用和可扩展类的原则,我们使用了一些现有的对象(Java.Swing.Text 
Package用它来对显示结果进行格式化)使打印结果能够显示在纸上。用这种方法设计DocumentRenderer使我们能够用比前面讨论过的方法少写近200行的代码来建立这个类。</P>
<P>  除了能少写代码之外,使用DocumentRenderer 
实现中的现有对象还提供了一些额外的功能使得该类更加通用。在最初设计这个类的时候,我们只是打算将HTML文档打印出来。而添加一些功能来打印其他类型的文档则是后来的想法。当我们发现只需在用于HTML 
打印类的代码中加上约6行的额外代码就可以打印一个Rich Text Format文档时,便在这个项目的后期添加了这个功能。</P>
<P></P>
<DIV class=right>共4页。 <A class=page 
href="http://www.yesky.com/237/1709237.shtml" target=_self><FONT 
color=#666666><B>1</B></FONT></A> <A class=page 
href="http://www.yesky.com/237/1709237_1.shtml" target=_self><B>2</B></A> <A 
class=page href="http://www.yesky.com/237/1709237_2.shtml" 
target=_self><B>3</B></A> <A class=page 
href="http://www.yesky.com/237/1709237_3.shtml" target=_self><B>4</B></A> <A 
class=page href="http://www.yesky.com/237/1709237_1.shtml" target=_self><FONT 
face=Webdings>8</FONT></A> <A class=page 
href="http://www.yesky.com/237/1709237_3.shtml" target=_self><FONT 
face=Webdings>:</FONT></A></DIV></DIV>
<DIV class=fontclear></DIV>
<HR class=hr1>

<DIV class=left><SPAN id=ad7></SPAN></DIV>
<DIV class=fontclear></DIV>
<HR class=hr1>
<!--文章内容结束--><!--文章评论开始--><A name=tlwb></A>
<SCRIPT language=JavaScript>
<!--
var aid = 1709237;
var channelid = 324;
var tagname = "Java";
//-->
</SCRIPT>

<DIV class=photobox id=Layer11><A name=plpl></A>
<SCRIPT src="在Java中轻松打印文档__天极Yesky1.files/comments.js"></SCRIPT>
</DIV><SPAN id=commentsSpanText></SPAN>
<SCRIPT language=javascript><!--if(typeof(aid) != "undefined") {		document.write("<script language=\"JavaScript\" charset=\"gb2312\"  src=\"http://comments.yesky.com/articlereplies/6/"+(aid%5000)+"/"+aid+".js\"><\/script>"); }//--></SCRIPT>

<DIV class=left>
<DIV class=left><IMG 
src="在Java中轻松打印文档__天极Yesky1.files/y_newcontent27.gif"></DIV>
<DIV class=right><IMG 
src="在Java中轻松打印文档__天极Yesky1.files/y_newcontent28.gif"></DIV></DIV>
<DIV class=fontclear style="HEIGHT: 5px"></DIV><!--文章评论结束--><!--相关厂商开始--><A 
name=xgcs></A><!-- Error --><!--相关厂商结束--><!--相关产品开始--><A name=xgcp></A><!-- Error --><!--相关产品结束--><!--文字广告开始-->
<DIV id=adendtext><SPAN id=ad8></SPAN></DIV><!--文字广告结束--><!--最新更新等内容开始--><A 
name=xgwz></A>
<DIV class=photobg1>
<DIV class=newarticle1 id=Layer2-2>相关文章</DIV>
<DIV class=newarticle2 id=Layer2-2-1 style="DISPLAY: none; CURSOR: hand" 
onclick="MM_showHideLayers('Layer1','','show','Layer2-2','','show','Layer3-3-1','','show','Layer1-1-1','','show','Layer4-4-1','','show','Layer5-5-1','','show','Layer3','','hide','Layer2','','hide','Layer4','','hide','Layer5','','hide','Layer3-3','','hide','Layer1-1','','hide','Layer4-4','','hide','Layer5-5','','hide','Layer2-2-1','','hide')">相关文章</DIV>
<DIV class=newarticle2 id=Layer1-1-1 style="CURSOR: hand" 
onclick="MM_showHideLayers('Layer2','','show','Layer1-1','','show','Layer3-3-1','','show','Layer2-2-1','','show','Layer4-4-1','','show','Layer5-5-1','','show','Layer3','','hide','Layer1','','hide','Layer4','','hide','Layer5','','hide','Layer3-3','','hide','Layer2-2','','hide','Layer4-4','','hide','Layer5-5','','hide','Layer1-1-1','','hide')">最新更新</DIV>
<DIV class=newarticle1 id=Layer1-1 style="DISPLAY: none">最新更新</DIV>
<DIV class=newarticle2 id=Layer3-3-1 title=此文章的读者还看了以下文章 style="CURSOR: hand" 
onclick="MM_showHideLayers('Layer3','','show','Layer3-3','','show','Layer1-1-1','','show','Layer2-2-1','','show','Layer4-4-1','','show','Layer5-5-1','','show','Layer1','','hide','Layer2','','hide','Layer4','','hide','Layer5','','hide','Layer1-1','','hide','Layer2-2','','hide','Layer4-4','','hide','Layer5-5','','hide','Layer3-3-1','','hide')">继续阅读</DIV>
<DIV class=newarticle1 id=Layer3-3 title=此文章的读者还看了以下文章 
style="DISPLAY: none">继续阅读</DIV>
<DIV class=newarticle2 id=Layer4-4-1 title="本文编辑 方舟 的其他文章" style="CURSOR: hand" 
onclick="MM_showHideLayers('Layer4','','show','Layer4-4','','show','Layer1-1-1','','show','Layer2-2-1','','show','Layer3-3-1','','show','Layer5-5-1','','show','Layer1','','hide','Layer2','','hide','Layer3','','hide','Layer5','','hide','Layer1-1','','hide','Layer2-2','','hide','Layer3-3','','hide','Layer5-5','','hide','Layer4-4-1','','hide')">编辑新作</DIV>
<DIV class=newarticle1 id=Layer4-4 title="本文编辑 方舟 的其他文章" 
style="DISPLAY: none">编辑新作</DIV>
<DIV class=newarticle2 id=Layer5-5-1 title=阅读排行 style="CURSOR: hand" 
onclick="MM_showHideLayers('Layer5','','show','Layer5-5','','show','Layer1-1-1','','show','Layer2-2-1','','show','Layer3-3-1','','show','Layer4-4-1','','show','Layer1','','hide','Layer2','','hide','Layer3','','hide','Layer4','','hide','Layer1-1','','hide','Layer2-2','','hide','Layer3-3','','hide','Layer4-4','','hide','Layer5-5-1','','hide')">热点文章</DIV>
<DIV class=newarticle1 id=Layer5-5 title=阅读排行 
style="DISPLAY: none">热点文章</DIV></DIV>
<DIV class=photobox id=Layer1>
<DIV class=photocolorblock></DIV>
<DIV class=fontclear></DIV>
<DIV class=newarticlebox>
<UL>
  <LI><A 
  href="http://www.yesky.com/40/1704040.shtml">《东方影都2003》媒体工具测试</A>(2003-05-29 
  16:25) 
  <LI><A 
  href="http://www.yesky.com/458/1704458.shtml">优化JAVA性能的几种方法</A>(2003-06-05 
  00:00) 
  <LI><A 
  href="http://www.yesky.com/459/1704459.shtml">Java技术实现数据库应用系统慨述</A>(2003-06-04 
  00:00) 
  <LI><A href="http://www.yesky.com/462/1704462.shtml">深入理解Collections 
  API</A>(2003-06-06 00:00) 
  <LI><A 
  href="http://www.yesky.com/10/1706010.shtml">通过Java套接字传递对象</A>(2003-06-13 
  11:23) 
  <LI><A 
  href="http://www.yesky.com/11/1706011.shtml">正则表达式和Java编程语言</A>(2003-06-12 
  15:42) 
  <LI><A href="http://www.yesky.com/14/1706014.shtml">使用Java 
  API压缩和解压缩数据</A>(2003-06-16 09:16) 
  <LI><A 
  href="http://www.yesky.com/18/1706018.shtml">用RMI和CORBA进行分布式Java编程</A>(2003-06-17 
  15:18) 
  <LI><A 
  href="http://www.yesky.com/428/1706928.shtml">正则表达式和Java编程语言</A>(2003-06-11 
  14:40) 
  <LI><A 
  href="http://www.yesky.com/397/1707397.shtml">用Java实现PDF报表</A>(2003-06-12 
  15:05) 
  <LI><A href="http://www.yesky.com/443/1711443.shtml">Java游戏编程初步</A>(2003-07-01 
  17:54) 
  <LI><A 
  href="http://www.yesky.com/195/1711695.shtml">Java平台上的CRM系统</A>(2003-07-02 
  16:41) 
  <LI><A href="http://www.yesky.com/382/1712382.shtml">Java Swing 
  组件全演示</A>(2003-07-07 13:11) 
  <LI><A 
  href="http://www.yesky.com/202/1712702.shtml">在Word和WPS中打印反字</A>(2003-07-08 
  16:05) 
  <LI><A 
  href="http://www.yesky.com/114/1714114.shtml">Java开发中的线程安全选择与Swing</A>(2003-07-14 
  18:00) 
  <LI><A 
  href="http://www.yesky.com/163/1714663.shtml">Java布局管理器在现实工程中的应用</A>(2003-07-16 
  14:06) </LI></UL></DIV>
<DIV class=fontclear></DIV></DIV>
<DIV class=photobox id=Layer2 style="DISPLAY: none">
<DIV class=photocolorblock></DIV>
<DIV class=fontclear></DIV>
<DIV class=newarticlebox>
<UL>
  <LI><A href="http://diy.yesky.com/25/3037525.shtml">AMD推出DTX规格 打造轻巧型PC新标准</A> 
  <LI><A 
  href="http://digital.yesky.com/1/3037501.shtml">四大绝技傍身,朗科A150成车载MP3年底热推产品!</A> 

  <LI><A href="http://diy.yesky.com/input/0/3037500.shtml">发烧推荐:创新Fatal1ty 
  1010明星设计</A> 
  <LI><A href="http://notebook.yesky.com/498/3037498.shtml">再提性价比 宏基 Aspire 
  5583跌至8k售</A> 
  <LI><A href="http://sh.yesky.com/497/3037497.shtml">上海星光相机文化节开幕 新光影像网上线</A> 
  </LI></UL></DIV>
<DIV class=fontclear></DIV></DIV>
<DIV class=photobox id=Layer3 style="DISPLAY: none">
<DIV class=photocolorblock></DIV>
<DIV class=fontclear></DIV>
<DIV class=newarticlebox>
<UL>
  <LI><A href="http://diy.yesky.com/monitor/482/2696982.shtml">宽屏继续普及 
  明基22英寸FP222W售价破3K</A> </LI></UL></DIV>
<DIV class=fontclear></DIV></DIV>
<DIV class=photobox id=Layer4 style="DISPLAY: none">
<DIV class=photocolorblock></DIV>
<DIV class=fontclear></DIV>
<DIV class=newarticlebox>
<UL></UL></DIV>
<DIV class=fontclear></DIV></DIV>
<DIV class=photobox id=Layer5 style="DISPLAY: none">
<DIV class=photocolorblock></DIV>

⌨️ 快捷键说明

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