<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="UdPdf.aspx.vb" Inherits="VBWebPdf.UdPdf" %>
<html>
<head id="Head1" runat="server">
    <title>优道PDF阅读控件在线演示</title>
    <meta http-equiv="Content-Language" content="zh-cn" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
        body{font-size:9pt}
        input{font-size:9pt}
        h2{background-color:#efefef;height:40px;line-height:40px;margin:0;}
        #info{background-color:#efefef;height:30px;line-height:30px;}
        .inst{display:block;border:1px solid #3079ED;background-color:#498AF4;color:#ffffff;width:350px;line-height:40px;font-weight:bold; text-decoration:none;}
        .inst:hover{background-color:#3B80EE}
        @media print 
        {
            #pdfCtl{display:none} 
            #pdfPlugin{display:none} 
            #ctlDiv{border:1px solid #000000;}
        } 
    </style>
    <script type="text/javascript">
        var ctl;
        //初始化加载
        function f_onload() {
            ctl = f_initPdf();//获取PDF控件对象,失败返回null
            <%if not String.IsNullOrEmpty(Request.QueryString("Id")) then %>
            if(ctl)
            {                
                //不知道为什么IE11必须异步延迟加载才不会报错
                setTimeout(function(){       
                    ctl.Encrypted = 1; //采用加密方式读取和加载
                    ctl.HashKey = "3CE59E850E2C590AFD6E4D3516BA3F1B";//使用加密读取的密码hash值：123abc
                    ctl.FileId = "<%=Server.UrlDecode(Request.QueryString("Id")) %>";   //更改文件ID值
                    ctl.LoadFromWeb("");
                },1);
            }
            <%end if %>
        }
        //通过路径打开文件
        function f_open(){  
            if(ctl){
                //设为非加密模式读取
                ctl.Encrypted = 0;           

                //打开其它网站文件，http开头的为绝对路径
                //ctl.LoadFromWeb("http://www.jslanfeng.com/download/upfile/2012020639708721.PDF"); 

                //相对路径打开当前服务器文件
                //ctl.LoadFromWeb("upload/sample.pdf"); 

                //也可通过URL读取文件
                ctl.FileId = "sample"
                ctl.LoadFromWeb("GetFile.aspx");
            }
        }
        //放大
        function f_zoomIn() {
            if(ctl)ctl.ZoomIn();
        }
        //缩小
        function f_zoomOut() {
            if(ctl)ctl.ZoomOut();
        }
        //获取缩放比例
        function f_getZoom()
        {
            if(ctl)alert("当前缩放比例：" + ctl.GetZoom());
        }
        //适应宽度
        function f_zoomFitWidth() {
            if(ctl)ctl.ZoomFitWidth();
        }
        //适应页面
        function f_zoomFitPage() {
            if(ctl)ctl.ZoomFitPage();
        }
        //原始大小
        function f_zoomActual() {
            if(ctl)ctl.ZoomActual();
        }
        //顺时针旋转
        function f_rotateLeft() {
            if(ctl)ctl.RotateLeft();
        }
        //逆时针旋转
        function f_rotateRight() {
            if(ctl)ctl.RotateRight();
        }
        //上页
        function f_gotoPrevPage() {
            if(ctl)ctl.GoToPrevPage();
        }
        //下页
        function f_gotoNextPage() {
            if(ctl)ctl.GoToNextPage();
        }
        //允许打印
        function f_enablePrint() {
            if(ctl){
                //ctl.EnablePrint = document.getElementById("chkEnablePrint").checked
                //也可以用加密方式设置
                if(document.getElementById("chkEnablePrint").checked)
		            ctl.EncryptExecute("22286F074E914C269FE84EB6FD1473771CD9FD9AAAD7141A9CCE9A3DC567036CF99E3DD7B52282441B6A3FCC6E9BA168")//EnablePrint=true
	            else
		            ctl.EncryptExecute("22286F074E914C269FE84EB6FD1473771A35B23CCF238ECD7999BCD7885726B552F3EA272B29E87023868FB7D5F7A69C")//EnablePrint=false
            }
        }
        //允许复制
        function f_enableCopy() {
            if(ctl){
                //ctl.EnableCopy = document.getElementById("chkEnableCopy").checked
                //也可以用加密方式设置
                if(document.getElementById("chkEnableCopy").checked)
		            ctl.EncryptExecute("74321C08CA9D4B127A06C1B07A78A8B11E2CB74C64AE25C4D42847F22A5F7B04")//EnableCopy=true
	            else
		            ctl.EncryptExecute("74321C08CA9D4B127A06C1B07A78A8B1344B4A88E7F2517D90A04FFEB46F7A9FF99E3DD7B52282441B6A3FCC6E9BA168")//EnableCopy=false
            }
        }
        //允许截图
        function f_enableCapture() {
            if(ctl)ctl.EnableCapture = document.getElementById("chkEnableCapture").checked
        }
        //显示工具条
        function f_toolbarVisible() {
            if(ctl)ctl.ToolbarVisible = document.getElementById("chkToolbarVisible").checked
        }
        //打印
        function f_print() {
            if(ctl)ctl.Print();
        }
        //获取页码信息
        function f_getpage(){
            if(ctl)alert("共" + ctl.TotalPage + "页,第" + ctl.CurrentPage + "页");
        }
        //显示书签页
        function f_showBookmark()
        {
            if(ctl)ctl.BookmarkVisible = document.getElementById("chkBookmark").checked
        }
        //向下查找
        function f_findNext() {
            if(ctl)ctl.FindNext(document.getElementById("findText").value);
        }
        //向上查找
        function f_findPrev(text) {
            if(ctl)ctl.FindPrev(document.getElementById("findText").value);
        }
        //全屏显示
	    function f_fullScreen(){
	        if(ctl)ctl.ToggleFullScreen();
	    }
        //关闭文档
        function f_close(){
            if(ctl)ctl.Close();
        }
        //动态水印演示
        var water1 = -1, water2 = -1
        function f_waterMark() {
            if (water1 > -1) {
                ctl.RemoveWaterMark(water1)
                water1 = -1;
            }
            else {
                ctl.SetWaterFont("宋体", 20, 100, 1);
                water1 = ctl.AddWaterText("这里是动态添加的水印", 20, 100);
            }

            if (water2 > -1) {
                ctl.RemoveWaterMark(water2);
                water2 = -1;
            }
            else {
                ctl.SetWaterFont("宋体", 40, 300);
                water2 = ctl.AddWaterText("斜体的水印文字", 100, 300, 50, 45);
            }
        }
    </script>
</head>
<body onload="f_onload()">
    <form id="form1" runat="server">
    <center>
    <h2>优道PDF阅读控件在线演示</h2>
    <div style="height:20px;clear:both"></div>
    <div style="height:600px" id="ctlDiv">
        <script src="udpdf.js" type="text/javascript" charset="UTF-8"></script>
    </div>    
    <div style="margin:6px 0">
        <input type="button" id="btnOpen" value="打开文件" onclick="f_open()" />
        <input type="button" id="btnZoomIn" value="放大" onclick="f_zoomIn()" />
        <input type="button" id="btnZoomOut" value="缩小" onclick="f_zoomOut()" />         
        <input type="button" id="btnZoomFitWidth" value="适应宽度" onclick="f_zoomFitWidth()" />
        <input type="button" id="btnZoomFitPage" value="适应页面" onclick="f_zoomFitPage()" />
        <input type="button" id="btnZoomActual" value="实际大小" onclick="f_zoomActual()" />
        <input type="button" id="btnClockwise" value="顺时针旋转90度" onclick="f_rotateLeft()"/>
        <input type="button" id="btnContrarotate" value="逆时针旋转90度" onclick="f_rotateRight()" />
        <input type="button" id="btnGotoNextPage" value="下页" onclick="f_gotoNextPage()" />
        <input type="button" id="btnGotoPrevPage" value="上页" onclick="f_gotoPrevPage()" />
        <input type="button" id="btnPrint" value="打印" onclick="f_print()" />
        页码：<input type="text" id="pageInfo" style="width:60px" readonly="readonly" />
        <input type="button" id="btnGetPage" value="获取页码" onclick="f_getpage()" />
    </div>
    <div style="margin:6px 0">
        <input type="checkbox" id="chkToolbarVisible" value="1" onclick="f_toolbarVisible()" checked="checked" /><label for="chkToolbarVisible">显示工具条</label>
        <input type="checkbox" id="chkEnableCapture" value="1" onclick="f_enableCapture()" checked="checked"  /><label for="chkEnableCapture">允许截图</label>
        <input type="checkbox" id="chkEnablePrint" value="1" onclick="f_enablePrint()" checked="checked" /><label for="chkEnablePrint">允许打印</label>
        <input type="checkbox" id="chkEnableCopy" value="1" onclick="f_enableCopy()"  checked="checked" /><label for="chkEnableCopy">允许内容复制</label>
        <input type="checkbox" id="chkWaterMark" value="1" onclick="f_waterMark()" /><label for="chkWaterMark">动态水印</label>
        <input type="checkbox" id="chkBookmark" value="1" onclick="f_showBookmark()"  checked="checked" disabled="disabled" /><label for="chkBookmark">显示书签</label>
        <input type="text" id="findText" />
        <input type="button" id="btnFindNext" value="向下查找" onclick="f_findNext()"/>
        <input type="button" id="btnFindPrev" value="向上查找" onclick="f_findPrev()"/>            
        <input type="button" id="btnFullScreen" value="全屏显示" onclick="f_fullScreen()" />
        <input type="button" id="btnClose" value="关闭" onclick="f_close()" />
    </div>
    <div id="info"></div>
    <br /><a href="http://www.uudoc.com">www.uudoc.com</a>
    </center>
    </form>
</body>
</html>