如何使用javascript在winForm中单击按钮时打开pdf文件? [英] How to open the pdf file on button click in winForm using javascript?

查看:112
本文介绍了如何使用javascript在winForm中单击按钮时打开pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在"C"文件夹中创建了一个PDF文件.

当用户单击按钮"时,我要打开该"PDF文件".


请帮助我..

Hi
i created one PDF file in my "C" Folder.

when the user click on "button", i want to open that "PDF file".


Please help me..

推荐答案

用两行代码完成,前提是您的计算机上安装了acrobat阅读器. System.Diagnostics命名空间具有一个用于执行此操作的流程类.

添加
Well in 2 lines of code you can do that assuming you have acrobat reader installed in your computer. System.Diagnostics namespace has a process class to do this.

add
using System.Diagnostics;




将此代码放在您的按钮单击事件中.




Place this code to your button click event.

string pdfFileName = "C:\\mypdfFileName.pdf";
System.Diagnostics.Process.Start(pdfFileName);



c#.net;



c#.net;

Response.Write("<SCRIPT language=javascript>var pdf=window.open('" +
result + "','PDF');pdf.moveTo(0,0);</SCRIPT>");







or

<script type="text/javascript">
function openWindow(path)
{
var myWin = window.open(' " + pdfFileName + " ','mywindow','width=400,height=200');
}
</script>
...
<input type="button" onClick="openWindow(varName)">


这篇关于如何使用javascript在winForm中单击按钮时打开pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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