首页 > 代码库 > EDU-PAAS文档转换工具
EDU-PAAS文档转换工具
本软件为edu-paas的文档转换工具,为开源软件。
该软件支持
word 转PDF、word转Swf、Word转Png、
Excel转Pdf、Excel转Swf、Excel转Png、
PPT转Pdf、PPT转Swf、PPT转Png、
PDF转Png、Pdf转Swf
?有需要的朋友可以直接下载
下载地址 live.edu-paas.com/dowmCenter/EDU-DocumentConversionTool.zip
下面附上代码。
demo.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> 6 <meta name="keywords" content="文档格式转换器,excel转换成pdf,office转pdf,文档转换源码" /> 7 <meta name="description" content="文档格式转换,支持从Word、excel、ppt文档到swf、pdf、png文档的快速转换;文件多线程并发转换,性能更稳定"> 8 <title>文档格式转换器|excel转换成pdf|office转pdf|让语言编程更高效 Edu-Pass</title> 9 <link rel="stylesheet" type="text/css" href=http://www.mamicode.com/"http://cdn.edu-paas.com/css/font-awesome.min.css?v=3.0" /> 10 <link rel="stylesheet" href=http://www.mamicode.com/"http://cdn.edu-paas.com/css/bootstrap.min.css" /> 11 <link rel="stylesheet" href=http://www.mamicode.com/"http://cdn.edu-paas.com/css/style_index.css?v=3.0" /> 12 <script src=http://www.mamicode.com/"http://cdn.edu-paas.com/js/jquery.min.js" type="text/javascript"></script> 13 <script src=http://www.mamicode.com/"http://cdn.edu-paas.com/js/bootstrap.min.js" type="text/javascript"></script> 14 <script src=http://www.mamicode.com/"http://cdn.edu-paas.com/js/kefu.js" type="text/javascript"></script> 15 <script src=http://www.mamicode.com/"http://cdn.edu-paas.com/js/layer/layer.js" type="text/javascript"></script> 16 <!--[if lt IE 9]> 17 <script src=http://www.mamicode.com/"/js/lib/respond.js/1.4.2/respond.js" type="text/javascript"></script> 18 <script src=http://www.mamicode.com/"/js/lib/shtml5shiv/3.7/html5shiv.min.js" type="text/javascript"></script> 19 <![endif]--> 20 </head> 21 <body> 22 <!--导航开始--> 23 <style type="text/css"> 24 .header_groupbtn .btn 25 { 26 margin-top: 8px; 27 border-radius: 0; 28 padding: 6px 15px; 29 } 30 .navbar_brand_txt 31 { 32 float: left; 33 line-height: 30px; 34 font-size: 14px; 35 color: #333; 36 margin-left: 10px; 37 margin-top: 10px; 38 } 39 .edu-paas-navbar .navbar-brand > img 40 { 41 float: left; 42 height: 25px; 43 } 44 .edu-paas-navbar .navbar-brand 45 { 46 padding: 12.5px; 47 } 48 </style> 49 <style> 50 .yanshi .nav > li > a:hover, .yanshi .nav > li > a:focus, .yanshi .nav > .open > a:hover, .yanshi .nav > .open > a:focus 51 { 52 background: #fff !important; 53 color: #000; 54 } 55 .tab-content > .tab-pane 56 { 57 display: none; 58 } 59 .tab-content > .active 60 { 61 display: block; 62 } 63 </style> 64 <!--导航结束--> 65 <!--header开始--> 66 <div class="header-y1"> 67 <div class="zt_nr"> 68 <h1> 69 <span class="white ">文档格式转换</span></h1> 70 <p class="fs20 white"> 71 Document Format Transformation</p> 72 <h3 class="white"> 73 支持从office到swf、pdf、png多种文档格式快速转换!</h3> 74 </div> 75 </div> 76 <!--header结束--> 77 <!--演示绍开始--> 78 <div class="bj_h"> 79 <div class="container"> 80 <div class="row yanshi"> 81 <div class=" col-xs-12"> 82 <div class="yl_bt"> 83 <h2 class="ys_blue"> 84 文档格式云转换演示</h2> 85 <p class="ys_h"> 86 点击上传文档开始演示</p> 87 <!--/Ajax/TEST.htm--> 88 <div class="yanshi"> 89 <form action="UpLoad.ashx" lang="zh-cn" dir="ltr" method="post" enctype="multipart/form-data" 90 id="convertForm"> 91 <!--请选择转换类型:--> 92 <ul id="myTab" class="nav nav-tabs"> 93 <li class="active"><a href=http://www.mamicode.com/"#zaixainwendnag" data-toggle="tab">本地文档</a> </li> 94 <li><a href=http://www.mamicode.com/"#bendiwendang" data-toggle="tab">在线文档</a> </li> 95 </ul> 96 <div id="myTabContent" class="tab-content"> 97 <div class="tab-pane fade in active" id="zaixainwendnag"> 98 <div style="padding-top: 30px;"> 99 <div style="margin-bottom: 20px; text-align: left"> 100 <button id="upfilebtn" onclick="$(‘input[id=Filedata]‘).click();" name="upfilebtn" 101 type="button" class="btn btn-default" style="float: left; margin-right: 35px;"> 102 上传文件 103 </button> 104 <br class="visible-xs"> 105 <span style="float: left; padding-top: 12px; color: #555">注意:<font style="color: #0183e0">请上传标准的office文档,以保证转换成功。例如:doc\docx\ppt\pptx 106 \xls</font></span> 107 </div> 108 <input id="photoCover" class="input-large" type="text" style="height: 30px; background-color: #f5f5f5; 109 width: 100%;" readonly="readonly" /> 110 <script type="text/javascript"> 111 $(‘input[id=Filedata]‘).change(function () { 112 $(‘#photoCover‘).val($(this).val()); 113 }); 114 </script> 115 </div> 116 </div> 117 <div class="tab-pane fade" id="bendiwendang"> 118 <div class="yanshi" style="padding-top: 0px;"> 119 <input id="Filedata" name="Filedata" type="file" style="display: none" accept=".xls,.xlsx,.doc,.ppt,.docx,.txt,.pdf,.pdfx" /> 120 <div style="margin-top: 30px; margin-bottom: 30px;"> 121 <div class="form-group"> 122 <div class="form-group" style="margin-bottom: 0"> 123 <input type="text" id="officeurl" name="officeurl" class="form-control" placeholder="请务必提供文档/电子书文件的直接URL链接。例如: ( http://www.edu-paas.com/file.doc )" /> 124 </div> 125 </div> 126 <script type="text/javascript"> 127 $(‘input[id=Filedata]‘).change(function () { 128 $(‘#photoCover‘).val($(this).val()); 129 }); 130 </script> 131 </div> 132 </div> 133 </div> 134 <div id="fileInfo"> 135 </div> 136 <div> 137 <div class="input-group"> 138 <span class="input-group-addon">EDU登录账号</span> 139 <input type="text" onblur="Setcookie(‘username‘,$(this).val())" id="username" class="form-control" 140 name="username" placeholder="Username" value=http://www.mamicode.com/""> 141 <span class="input-group-addon">TOKEN</span> 142 <input type="text" onblur="Setcookie(‘token‘,$(this).val())" id="token" class="form-control" 143 name="token" placeholder="token" value=http://www.mamicode.com/""> 144 </div> 145 </div> 146 <select id="ConverType" name="type" class="form-control"> 147 <option value=http://www.mamicode.com/"1">office转pdf</option> 148 <option value=http://www.mamicode.com/"2">office转swf</option> 149 <option value=http://www.mamicode.com/"3">office转png</option> 150 <option value=http://www.mamicode.com/"4">office转pdf单页</option> 151 <option value=http://www.mamicode.com/"5">pdf转swf</option> 152 <option value=http://www.mamicode.com/"6">pdf转png</option> 153 <option value=http://www.mamicode.com/"8">ppt转png</option> 154 </select> 155 <button type="button" id="btnsubmit" onclick="submitForm()" class="btn btn-default" 156 style="margin-top: 10px;"> 157 提 交 转 换 158 </button> 159 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/Images/loading.gif" style="width: 25px; visibility: hidden" 160 id="loading" alt="" /> 161 </div> 162 </form> 163 </div> 164 <p style="border: 1px dashed #0183e0; color: #555; padding: 20px 15px; background-color: #fff"> 165 我们不会将您上传的文件用于其他任何用途,也不会向第三方透露文件内容;上传的文件将会在10分钟后自动删除,请及时下载转换完的文档。</font></p> 166 </div> 167 </div> 168 </div> 169 </div> 170 </div> 171 <!--演示介绍结束--> 172 <!--内容开始--> 173 <div class=" wdzh_nr"> 174 <div class="container"> 175 <div class="row yulan wdzhTop1"> 176 <div class="col-xs-12"> 177 <div class="yl_bt"> 178 <h2 class="ys_blue"> 179 云转换功能</h2> 180 <p class="ys_h"> 181 常用文档格式,云端处理格式转换</p> 182 </div> 183 </div> 184 <div class="col-xs-6 col-sm-4 col-md-4"> 185 <div class="yzh_t"> 186 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/word-to-pdf.aspx"> 187 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/w-pdf.png" width="150px" height="65px" alt="word转pdf" 188 title="word转pdf" /></a> 189 </div> 190 <div class="yzh_z"> 191 <p class="ys_blue"> 192 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/word-to-pdf.aspx">Word转Pdf</a></p> 193 </div> 194 </div> 195 <div class="col-xs-6 col-sm-4 col-md-4"> 196 <div class="yzh_t"> 197 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/word-to-swf.aspx"> 198 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/w-swf.png" width="150px " height="65px" 199 alt="Word转swf" title="Word转swf" /></a> 200 </div> 201 <div class="yzh_z"> 202 <p class="ys_blue"> 203 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/word-to-swf.aspx">Word转Swf</a></p> 204 </div> 205 </div> 206 <div class="col-xs-6 col-sm-4 col-md-4"> 207 <div class="yzh_t"> 208 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/word-to-png.aspx"> 209 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/w-png.png" width="150px" height="65px" alt="Word转png" 210 title="Word转png" /></a> 211 </div> 212 <div class="yzh_z"> 213 <p class="ys_blue"> 214 <a href=http://www.mamicode.com/"">Word转Png</a></p> 215 </div> 216 </div> 217 <div class="col-xs-6 col-sm-4 col-md-4"> 218 <div class="yzh_t"> 219 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/office-to-pdf.aspx"> 220 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/e-pdf.png" width="150px" height="65px" alt="excel转pdf" 221 title="excel转pdf" /></a> 222 </div> 223 <div class="yzh_z"> 224 <p class="ys_blue"> 225 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/office-to-pdf.aspx">Excel转Pdf</a></p> 226 </div> 227 </div> 228 <div class="col-xs-6 col-sm-4 col-md-4"> 229 <div class="yzh_t"> 230 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/office-to-swf.aspx"> 231 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/e-swf.png" width="150px" height="65px" alt="excel转swf" 232 title="excel转swf" /></a> 233 </div> 234 <div class="yzh_z"> 235 <p class="ys_blue"> 236 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/office-to-swf.aspx">Excel转Swf</a></p> 237 </div> 238 </div> 239 <div class="col-xs-6 col-sm-4 col-md-4"> 240 <div class="yzh_t"> 241 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/office-to-png.aspx"> 242 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/e-png.png" width="150px" height="65px" alt="excel转png" 243 title="excel转png" /></a> 244 </div> 245 <div class="yzh_z"> 246 <p class="ys_blue"> 247 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/office-to-png.aspx">Excel转Png</a></p> 248 </div> 249 </div> 250 <div class="col-xs-6 col-sm-4 col-md-4"> 251 <div class="yzh_t"> 252 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/ppt-to-pdf.aspx"> 253 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/p-pdf.png" width="150px" height="65px" alt="ppt转pdf" 254 title="ppt转pdf" /></a> 255 </div> 256 <div class="yzh_z"> 257 <p class="ys_blue"> 258 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/ppt-to-pdf.aspx">PPT转Pdf</a></p> 259 </div> 260 </div> 261 <div class="col-xs-6 col-sm-4 col-md-4"> 262 <div class="yzh_t"> 263 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/ppt-to-swf.aspx"> 264 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/p-swf.png" width="150px" height="65px" alt="ppt转swf" 265 title="ppt转swf" /></a> 266 </div> 267 <div class="yzh_z"> 268 <p class="ys_blue"> 269 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/ppt-to-swf.aspx">PPT转Swf</a></p> 270 </div> 271 </div> 272 <div class="col-xs-6 col-sm-4 col-md-4"> 273 <div class="yzh_t"> 274 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/ppt-to-png.aspx"> 275 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/p-png.png" width="150px" height="65px" alt="ppt转png" 276 title="ppt转png" /></a> 277 </div> 278 <div class="yzh_z"> 279 <p class="ys_blue"> 280 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/ppt-to-png.aspx">PPT转Png</a></p> 281 </div> 282 </div> 283 <div class="col-xs-6 col-sm-4 col-md-4"> 284 <div class="yzh_t"> 285 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/pdf-to-png.aspx"> 286 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/pdf-to-png.png" width="150px" height="65px" 287 alt="pdf转png" title="pdf转png" /></a> 288 </div> 289 <div class="yzh_z"> 290 <p class="ys_blue"> 291 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/ppt-to-png.aspx">PDF转Png</a></p> 292 </div> 293 </div> 294 <div class="col-xs-6 col-sm-4 col-md-4"> 295 <div class="yzh_t"> 296 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/pdf-to-swf.aspx"> 297 <img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/pdf-to-swf.png" width="150px" height="65px" 298 alt="pdf转swf" title="pdf转swf" /></a> 299 </div> 300 <div class="yzh_z"> 301 <p class="ys_blue"> 302 <a href=http://www.mamicode.com/"http://www.edu-paas.com/demo/ppt-to-png.aspx">Pdf转Swf</a></p> 303 </div> 304 </div> 305 </div> 306 </div> 307 </div> 308 <!--内容结束--> 309 <!--为什么使用云转换开始--> 310 <div class="mokuai"> 311 <div class="bj_h "> 312 <div class="container"> 313 <div class="row yulan"> 314 <!------> 315 <div class="col-xs-12 "> 316 <div class=""> 317 <h2 class="ys_blue"> 318 为什么使用云转换?</h2> 319 <p class="ys_h"> 320 高性能,更可靠</p> 321 </div> 322 </div> 323 <div class="col-xs-6 col-sm-3 col-md-3 yulan2"> 324 <div class="yzh_t yzh_t_margin"> 325 <i class="iconfont"></i><!--<img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/wxhjzc.png" width="128px"/>--> 326 </div> 327 <div class="yzh_za yzh_z_margin"> 328 <p class="ys_blue"> 329 无需环境支持</p> 330 <p class="ys_h"> 331 即传即用,更方便</p> 332 </div> 333 </div> 334 <div class="col-xs-6 col-sm-3 col-md-3 yulan2"> 335 <div class="yzh_t yzh_t_margin"> 336 <i class="iconfont"></i><!--<img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/gbfwd.png" width="128px"/>--> 337 </div> 338 <div class="yzh_za yzh_z_margin"> 339 <p class="ys_blue"> 340 高并发稳定</p> 341 <p class="ys_h"> 342 多线程,更稳定</p> 343 </div> 344 </div> 345 <div class="col-xs-6 col-sm-3 col-md-3 yulan2"> 346 <div class="yzh_t"> 347 <i class="iconfont"></i><!--<img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/kptzc.png" width="128px"/>--> 348 </div> 349 <div class="yzh_za"> 350 <p class="ys_blue"> 351 跨平台支持</p> 352 <p class="ys_h"> 353 随时随地,方便快捷</p> 354 </div> 355 </div> 356 <div class="col-xs-6 col-sm-3 col-md-3 yulan2"> 357 <div class="yzh_t"> 358 <i class="iconfont"></i><!--<img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/kskfjc.png" width="128px"/>--> 359 </div> 360 <div class="yzh_za"> 361 <p class="ys_blue"> 362 快速开发集成</p> 363 <p class="ys_h"> 364 简单实用,更高效</p> 365 </div> 366 </div> 367 <div class="col-xs-6 col-sm-3 col-md-3 yulan2"> 368 <div class="yzh_t"> 369 <i class="iconfont"></i><!--<img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/aqbcc.png" width="128px"/>--> 370 </div> 371 <div class="yzh_za"> 372 <p class="ys_blue"> 373 安全不储存</p> 374 <p class="ys_h"> 375 转后即焚,更放心</p> 376 </div> 377 </div> 378 <div class="col-xs-6 col-sm-3 col-md-3 yulan2"> 379 <div class="yzh_t yzh_t_margin"> 380 <i class="iconfont"></i><!--<img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/dptnwip.png" width="128px"/>--> 381 </div> 382 <div class="yzh_za yzh_z_margin"> 383 <p class="ys_blue"> 384 大平台内网IP</p> 385 <p class="ys_h"> 386 支持阿里云,百度云内容IP</p> 387 </div> 388 </div> 389 <div class="col-xs-6 col-sm-3 col-md-3 yulan2"> 390 <div class="yzh_t yzh_t_margin"> 391 <i class="iconfont"></i><!--<img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/jszc.png" width="128px"/>--> 392 </div> 393 <div class="yzh_za yzh_z_margin"> 394 <p class="ys_blue"> 395 技术支持</p> 396 <p class="ys_h"> 397 全天支持,更保障</p> 398 </div> 399 </div> 400 <div class="col-xs-6 col-sm-3 col-md-3 yulan2"> 401 <div class="yzh_t"> 402 <i class="iconfont"></i><!--<img src=http://www.mamicode.com/"http://cdn.edu-paas.com/images/axff.png" width="128px"/>--> 403 </div> 404 <div class="yzh_za"> 405 <p class="ys_blue"> 406 按需付费</p> 407 <p class="ys_h"> 408 更优惠,更省钱</p> 409 </div> 410 </div> 411 </div> 412 </div> 413 </div> 414 </div> 415 <!--为什么试用运转换结束--> 416 <!--价格介绍开始--> 417 <script src=http://www.mamicode.com/"http://office.edu-paas.com/Scripts/jquery-migrate-1.2.1.js" type="text/javascript"></script> 418 <script src=http://www.mamicode.com/"http://office.edu-paas.com/Scripts/jquery.form.js" type="text/javascript"></script> 419 <script type="text/javascript"> 420 String.prototype.Trim = function () { 421 return this.replace(/^\s+/g, "").replace(/\s+$/g, ""); 422 } 423 function JSCookie() { 424 this.GetCookie = function (key) { 425 var cookie = document.cookie; 426 var cookieArray = cookie.split(‘;‘); 427 var getvalue = http://www.mamicode.com/""; 428 for (var i = 0; i < cookieArray.length; i++) { 429 if (cookieArray[i].Trim().substr(0, key.length) == key) { 430 getvalue = http://www.mamicode.com/cookieArray[i].Trim().substr(key.length + 1); 431 break; 432 } 433 } 434 return getvalue; 435 }; 436 this.GetChild = function (cookiekey, childkey) { 437 var child = this.GetCookie(cookiekey); 438 var childs = child.split(‘&‘); 439 var getvalue = http://www.mamicode.com/""; 440 for (var i = 0; i < childs.length; i++) { 441 if (childs[i].Trim().substr(0, childkey.length) == childkey) { 442 getvalue = http://www.mamicode.com/childs[i].Trim().substr(childkey.length + 1); 443 break; 444 } 445 } 446 return getvalue; 447 }; 448 this.SetCookie = function (key, value, expire, domain, path) { 449 var cookie = ""; 450 if (key != null && value != null) 451 cookie += key + "=" + value + ";"; 452 if (expire != null) 453 cookie += "expires=" + expire.toGMTString() + ";"; 454 if (domain != null) 455 cookie += "domain=" + domain + ";"; 456 if (path != null) 457 cookie += "path=" + path + ";"; 458 document.cookie = cookie; 459 }; 460 this.Expire = function (key) { 461 expire_time = new Date(); 462 expire_time.setFullYear(expire_time.getFullYear() - 1); 463 var cookie = " " + key + "=e;expires=" + expire_time + ";" 464 document.cookie = cookie; 465 } 466 } 467 </script> 468 <script type="text/javascript"> 469 function zhuce() { 470 location.href = http://www.mamicode.com/"http://www.edu-paas.com/Frame/Register.aspx"; 471 } 472 function Setcookie(key,keyval) { 473 var cookie = new JSCookie(); 474 cookie.SetCookie(key, keyval); 475 } 476 $(function () { 477 var cookie = new JSCookie(); 478 var name = cookie.GetCookie("username"); 479 var token = cookie.GetCookie("token"); 480 if (name == "" || token == "") { 481 layer.confirm(‘您尚未填写对接参数[EDU登录账号]、[token],如果未注册,点击确定。立即注册免费使用。‘, { 482 btn: [‘确定‘] //按钮 483 }, function () { 484 zhuce(); 485 }); 486 } else { 487 $("#token").val(token); 488 $("#username").val(name); 489 } 490 }); 491 492 493 </script> 494 <script type="text/javascript"> 495 var datahost = "http://office.edu-paas.com"; 496 var info = null; 497 function submitForm() { 498 $("#btnsubmit").attr({ "disabled": "disabled" }); 499 $("#loading").css("visibility", "visible"); 500 $("#convertForm").ajaxSubmit({ 501 type: "post", 502 url: "UpLoad.ashx", 503 datatype: "json", 504 success: function (data) { 505 console.log(data); 506 info = $.parseJSON(data); 507 if (info.state == "101") { 508 if (info.mes.indexOf("http://") < 0) { 509 info.mes = datahost + info.mes; 510 } 511 var fileHtml = "转换成功<a href=http://www.mamicode.com/"" + info.mes + "\" download >下载</a>" 512 if (info.img_path != "") { 513 514 fileHtml += " <a href=http://www.mamicode.com/"javascript:;\" onclick=\"openDiv(‘" + info.img_path + "‘)\">文件详细</a>" 515 } 516 $("#fileInfo").html(fileHtml); 517 518 } else { 519 $("#fileInfo").html("转换失败;错误代码:" + info.state); 520 } 521 $("#btnsubmit").removeAttr("disabled"); 522 $("#loading").css("visibility", "hidden"); 523 }, 524 error: function (ex) { } 525 }); 526 } 527 function openDiv(obj) { 528 529 var imgHtml = ""; 530 var infoimg = obj.split(‘,‘); 531 imgHtml = "<div style=\"width:900px;padding:20px;\">"; 532 for (var i = 0; i < infoimg.length; i++) { 533 if (infoimg[i].indexOf("http://") < 0) { 534 infoimg[i] = datahost + infoimg[i]; 535 } 536 imgHtml += "<div style=\"float:left;margin:10px\"><img src=http://www.mamicode.com/"" + infoimg[i] + "\" style=\"width:180px;border:1px solid #ccc\"/><br/><a href=http://www.mamicode.com/"" + datahost + infoimg[i] + "\" download>下载</a></div>"; 537 } 538 imgHtml += "</div>"; 539 layer.open({ 540 type: 1, 541 skin: ‘layui-layer-demo‘, //样式类名 542 closeBtn: 1, //不显示关闭按钮 543 shift: 2, 544 shadeClose: true, //开启遮罩关闭 545 maxWidth: 1024, 546 offset: ‘0px‘, 547 area: [‘980px‘, ‘370px‘], 548 content: imgHtml 549 }); 550 } 551 552 function checkform() { 553 var _file = document.getElementById(‘Filedata‘); 554 if (_file.value =http://www.mamicode.com/= "") { 555 alert(‘未选择文件‘); 556 $("#btnsubmit").removeAttr("disabled"); 557 $("#loading").css("visibility", "hidden"); 558 return false; 559 } 560 return true; 561 } 562 </script> 563 </body> 564 </html>
一般处理程序
public class UpLoad : IHttpHandler { public void ProcessRequest(HttpContext context) { string serverUrl = "http://office.edu-paas.com/Server/FileConvert.ashx";//服务器地址 string type = context.Request["type"]; // [type] 操作类型转换类型(1:office转pdf、2:office转swf、3:office转png、4:pdf拆页、5:pdf转swf、6:pdf转png、7:word转txt) string username = context.Request["username"]; // [username] 用户帐号 string token = context.Request["token"]; // [token] 用户系统的token string officeurl = context.Request["officeurl"];//在线文本地址 string filepath = ""; if (string.IsNullOrEmpty(officeurl)) { //如果为空 判断获取本地上传 HttpPostedFile Path = HttpContext.Current.Request.Files["Filedata"]; string str = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString(); string tp = System.Web.HttpContext.Current.Server.MapPath("/"); filepath = tp + str + Path.FileName.Substring(Path.FileName.LastIndexOf("."));//本地文件 Path.SaveAs(filepath); context.Response.Write(this.HttpUploadFile(serverUrl, filepath, type, username, token)); } else { context.Response.Write(this.HttpUploadFileofficeurl(serverUrl, officeurl, type, username, token)); } } public string HttpUploadFile(string serverUrl, string filepath, string type, string username, string token) { string content = ""; try { // [type] 操作类型转换类型(1:office转pdf、2:office转swf、 //3:office转png、4:pdf拆页、5:pdf转swf、 //6:pdf转png、7:word转txt) // [username] 用户帐号 // [token] 用户系统的token string param = "type=" + type + "&username=" + username + "&token=" + token; // 设置参数 HttpWebRequest request = WebRequest.Create(serverUrl + "?" + param) as HttpWebRequest; CookieContainer cookieContainer = new CookieContainer(); request.CookieContainer = cookieContainer; request.AllowAutoRedirect = true; request.Method = "POST"; string boundary = DateTime.Now.Ticks.ToString("X"); // 标识调试随机分隔线 request.ContentType = "multipart/form-data;charset=utf-8;boundary=" + boundary; byte[] itemBoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "\r\n"); byte[] endBoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); int pos = filepath.LastIndexOf("\\"); string fileName = filepath.Substring(pos + 1); //请求头部信息 StringBuilder sbHeader = new StringBuilder(string.Format("Content-Disposition:form-data;name=\"file\";filename=\"{0}\"\r\nContent-Type:application/octet-stream\r\n\r\n", fileName)); byte[] postHeaderBytes = Encoding.UTF8.GetBytes(sbHeader.ToString()); FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read); byte[] bArr = new byte[fs.Length]; fs.Read(bArr, 0, bArr.Length); fs.Close(); //把数组转换成流中所需字节数组类型 byte[] paramBytes = Encoding.UTF8.GetBytes(param); Stream postStream = request.GetRequestStream(); postStream.Write(itemBoundaryBytes, 0, itemBoundaryBytes.Length); postStream.Write(postHeaderBytes, 0, postHeaderBytes.Length); postStream.Write(bArr, 0, bArr.Length); postStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length); postStream.Write(paramBytes, 0, paramBytes.Length); postStream.Close(); //发送请求并获取相应回应数据 HttpWebResponse response = request.GetResponse() as HttpWebResponse; //直到request.GetResponse()程序才开始向目标网页发送Post请求 Stream instream = response.GetResponseStream(); StreamReader sr = new StreamReader(instream, Encoding.UTF8); //返回结果网页(html)代码 // "state": 返回状态, "mes": 文件下载地址 //101 转换成功 //102 转换失败 //103 转换程序异常 //104 找不到转换源文件 //105 源文件格式错误 //106 验证用户失败 //107 缺失参数 //108 服务发送数据失败 //109 上传文件异常 content = sr.ReadToEnd(); } catch (Exception ex) { content = ex.ToString(); } return content; } public string HttpUploadFileofficeurl(string serverUrl, string officeurl, string type, string username, string token) { string content = ""; try { // [type] 操作类型转换类型(1:office转pdf、2:office转swf、 //3:office转png、4:pdf拆页、5:pdf转swf、 //6:pdf转png、7:word转txt) // [username] 用户帐号 // [token] 用户系统的token string param = "type=" + type + "&username=" + username + "&token=" + token + "&officeurl=" + officeurl; // 设置参数 HttpWebRequest request = WebRequest.Create(serverUrl + "?" + param) as HttpWebRequest; CookieContainer cookieContainer = new CookieContainer(); request.CookieContainer = cookieContainer; request.AllowAutoRedirect = true; request.Method = "POST"; string boundary = DateTime.Now.Ticks.ToString("X"); // 标识调试随机分隔线 request.ContentType = "multipart/form-data;charset=utf-8;boundary=" + boundary; byte[] itemBoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "\r\n"); byte[] endBoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); //请求头部信息 StringBuilder sbHeader = new StringBuilder(string.Format("Content-Disposition:form-data;name=\"file\";\r\nContent-Type:application/octet-stream\r\n\r\n")); byte[] postHeaderBytes = Encoding.UTF8.GetBytes(sbHeader.ToString()); //把数组转换成流中所需字节数组类型 byte[] paramBytes = Encoding.UTF8.GetBytes(param); Stream postStream = request.GetRequestStream(); postStream.Write(itemBoundaryBytes, 0, itemBoundaryBytes.Length); postStream.Write(postHeaderBytes, 0, postHeaderBytes.Length); postStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length); postStream.Write(paramBytes, 0, paramBytes.Length); postStream.Close(); //发送请求并获取相应回应数据 HttpWebResponse response = request.GetResponse() as HttpWebResponse; //直到request.GetResponse()程序才开始向目标网页发送Post请求 Stream instream = response.GetResponseStream(); StreamReader sr = new StreamReader(instream, Encoding.UTF8); //返回结果网页(html)代码 // "state": 返回状态, "mes": 文件下载地址 //101 转换成功 //102 转换失败 //103 转换程序异常 //104 找不到转换源文件 //105 源文件格式错误 //106 验证用户失败 //107 缺失参数 //108 服务发送数据失败 //109 上传文件异常 content = sr.ReadToEnd(); } catch (Exception ex) { content = ex.ToString(); } return content; } public bool IsReusable { get { return false; } } }
EDU-PAAS文档转换工具
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。