杰表技术论坛 's Archiver

admin 发表于 2009-11-20 16:48

使用jatoolsPrinter控件进行WEB打印设置(转帖)

jatoolsPrinter 是一款实现网页套打的免费工具。该工具的特点是可以直接对web页面进行精确的分页打印,这不仅使“会设计网页就会做网页套打”成为可能,也使项目经理们摆脱了预算紧张的压力。jatoolsPrinter通过在网页中嵌入控件,解决了web客户端精确打印,批量打印,打印配置自动保留等问题。
由于jatoolsPrinter的[url=http://www.jatools.com/print/index.html][color=#800080]官方网站[/color][/url]上有详细的例子和文档,因此,本篇内容就不对具体的一些参数和用法进行介绍了。本道直接给出一个例子。


[list=1]<html>

<head>

<title>我的第一个打印文档</title>


<!-- 插入打印控件 -->

<OBJECT
ID="jatoolsPrinter"
CLASSID="CLSID:B43D3361-D075-4BE2-87FE-057188254255"
codebase="jatoolsPrinter.cab#version=2,1,0,3"></OBJECT>

<script>
function doPrint()     {     
myreport = {        print_settings:{                                       // 如果想使用默认打印机,不需要设置                                       // printer: '联想激打',     
                                  // 指定纸张的高宽以毫米为单位z,本设置实际是指定为a4大小                                     paperWidth : 2100,                                     paperHeight : 2970,                                    // 指定打打印方向为横向, 1/2 = 纵向/横向                                    orientation : 2 },         documents:document,   // 要打印的div 对象在本文档中,控件将从本文档中的 id 为 'page1' 的div对象,作为首页打印                                                             // id 为 'page2' 的作为第二页打印             copyrights:'杰创软件拥有版权  www.jatools.com'         // 版权声明,必须             };            jatoolsPrinter.printPreview(myreport);  // 预览           }      
</script>

</head>

<body
bgcolor="#e0e0e0">


<div
id='page1'
style='background:#ffffff;margin:10;width:270;height:450;float:left'>文档第一页</div>

<div
id='page2'
style='background:#ffffff;margin:10;width:270;height:450;float:left'>文档第二页</div>


<input
type="button"
value="按钮"
onClick=' doPrint()'>

</body>
[*]
</html>
[/list]

点击按钮后,就弹出预览界面,如下图:
[url=http://ajava.org/uploads/090109/1_165610_1.png][img=575,267]http://ajava.org/uploads/090109/1_165610_1.png[/img][/url]
图片1

两个div分别在第一页和第二页。
jatoolsPrinter免费版只能使用在网段192.168.*.*。
本来在没了解jatoolsPrinter之前,对它抱有很大的希望,谁知到只能在192.168.*.*使用。在实际环境中,有很多局域网是172.16.*.*网段,总不能要求用户改地址吧。
希望还有更好的打印控件出现。

原文 [url=http://ajava.org/hot/print/7281.html]http://ajava.org/hot/print/7281.html[/url]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.