仅当用户尝试打印证书时,如何显示授权签名 [英] How do I display authorized signature only when user tries to print certificate

查看:75
本文介绍了仅当用户尝试打印证书时,如何显示授权签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户点击打印按钮时在asp.net页面显示该人的签名。



我创建了一个证书页面,其中页面可以有人的数字签名

但是用户应该只能在打印预览页面中看到签名,而不能在实际的aspx页面中看到签名。



我怎样才能做到这一点..请给我一些建议。



在此先感谢..



< b>我尝试了什么:



 功能 cert_Print(){

var contents = document .getElementById( divPrintContent)。innerHTML;
var frame1 = document .createElement(' iframe');
frame1.name = frame1;
frame1.style.position = 绝对;
frame1.style.top = - 1000000px;
document .body.appendChild(frame1);
var frameDoc = frame1.contentWindow? frame1.contentWindow:frame1.contentDocument。 document ? frame1.contentDocument。 document :frame1.contentDocument;
frameDoc。 document .open();
frameDoc。 document .write(' ' );
frameDoc。 document .write(' ' );
frameDoc。 document .write(contents);
frameDoc。 document .write(' ' );
frameDoc。 document .close();
setTimeout( function (){
window .frames [ frame1]。focus();
window .frames [ frame1]。print();
document .body.removeChild(frame1);
}, 500 );
return false ;
}

解决方案

在ASP.NET(或整体Web开发)中,您是否知道CSS可以控制显示的内容屏幕和隐藏的内容,直到满足状态?如处于打印状态?



你可以隐藏标志,

 signelement  {
display none;
}



然后,您可以在网页的打印版本中显示它,使用CSS3媒体查询,

  @ media   print  {
#signelement {
display inline-block; / * 或者其他什么。 * /
}
}



这甚至可以控制JavaScript在运行时创建的元素。因此,您可以轻松管理用户可见的内容和隐藏的内容。



欲了解更多信息,请使用媒体查询 - CSS | MDN [ ^


I want to display signature of the person in the asp.net page only when user clicks on print button.

I have created a certificate page where page can have digital signature of the person
but user should able to see signature only in the print preview page but not in the actual aspx page.

How can i achieve this..any suggestions please.

Thanks in Advance..

What I have tried:

function cert_Print() {
            
                var contents = document.getElementById("divPrintContent").innerHTML;
                var frame1 = document.createElement('iframe');
                frame1.name = "frame1";
                frame1.style.position = "absolute";
                frame1.style.top = "-1000000px";
                document.body.appendChild(frame1);
                var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
                frameDoc.document.open();
                frameDoc.document.write('');
                frameDoc.document.write('');
                frameDoc.document.write(contents);
                frameDoc.document.write('');
                frameDoc.document.close();
                setTimeout(function () {
                    window.frames["frame1"].focus();
                    window.frames["frame1"].print();
                    document.body.removeChild(frame1);
                }, 500);
                return false;
            }

解决方案

In ASP.NET (or overall web development), did you know that CSS can control what is shown on screen and what is hidden, until a state is met? Such as being in the state of printed?

You can hide the sign,

#signelement {
   display: none;
}


Then, you can show it in the printed version of your web page, using CSS3 media queries,

@media print {
   #signelement {
      display: inline-block; /* Or whatever. */
   }
}


This will control even the elements created by JavaScript on runtime. So you can easily manage what is visible and what is hidden from the user.

For more,
Using media queries - CSS | MDN[^]


这篇关于仅当用户尝试打印证书时,如何显示授权签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆