当前位置: 代码迷 >> ASP.NET >> c# 打印解决方案
  详细解决方案

c# 打印解决方案

热度:2893   发布时间:2013-02-25 00:00:00.0
c# 打印
代码

------解决方案--------------------------------------------------------
没有,试试,JS打印。。。
<script language="javascript" type="text/javascript">
function printpage(myDiv){ 
 
//var newstr = document.all.item(myDiv).innerHTML; 
var newstr = document.getElementById(myDiv).innerHTML;
var oldstr = document.body.innerHTML; 
document.body.innerHTML = newstr; 
window.print(); 
document.body.innerHTML = oldstr; 
return false; 

</script>
<div id="myDiv" >打印内容,内加任何东东,</div>
------解决方案--------------------------------------------------------
webbrower打印
window.print()
调用Office实现WEB打印
导出报表
Graphics.DrawString 输出字符,导出打印
打印组件http://topic.csdn.net/u/20090921/20/625a532c-1c97-4bfb-bdf1-7a1ab04fd797
------解决方案--------------------------------------------------------
<script type="text/javascript" language="javascript">
function printContent() {
var printContent = $("printtable").innerHTML;
var bodyContent = document.body.innerHTML;
document.body.innerHTML = printContent;
window.print();
document.body.innerHTML = bodyContent;
window.location.reload();
return;
}
</script>
自己有打印预览
------解决方案--------------------------------------------------------
winfrom的话就需要用Graphics对象来打印了
------解决方案--------------------------------------------------------
http://www.cnblogs.com/scottckt/archive/2008/01/31/1059576
http://developer.51cto.com/art/200908/146857.htm
------解决方案--------------------------------------------------------
<script language="javascript" type="text/javascript">
function printpage(myDiv){

//var newstr = document.all.item(myDiv).innerHTML;
var newstr = document.getElementById(myDiv).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = newstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}
</script>
<div id="myDiv" >打印内容div>


web打印也可以
------解决方案--------------------------------------------------------
调用别人写好的代码的人飘过。。。
------解决方案--------------------------------------------------------
HTML code
<HTML><HEAD><TITLE>网页打印去掉页眉页脚,以及如何控制不想打印出的页面元素【梨城在线】</TITLE><META http-equiv=Content-Type content="text/html; charset=gb2312"><SCRIPT language=javascript>function printpr()   //预览函数{document.all("qingkongyema").click();//打印之前去掉页眉,页脚document.all("dayinDiv").style.display="none"; //打印之前先隐藏不想打印输出的元素(此例中隐藏“打印”和“打印预览”两个按钮)var OLECMDID = 7;var PROMPT = 1; var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(OLECMDID, PROMPT);WebBrowser1.outerHTML = "";document.all("dayinDiv").style.display="";//打印之后将该元素显示出来(显示出“打印”和“打印预览”两个按钮,方便别人下次打印)}function printTure()   //打印函数{    document.all('qingkongyema').click();//同上    document.all("dayinDiv").style.display="none";//同上    window.print();    document.all("dayinDiv").style.display="";}function doPage(){    layLoading.style.display = "none";//同上}</SCRIPT><script language="JavaScript">var hkey_root,hkey_path,hkey_keyhkey_root="HKEY_CURRENT_USER"hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"//设置网页打印的页眉页脚为空function pagesetup_null(){try{var RegWsh = new ActiveXObject("WScript.Shell")hkey_key="header" RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")hkey_key="footer"RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")}catch(e){}}//设置网页打印的页眉页脚为默认值function pagesetup_default(){try{var RegWsh = new ActiveXObject("WScript.Shell")hkey_key="header" RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P")hkey_key="footer"RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d")}catch(e){}}</script></HEAD><BODY leftMargin=0 topMargin=0 rightMargin=0 bottomMargin=0 style="BACKGROUND-POSITION: center 50%"><DIV align=center>你希望打印的内容放置此处..........SDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDSDSDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD  <table width="200" border="1">    <tr>      <td>1</td>      <td>2</td>    </tr>    <tr>      <td>3</td>      <td>4</td>    </tr>  </table>  <form name="form1" method="post" action="">    <input name="textfield" type="text" value="SSAASSSAAS">  </form>  <p>SASASASAAAAAAA</p></DIV><DIV align="center" id="dayinDiv" name="dayinDiv"><table width="100%" border="0" cellspacing="0" cellpadding="0">    <tr>      <td align="center">翻页代码及其他不需要打印的内容放置此处</td>    </tr></table><input type="button" class="tab" value="打印" onClick="printTure();">&nbsp;&nbsp;<input type="button" class="tab" value="打印预览" onClick="printpr();"><input type="button" name="qingkongyema" id="qingkongyema" class="tab" value="清空页码" onClick="pagesetup_null()">&nbsp;&nbsp;<input type="button" class="tab" value="恢复页码" onClick="pagesetup_default()"></DIV></BODY></HTML>
  相关解决方案