Web打印控件smsx.cab使用说明
在项目开发中,经常会用到页面打印的功能,在ASP.NET环境下推荐一款web打印控件smsx.cab。
使用方法:一般会先定义一个用于打印的母版页(Print.Master),在母版页上做好布局,包括页面布局、js 的引用、smsx.cab控件加载、打印和预览按钮的放置。
下载链接:http://download.csdn.net/detail/nxgliming/6668999
母版页(Print.Master):
- <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Print.master.cs" Inherits="PdSecrity.Pages.Print.Print" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>打印</title>
- <asp:ContentPlaceHolder ID="head" runat="server">
- </asp:ContentPlaceHolder>
- <style media="print">
- .Noprint
- {
- display: none;
- }
- .w3cbbs
- {
- page-break-after: always;
- }
- </style>
- </head>
- <script src="<%= Page.ResolveClientUrl("~/PdSecrity/Scripts/jquery-1.10.2.min.js")%>"
- type="text/javascript"></script>
- <script src="<%= Page.ResolveClientUrl("~/PdSecrity/Scripts/Print.js")%>" type="text/javascript"></script>
- <body>
- <form id="form1" runat="server">
- <!--下面的这个objec标签就是加载t加载smsx.cab控件用-->
- <object id="factory" style="display: none" codebase="<%= Page.ResolveClientUrl("~/PdSecrity/Scripts/smsx.cab")%>#VVersion=6,6,440,26"
- classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext>
- </object>
- <script>
- $(document).ready(function () {
- //加载打印设置
- SetPrintSettings();
- });
- </script>
- <table align="center">
- <tr class="Noprint">
- <td>
- <input id="Button1" type="button" value="打印" class="btnbg" onclick="Print();" />
- <input id="Button2" type="button" value="预览" class="btnbg" onclick="Preview();" />
- </td>
- </tr>
- <tr>
- <td>
- <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
- </asp:ContentPlaceHolder>
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Print.js,主页用于打印的一些设置
- //预览
- function Preview() {
- document.all.factory.printing.Preview();
- }
- function Print() {
- document.all.factory.printing.Print(false); //无确认打印,true时打印前需进行确认
- }
- function PrintSetup() {
- document.all.factory.printing.PageSetup();
- }
- function SetPrintSettings() {
- // -------------------基本功能,可免费使用-----------------------
- document.all.factory.printing.header = ""; //页眉
- document.all.factory.printing.footer = ""; //页脚
- ////document.all.factory.printing.SetMarginMeasure(1); //页边距单位,1为毫米,2为英寸//边距设置,需要注意大部分打印机都不能进行零边距打印,即有一个边距的最小值,一般都是6毫米以上
- //设置边距的时候时候如果设置为零,就会自动调整为它的最小边距
- document.all.factory.printing.leftMargin = ; //左边距
- document.all.factory.printing.topMargin = ; //上边距
- document.all.factory.printing.rightMargin = ; //右边距
- document.all.factory.printing.bottomMargin = ; //下边距
- document.all.factory.printing.portrait = true; //是否纵向打印,横向打印为false
- //--------------------高级功能---------------------------------------------
- //document.all.factory.printing.printer = "EPSON LQ-1600KIII"; //指定使用的打印机
- //document.all.factory.printing.printer = "\\\\cosa-data\\HPLaserJ";//如为网络打印机,则需要进行字符转义
- ////document.all.factory.printing.paperSize = "A4"; //指定使用的纸张
- document.all.factory.printing.paperSource = "Manual feed"; //进纸方式,这里是手动进纸
- ////document.all.factory.printing.copies = 1; //打印份数
- ////document.all.factory.printing.printBackground = false; //是否打印背景图片
- ////document.all.factory.printing.SetPageRange(false, 1, 3); //打印1至3页
- //---------------------常用函数--------------------------------
- //document.all.factory.printing.Print(false); //无确认打印,true时打印前需进行确认
- //document.all.factory.printing.PrintSetup(); //打印设置
- //document.all.factory.printing.Preview(); //打印预览
- //document.all.factory.printing.WaitForSpoolingComplete(); //等待上一个打印任务完全送入打印池,在连续无确认打印时非常有用
- //document.all.factory.printing.EnumPrinters(index); //枚举已安装的所有打印机,主要用于生成打印机选择功能
- }
最后,让所需要打印的页面都引用这个母版页即可。
Web打印控件smsx.cab使用说明的更多相关文章
- WEB打印控件Lodop(V6.x)使用说明及样例
WEB打印控件Lodop(V6.x)使用说明及样例 Lodop是专业WEB控件,用它既可裁剪输出页面内容,又可用程序代码生成复杂打印页. 控件功能强大,却简单易用,所有调用如同JavaScript扩展 ...
- Web打印控件
Lodop是什么? 有人说她是Web打印控件,因为她能打印.在浏览器中以插件的形式出现,用简单一行语句就把整个网页打印出来: 有人说她是打印编程接口,因为她介于浏览器和打印设备之间,是个通道和桥梁,几 ...
- 网页WEB打印控件
网页WEB打印控件制作 在WEB系统中,打印的确是比较烦人的问题,如果我们能制作一个属于自己的自定义的打印插件,那么我们在后续自定义打印的时候能随心所欲的控制打印,这样的效果对于程序员来说是非常开心的 ...
- Web打印控件Lodop实现表格物流单的打印
Web打印控件Lodop实现表格物流单的打印 一.lodop打印预览效果图 LODOP.PRINT_SETUP();打印维护效果图 LODOP.PREVIEW();打印预览图 二.写在前面 最近项目用 ...
- C/S架构引用Lodop 如何在C#调用web打印控件Lodop
lodop是web打印控件,引用安装目录下的ocx文件,可以在c/s架构中使用. 该文件所在路径:C:\Program Files (x86)\MountTaiSoftware\Lodop 有32位和 ...
- 在.net Core 使用PDF模板文件生成PDF文件,代替WEB打印控件!
这几天找WEB打印控件,要么收费的,要么免费的只能在IE里用! 我只想简单的打个标签纸!百度2天,看到一老兄说可以用PDF,然后又开始百度..找到了一篇文章 http://www.jianshu.co ...
- WEB打印控件LODOP的使用
有人说她是Web打印控件,因为她能打印.在浏览器中以插件的形式出现,用简单一行语句就把整个网页打印出来: 有人说她是打印编程接口,因为她介于浏览器和打印设备之间,是个通道和桥梁,几乎能想到的打印控制事 ...
- 网页WEB打印控件制作-开放源码
在WEB系统中,打印的确是比较烦人的问题,如果我们能制作一个属于自己的自定义的打印插件,那么我们在后续自定义打印的时候能随心所欲的控制打印,这样的效果对于程序员来说是非常开心的一件事件,本文将自己开发 ...
- WEB打印控件Lodop使用体会
控件的使用方法,作者都已经有详细的使用说明供使用者参考. 但是对于打印表格,确实出现一点小问题,如果表格是自然高度,也就是只设置了table的高度,此时是可以正常显示的 ...
随机推荐
- unity 3d-Easy Touch 3教程 转
Easy Touch 教程 转自:http://www.unitymanual.com/thread-31332-1-1.html 1.import “Easy Touch 3”的资源包 2.创建人物 ...
- N皇后问题2
Description Examine the checkerboard below and note that the six checkers are arranged on the board ...
- EXTJS 4.2 资料 控件之Window窗体添加html
//这里要跳转页面 var subWindow = new Ext.Window({ title: '窗口', width: width, height: height, modal: true,// ...
- windows server 2008 r2电脑历史操作记录
1.看计算机哪天运行过. 在系统盘下的Windows\Tasks文件夹下找到文件SCHEDLGU.TXT. 2.看你最近打开过什么文件(非程序)或者文件夹 开始-->运行--> ...
- Qt的gzip模块实现
一直没找到Qt中方便的gzip模块,于是自己动手,调用zlib模块实现了一份. 目标: 1.gzip的压缩与解压 2.内存中操作 3.方便的Qt接口 实现分析: gzip 压缩算法为 defla ...
- 遍历并修改dictionary的值
var dictionary = clb_Select.Items.Cast<object>().ToDictionary(item => item.ToString(), item ...
- dubbo zookeeper模型
本文摘自dubbo的官方文档,原文请参见: http://alibaba.github.io/dubbo-doc-static/User+Guide-zh.htm#UserGuide-zh-Zooke ...
- Mysql异常:MySQLNonTransientConnectionException: No operations allowed after statement closed
Mysql异常:MySQLNonTransientConnectionException: No operations allowed after statement closed MySQLNonT ...
- tomcat部署javaweb项目的三种方式
一.将项目文件夹或war包直接拷贝到tomcat的webapps下 二.在Tomcat\conf\Catalina\localhost下建立xml文件 修改内容如下<Context path=& ...
- linux distribution是什么?
linux distribution,即Linux发行版,有很多种类,包括Fedora,Ubuntu,Debian,Red Hat,SuSE等,其内核都是差不多的,只是界面设计和功能上各有千秋.