foxit.ofd.ocx.new.js 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  1. var OFD = {
  2. _OCX_Array: [],
  3. find: function(id) {
  4. var ocx
  5. this._each(this._OCX_Array, function(i, e) {
  6. if (e._id == id) {
  7. ocx = e
  8. return false
  9. }
  10. })
  11. return ocx
  12. },
  13. _extend: function(defs, target) {
  14. if (!target) {
  15. return defs
  16. }
  17. this._each(defs, function(n, v) {
  18. if (!(n in target)) {
  19. target[n] = v
  20. }
  21. })
  22. return target
  23. },
  24. // 判断参数是否是数组
  25. _isArray: function(v) {
  26. return Object.prototype.toString.call(v) === '[object Array]'
  27. },
  28. // 判断参数是否是undefined或null
  29. _isNull: function(v) {
  30. return typeof v == 'undefined' || (v != 0 && !v)
  31. },
  32. // 判断参数是有有效值
  33. _isValid: function(v) {
  34. return !this._isNull(v)
  35. },
  36. // getElementById
  37. _$: function(id) {
  38. return document.getElementById(id)
  39. },
  40. // createElement
  41. _new: function(tag) {
  42. return document.createElement(tag)
  43. },
  44. // for each like jquery
  45. _each: function(o, fn) {
  46. if (this._isArray(o)) {
  47. for (
  48. var i = 0, ol = o.length, val = o[0];
  49. i < ol && fn.call(val, i, val) !== false;
  50. val = o[++i]
  51. ) {}
  52. } else {
  53. for (var i in o) {
  54. if (fn.call(o[i], i, o[i]) === false) {
  55. break
  56. }
  57. }
  58. }
  59. return o
  60. },
  61. // 一些页面方法
  62. Page: {
  63. // 获取窗口宽度
  64. width: function() {
  65. var w = 0
  66. if (window.innerWidth) {
  67. w = window.innerWidth
  68. } else if (document.body && document.body.clientWidth) {
  69. w = document.body.clientWidth
  70. }
  71. // 通过深入Document内部对body进行检测,获取窗口大小
  72. if (
  73. document.documentElement &&
  74. document.documentElement.clientHeight &&
  75. document.documentElement.clientWidth
  76. ) {
  77. w = document.documentElement.clientWidth
  78. }
  79. return w
  80. },
  81. // 获取窗口高度
  82. height: function() {
  83. var h = 0
  84. if (window.innerHeight) {
  85. h = window.innerHeight
  86. } else if (document.body && document.body.clientHeight) {
  87. h = document.body.clientHeight
  88. }
  89. // 通过深入Document内部对body进行检测,获取窗口大小
  90. if (
  91. document.documentElement &&
  92. document.documentElement.clientHeight &&
  93. document.documentElement.clientWidth
  94. ) {
  95. h = document.documentElement.clientHeight
  96. }
  97. return h
  98. },
  99. // 兼容FF和IE的事件,当e未定义的时候返回window.event
  100. dEvent: function(e) {
  101. if (!e) {
  102. return window.event
  103. } else {
  104. return e
  105. }
  106. },
  107. },
  108. }
  109. // 定义提示框对象
  110. OFD.MsgBox = {
  111. // 创建一个元素,并赋予其各种属性
  112. _new: function(tag, id, css, type, value, style) {
  113. var e = OFD._new(tag)
  114. if (OFD._isValid(id)) {
  115. e.id = id
  116. }
  117. this._css(e, css)
  118. if (OFD._isValid(type)) {
  119. e.type = type
  120. }
  121. if (OFD._isValid(value)) {
  122. e.value = value
  123. }
  124. if (OFD._isValid(style)) {
  125. OFD._each(style, function(n, v) {
  126. e.style[n] = v
  127. })
  128. }
  129. return e
  130. },
  131. // 对象转为字符串,用;号分割
  132. _o2s: function(obj) {
  133. var r = []
  134. OFD._each(obj, function(n, v) {
  135. r.push(n + ':' + v)
  136. })
  137. if (r.length > 0) {
  138. return r.join(';')
  139. }
  140. return ''
  141. },
  142. // 设置元素的css
  143. _css: function(e, css) {
  144. if (OFD._isValid(css)) {
  145. if (typeof css == 'string') {
  146. e.style.cssText = css
  147. } else {
  148. var text = this._o2s(css)
  149. e.style.cssText = text
  150. }
  151. }
  152. },
  153. // 初始化对话框的DOM对象,并设置相关的样式
  154. init: function(msg, title) {
  155. // 覆盖背景,将当前页面其他内容覆盖
  156. this.background = this._new(
  157. 'div',
  158. 'maskDiv',
  159. {
  160. position: 'absolute',
  161. top: '0',
  162. left: '0',
  163. filter: 'alpha(opacity = 30)',
  164. '-moz-opacity': '0.3',
  165. opacity: '0.3',
  166. background: '#000',
  167. 'z-index': '9990',
  168. },
  169. null,
  170. null,
  171. {
  172. width: OFD.Page.width() + 'px',
  173. height: OFD.Page.height() + 'px',
  174. }
  175. )
  176. // 标题,对话框标题容器
  177. this.titleContainer = this._new('div', 'messageBoxTitle', {
  178. height: '20px',
  179. padding: '4px',
  180. cursor: 'move',
  181. })
  182. // 对话框标题内容,如果为空则自动显示“消息”
  183. var titleText
  184. if (!title) {
  185. titleText = '提示'
  186. } else {
  187. titleText = title
  188. }
  189. this.titleObj = document.createTextNode(titleText)
  190. this.titleSpan = this._new('span', null, {
  191. float: 'left',
  192. })
  193. this.titleSpan.appendChild(this.titleObj)
  194. this.titleContainer.appendChild(this.titleSpan)
  195. var closeBtnCSS = {
  196. float: 'right',
  197. background: '#e3f1ff',
  198. border: 'none',
  199. color: '#96caff',
  200. 'font-size': '12px',
  201. }
  202. var closeBtnHover = OFD._extend(closeBtnCSS, {
  203. background: '#f00',
  204. color: '#fff',
  205. '-moz-border-radius': '3px',
  206. '-webkit-border-radius': '3px',
  207. })
  208. this.closeBtn = this._new('input', 'closeBtn', closeBtnCSS, 'button', 'X')
  209. var cb = this.closeBtn
  210. this.closeBtn.onmouseover = function() {
  211. OFD.MsgBox._css(cb, closeBtnHover)
  212. }
  213. this.closeBtn.onmouseout = function() {
  214. OFD.MsgBox._css(cb, closeBtnCSS)
  215. }
  216. this.titleContainer.appendChild(this.closeBtn)
  217. // 消息内容
  218. this.messageContainer = this._new('div', 'messageContainer', {
  219. padding: '12px 4px',
  220. /* "padding-left":"90px", */
  221. background: '#eef7ff',
  222. margin: '0 4px',
  223. border: '1px solid #fff',
  224. '-moz-border-radius': '2px',
  225. '-webkit-border-radius': '2px',
  226. })
  227. this.messageStr = msg
  228. // this.messageObj = document.createTextNode(msg);
  229. this.messageObj = OFD._new('div')
  230. this.messageObj.innerHTML = this.messageStr
  231. this.messageContainer.appendChild(this.messageObj)
  232. this.footContainer = this._new('div', 'messageBoxFoot', {
  233. position: 'relative',
  234. height: '20px',
  235. padding: '4px',
  236. })
  237. // 确定按钮
  238. this.confirmBtn = this._new(
  239. 'input',
  240. 'okBtn',
  241. {
  242. float: 'right',
  243. border: '1px solid #fff',
  244. '-moz-border-radius': '3px',
  245. '-webkit-border-radius': '3px',
  246. background: '#c0ddfb',
  247. 'line-height': '24px',
  248. },
  249. 'button',
  250. '确定'
  251. )
  252. this.footContainer.appendChild(this.confirmBtn)
  253. // 消息框的整体
  254. this.messageBox = this._new(
  255. 'div',
  256. 'messageBox',
  257. {
  258. width: '308px',
  259. position: 'absolute',
  260. background: '#e3f1ff',
  261. border: 'solid 1px #b3d7ff',
  262. opacity: '1',
  263. 'z-index': '9999',
  264. '-moz-border-radius': '3px',
  265. '-webkit-border-radius': '3px',
  266. 'font-size': '12px',
  267. 'line-height': '24px',
  268. },
  269. null,
  270. null,
  271. {
  272. // 对话框的定位,根据宽度和高度自动生成定位
  273. top: parseInt(OFD.Page.height()) / 2 - 100 + 'px',
  274. left: parseInt(OFD.Page.width()) / 2 - 150 + 'px',
  275. }
  276. )
  277. // 将元素添加到对话框中
  278. this.messageBox.appendChild(this.titleContainer)
  279. this.messageBox.appendChild(this.messageContainer)
  280. this.messageBox.appendChild(this.footContainer)
  281. },
  282. // 对话框释放函数
  283. dispose: function() {
  284. var background = OFD._$('maskDiv')
  285. var messageBox = OFD._$('messageBox')
  286. document.body.removeChild(background)
  287. document.body.removeChild(messageBox)
  288. },
  289. // 对话框显示的主方法
  290. show: function(msg, title) {
  291. // 初始化对话框基本元素
  292. this.init(msg, title)
  293. // 将对话框以及背景加入到body中
  294. document.body.appendChild(this.background)
  295. document.body.appendChild(this.messageBox)
  296. // 定义按钮,当点击按钮的时候关闭对话框
  297. this.confirmBtn.onclick = this.dispose
  298. this.closeBtn.onclick = this.dispose
  299. // 定义对话框的拖动事件
  300. var nowTitleContainer = this.titleContainer
  301. // 当在标题上点击的时候开始实现拖动
  302. this.titleContainer.onmousedown = function(e) {
  303. var messageBox = OFD._$('messageBox')
  304. var startX = OFD.Page.dEvent(e).clientX
  305. var startY = OFD.Page.dEvent(e).clientY
  306. var offsetLeft = messageBox.offsetLeft
  307. var offsetTop = messageBox.offsetTop
  308. // 当鼠标移动到时候对话框跟随鼠标移动,为了防止作用的区域过小对话框移动出问题,这个地方选择了对body对象注册mousemove事件
  309. document.body.onmousemove = function(e) {
  310. // 设置对话框的具体坐标
  311. messageBox.style.top = offsetTop + OFD.Page.dEvent(e).clientY - startY + 'px'
  312. messageBox.style.left = offsetLeft + OFD.Page.dEvent(e).clientX - startX + 'px'
  313. }
  314. // 当鼠标释放即mouseup事件触发后注销body的mousemove事件同时注销body的mouseup事件自身,以防止事件污染
  315. document.body.onmouseup = function() {
  316. document.body.onmousemove = null
  317. document.body.onmouseup = null
  318. }
  319. }
  320. },
  321. }
  322. // OCX类型及方法
  323. OFD.OCX = function(options) {
  324. // OCX的CLSID
  325. this.clsid = '9A9F603B-51A8-4630-AE99-4BBF01675575'
  326. // OCX的Object ID
  327. this._id
  328. // 配置
  329. this.opts = OFD._extend(
  330. {
  331. width: '100%',
  332. height: OFD.Page.height() + 'px',
  333. compsite: {
  334. 'toolstate handtool': false,
  335. 'toolstate selecttext': false,
  336. 'vnavigator outline': false,
  337. ExportStream: false,
  338. open: false,
  339. print: false,
  340. },
  341. loadMsg: '<span>正在加载控件,请稍候....</span>',
  342. // 控件安装程序的下载路径
  343. downURL: null,
  344. },
  345. options
  346. )
  347. // 控件对象
  348. this.ax
  349. // 缓存用户操作.因为某些情况下,用户操作时,控件还没有初始化完毕
  350. this._optCache = {
  351. compsite: [],
  352. callback: [],
  353. open: [],
  354. }
  355. // 加载控件
  356. this.load = function() {
  357. if (!('div' in this.opts)) {
  358. // OFD.MsgBox.show("请指定一个div,以便写入ActiveX!","错误信息");
  359. // return;
  360. // 新建一个div放置控件,并追加到body的最后
  361. var newDiv = OFD._new('div')
  362. newDiv.id = 'ofd_div_' + this._randomString(5)
  363. document.body.appendChild(newDiv)
  364. this.opts.div = newDiv.id
  365. }
  366. var div = OFD._$(this.opts.div)
  367. // if (this._hasActiveX()) {
  368. div.innerHTML = this.opts.loadMsg
  369. this._id = 'ofd_ocx_' + this._randomString(10)
  370. OFD._OCX_Array.push(this) // 放入队列,以方便查找使用
  371. this._writeOCX(div)
  372. // } else {
  373. // div.innerHTML = "<span style='color:red;'>加载ActiveX控件失败!</span>";
  374. // }
  375. return this
  376. }
  377. // 加载配置,完成准备工作,只执行一次
  378. this.ready = function() {
  379. if (this.ax) {
  380. // 已经初始化
  381. return this
  382. }
  383. var o = OFD._$(this._id)
  384. if (!o || !('openFile' in o)) {
  385. OFD.MsgBox.show('控件没有正确初始化!')
  386. div.innerHTML = '<span>ActiveX控件未正确初始化!</span>'
  387. return
  388. }
  389. this.ax = o // 赋值,很重要
  390. return this
  391. }
  392. // 生成随机串
  393. this._randomString = function(l) {
  394. var x = '0123456789qwertyuioplkjhgfdsazxcvbnm'
  395. var tmp = ''
  396. for (var i = 0; i < l; i++) {
  397. tmp += x.charAt(Math.ceil(Math.random() * 100000000) % x.length)
  398. }
  399. return tmp
  400. }
  401. // 判断是否安装了OFD控件
  402. this._hasActiveX = function() {
  403. if ('ActiveXObject' in window) {
  404. // 判断是否IE
  405. try {
  406. // 判断是否安装OFD阅读器
  407. return new ActiveXObject('FoxitReader.FoxitReaderCtl')
  408. } catch (e) {
  409. var html = 'OFD阅读控件没有正确安装,请下载安装!'
  410. if (OFD._isValid(this.opts.downURL)) {
  411. html +=
  412. "<br><a href='" + //
  413. this.opts.downURL + //
  414. "' target='_blank'>下载</a>"
  415. }
  416. html +=
  417. '<br>由于安装程序会更改IE的安全设置并注册dll文件,一些安全软件(如360安全卫士)可能会弹出安全警告,允许本软件继续即可。<br>建议使用管理员权限运行本软件。'
  418. OFD.MsgBox.show(html)
  419. }
  420. } else {
  421. OFD.MsgBox.show('无法显示ActiveX控件,请使用IE访问')
  422. }
  423. return false
  424. }
  425. // 输出OCX的Object HTML
  426. this._writeOCX = function(div) {
  427. if ('ActiveXObject' in window) {
  428. OFD._$(this.opts.div).innerHTML =
  429. "<object name='ht_foxit' id='" +
  430. this._id + //
  431. "' width='" + //
  432. this.opts.width + //
  433. "' height='" + //
  434. this.opts.height + //
  435. "' classid='CLSID:" +
  436. this.clsid +
  437. "'>" +
  438. "<param name='object_id' value = '" +
  439. this._id +
  440. "'> " + //
  441. '</object>'
  442. } else {
  443. OFD._$(this.opts.div).innerHTML =
  444. "<embed id='" +
  445. this._id + // id
  446. "' width='" +
  447. this.opts.width + // width
  448. "' height='" +
  449. this.opts.height + // heigth
  450. "' type='application/ofd" +
  451. "'>"
  452. }
  453. }
  454. // 检查组件是否准备完毕
  455. this._check = function() {
  456. return OFD._isValid(this.ax)
  457. }
  458. // 显示和隐藏组件
  459. /* this.setCompositeVisible = function (name, visible) {
  460. if (this._check()) {
  461. if (OFD._isArray(name)) {
  462. for (var i in name) {
  463. var n = name[i];
  464. this.ax.setCompositeVisible(n, visible);
  465. }
  466. } else {
  467. this.ax.setCompositeVisible(name, visible);
  468. }
  469. } else {
  470. this._optCache.compsite.push({
  471. n: name,
  472. v: visible
  473. });
  474. }
  475. return this;
  476. };*/
  477. // 设置回调
  478. this.setCallback = function(name, func, after) {
  479. if (this._check()) {
  480. this.ax.setCallback(name, func, after)
  481. } else {
  482. this._optCache.callback.push({
  483. n: name,
  484. f: func,
  485. a: after,
  486. })
  487. }
  488. return this
  489. }
  490. // 打开文件
  491. this._open = function(path, breadonly) {
  492. if (this._check()) {
  493. try {
  494. return this.ax.openFile(path)
  495. } catch (e) {
  496. return this.ax.openFile(path, breadonly)
  497. }
  498. } else {
  499. this._optCache.open.push({
  500. p: path,
  501. })
  502. return false
  503. }
  504. }
  505. // 打开Ps文件
  506. this._openPSFile = function(
  507. path,
  508. breadonly,
  509. nPageWidth,
  510. nPageHeight,
  511. nMarginLeft,
  512. nMarginTop,
  513. nMarginRight,
  514. nMarginBottom
  515. ) {
  516. if (this._check()) {
  517. try {
  518. return this.ax.openPSFile(
  519. path,
  520. breadonly,
  521. nPageWidth,
  522. nPageHeight,
  523. nMarginLeft,
  524. nMarginTop,
  525. nMarginRight,
  526. nMarginBottom
  527. )
  528. } catch (e) {}
  529. } else {
  530. this._optCache.open.push({
  531. p: path,
  532. })
  533. return false
  534. }
  535. }
  536. this._save = function(path) {
  537. if (this._check()) {
  538. try {
  539. /*
  540. if (this.ax.saveFile(path) == 1)
  541. return false;
  542. else
  543. return true;*/
  544. return this.ax.saveFile(path)
  545. } catch (e) {
  546. return this.ax.saveFile(path)
  547. }
  548. } else return false
  549. }
  550. this._close = function() {
  551. /*
  552. if (this._check()) {
  553. if (this.ax.closeFile() == 1)
  554. return false;
  555. else
  556. return true;
  557. }
  558. else
  559. return false;*/
  560. if (this._check()) {
  561. return this.ax.closeFile()
  562. }
  563. }
  564. this._setSealName = function(strSealName) {
  565. if (this._check()) {
  566. this.ax.setSealName(strSealName)
  567. }
  568. }
  569. this._setSealId = function(strSealId) {
  570. if (this._check()) {
  571. this.ax.setSealId(strSealId)
  572. }
  573. }
  574. this._searchFull = function(strSearchFull) {
  575. if (this._check()) {
  576. this.ax.searchFull(strSearchFull)
  577. }
  578. }
  579. this._setSealSignMethod = function(strSignMethod) {
  580. if (this._check()) {
  581. this.ax.setSealSignMethod(strSignMethod)
  582. }
  583. }
  584. this._setCompositeVisible = function(strCompName, bVisible) {
  585. if (this._check()) {
  586. this.ax.setCompositeVisible(strCompName, bVisible)
  587. }
  588. }
  589. this._setViewPreference = function(key, value) {
  590. if (this._check()) {
  591. this.ax.setViewPreference(key, value)
  592. }
  593. }
  594. this._setLogURL = function(logurl, oid) {
  595. if (this._check()) {
  596. this.ax.setLogURL(logurl, oid)
  597. }
  598. }
  599. this._addTrackInfo = function(xmlParam) {
  600. if (this._check()) {
  601. this.ax.addTrackInfo(xmlParam)
  602. }
  603. }
  604. this._setPrintInfo = function(num) {
  605. if (this._check()) {
  606. this.ax.setPrintInfo(num)
  607. }
  608. }
  609. this.setPrintScale = function(value) {
  610. if (this._check()) {
  611. this.ax.setPrintScale(value)
  612. }
  613. }
  614. this._printFile = function(title, bgray) {
  615. if (this._check()) {
  616. this.ax.PrintFile(title, bgray, 0)
  617. }
  618. }
  619. this._quietPrintFile = function(title, bgray, isquietprint) {
  620. if (this._check()) {
  621. this.ax.PrintFile(title, bgray, isquietprint)
  622. }
  623. }
  624. this._getLogFilePath = function() {
  625. if (this._check()) {
  626. return this.ax.getLogFilePath()
  627. }
  628. }
  629. this._getLogFileContent = function() {
  630. if (this._check()) {
  631. return this.ax.getLogFileContent()
  632. }
  633. }
  634. this._setDisPlayMode = function(disPlayMode) {
  635. if (this._check()) {
  636. this.ax.setDisPlayMode(disPlayMode)
  637. }
  638. }
  639. this._setZoomMode = function(zoomMode) {
  640. if (this._check()) {
  641. this.ax.setZoomMode(zoomMode)
  642. }
  643. }
  644. this._getAppVersion = function() {
  645. if (this._check()) {
  646. return this.ax.getAppVersion()
  647. }
  648. }
  649. //获取公文域位置
  650. this._getTaggedPosition = function(docdomain) {
  651. if (this._check()) {
  652. return this.ax.getTaggedPosition(docdomain)
  653. }
  654. }
  655. //获取公文域内容
  656. this._getTaggedText = function(docdomain) {
  657. if (this._check()) {
  658. return this.ax.getTaggedText(docdomain)
  659. }
  660. }
  661. this._removeAppPermission = function(permission) {
  662. if (this._check()) {
  663. this.ax.removeAppPermission(permission)
  664. }
  665. }
  666. this._isQuietPrinting = function() {
  667. if (this._check()) {
  668. return this.ax.isQuietPrinting()
  669. }
  670. }
  671. this._isSigning = function() {
  672. if (this._check()) {
  673. return this.ax.isSigning()
  674. }
  675. }
  676. this._printSetting = function() {
  677. if (this._check()) {
  678. return this.ax.printSetting()
  679. }
  680. }
  681. this._getPluginVersion = function() {
  682. if (this._check()) {
  683. return this.ax.getPluginVersion()
  684. }
  685. }
  686. this._setMetaData = function(key, value) {
  687. if (this._check()) {
  688. this.ax.setMetaData(key, value)
  689. }
  690. }
  691. this._getMetaData = function(key) {
  692. if (this._check()) {
  693. return this.ax.getMetaData(key)
  694. }
  695. }
  696. this._setUserName = function(uname) {
  697. if (this._check()) {
  698. return this.ax.setUserName(uname)
  699. }
  700. }
  701. this._getUserName = function() {
  702. if (this._check()) {
  703. return this.ax.getUserName()
  704. }
  705. }
  706. this._clearTrackInfo = function() {
  707. if (this._check()) {
  708. this.ax.clearTrackInfo()
  709. }
  710. }
  711. this._setZoomRadio = function(value) {
  712. if (this._check()) {
  713. this.ax.setZoomRadio(value)
  714. }
  715. }
  716. this._getZoomRadio = function() {
  717. if (this._check()) {
  718. return this.ax.getZoomRadio()
  719. }
  720. }
  721. this._setLogSvrURL = function(url) {
  722. if (this._check()) {
  723. this.ax.setLogSvrURL(url)
  724. }
  725. }
  726. this._countSignatures = function() {
  727. if (this._check()) {
  728. return this.ax.CountSigns()
  729. }
  730. }
  731. this._verifySignature = function(index, nFlag) {
  732. if (this._check()) {
  733. return this.ax.verifySignature(index, nFlag)
  734. }
  735. }
  736. this._isSignVerify = function() {
  737. if (this._check()) {
  738. return this.ax.isSignVerify()
  739. }
  740. }
  741. this._setCompositeEnable = function(strcmpName, bisEnable) {
  742. if (this._check()) {
  743. //alert(strcmpName)
  744. return this.ax.setCompositeEnable(strcmpName, bisEnable)
  745. }
  746. }
  747. this._importFormData = function(formdata) {
  748. if (this._check()) {
  749. //alert(strcmpName)
  750. return this.ax.importFormData(formdata)
  751. }
  752. }
  753. this._showToolbar = function(isVisible) {
  754. if (this._check()) {
  755. //alert(strcmpName)
  756. return this.ax.showToolbar(isVisible)
  757. }
  758. }
  759. this._showContextMenu = function(isVisible) {
  760. if (this._check()) {
  761. //alert(strcmpName)
  762. return this.ax.showContextMenu(isVisible)
  763. }
  764. }
  765. this._showViewContextMenu = function(isVisible) {
  766. if (this._check()) {
  767. return this.ax.showViewContextMenu(isVisible)
  768. }
  769. }
  770. this._setReadMode = function(bReadMode) {
  771. if (this._check()) {
  772. //alert(strcmpName)
  773. return this.ax.setReadMode(bReadMode)
  774. }
  775. }
  776. this._getCurPageIndex = function() {
  777. if (this._check()) {
  778. //alert(strcmpName)
  779. return this.ax.GetCurPageIndex()
  780. }
  781. }
  782. // 获取页码
  783. this.getCurPageIndex = function() {
  784. return this._getCurPageIndex()
  785. }
  786. // 打开文件
  787. this.openFile = function(url, breadonly) {
  788. return this._open(url, breadonly)
  789. }
  790. //打开Ps文件
  791. this.openPSFile = function(
  792. url,
  793. breadonly,
  794. nPageWidth,
  795. nPageHeight,
  796. nMarginLeft,
  797. nMarginTop,
  798. nMarginRight,
  799. nMarginBottom
  800. ) {
  801. return this._openPSFile(
  802. url,
  803. breadonly,
  804. nPageWidth,
  805. nPageHeight,
  806. nMarginLeft,
  807. nMarginTop,
  808. nMarginRight,
  809. nMarginBottom
  810. )
  811. }
  812. //保存文件
  813. this.saveFile = function(url) {
  814. return this._save(url)
  815. }
  816. //关闭文件
  817. this.closeFile = function() {
  818. return this._close(false)
  819. }
  820. //设置将要应用的印章名称
  821. this.setSealName = function(strSealName) {
  822. return this._setSealName(strSealName)
  823. }
  824. //设置将要应用的印章标识
  825. this.setSealId = function(sealid) {
  826. return this._setSealId(sealid)
  827. }
  828. //查询 searchFull。。。。。。。。。
  829. this.searchFull = function(searchfull) {
  830. return this._searchFull(searchfull)
  831. }
  832. //设置将要应用的签名算法
  833. this.setSealSignMethod = function(strSignMethod) {
  834. return this._setSealSignMethod(strSignMethod)
  835. }
  836. //设置Reader界面按钮或组件是否可见
  837. this.setCompositeVisible = function(strCompName, bVisible) {
  838. return this._setCompositeVisible(strCompName, bVisible)
  839. }
  840. //导航栏
  841. this.setViewPreference = function(key, value) {
  842. return this._setViewPreference(key, value)
  843. }
  844. //日志上传
  845. this.setLogURL = function(logurl, oid) {
  846. return this._setLogURL(logurl, oid)
  847. }
  848. //二维码
  849. this.addTrackInfo = function(xmlParam) {
  850. return this._addTrackInfo(xmlParam)
  851. }
  852. //打印控制
  853. this.setPrintInfo = function(num) {
  854. return this._setPrintInfo(num)
  855. }
  856. //打印
  857. //title文档标题,
  858. this.printFile = function(title, bgray) {
  859. return this._printFile(title, bgray)
  860. }
  861. //静默打印
  862. this.quietPrintFile = function(title, bgray, isquietprint) {
  863. return this._quietPrintFile(title, bgray, isquietprint)
  864. }
  865. //获取打印日志路径
  866. this.getLogFilePath = function() {
  867. return this._getLogFilePath()
  868. }
  869. //获取日志打印内容 ----新增
  870. this.getLogFileContent = function() {
  871. return this._getLogFileContent()
  872. }
  873. // setCompositeEnable --新增
  874. this.setCompositeEnable = function(strcmpName, bisEnable) {
  875. return this._setCompositeEnable(strcmpName, bisEnable)
  876. }
  877. //设置阅读模式
  878. this.setDisPlayMode = function(disPlayMode) {
  879. return this._setDisPlayMode(disPlayMode)
  880. }
  881. //设置显示宽度
  882. this.setZoomMode = function(zoomMode) {
  883. return this._setZoomMode(zoomMode)
  884. }
  885. //获取版本号
  886. this.getAppVersion = function() {
  887. return this._getAppVersion()
  888. }
  889. //获取公文域位置
  890. this.getTaggedPosition = function(docdomain) {
  891. return this._getTaggedPosition(docdomain)
  892. }
  893. //获取公文域内容
  894. this.getTaggedText = function(docdomain) {
  895. return this._getTaggedText(docdomain)
  896. }
  897. //设置打开文档权限
  898. this.removeAppPermission = function(permission) {
  899. return this._removeAppPermission(permission)
  900. }
  901. //判断是否正在打印
  902. this.isQuietPrinting = function() {
  903. return this._isQuietPrinting()
  904. }
  905. //判断是否正在签章
  906. this.isSigning = function() {
  907. return this._isSigning()
  908. }
  909. //静默打印设置
  910. this.printSetting = function() {
  911. return this._printSetting()
  912. }
  913. //获取插件版本
  914. this.getPluginVersion = function() {
  915. return this._getPluginVersion()
  916. }
  917. //增加元数据
  918. this.setMetaData = function(key, value) {
  919. this._setMetaData(key, value)
  920. }
  921. //获取元数据
  922. this.getMetaData = function(key) {
  923. return this._getMetaData(key)
  924. }
  925. //添加用户名
  926. this.setUserName = function(uname) {
  927. return this._setUserName(uname)
  928. }
  929. //获取用户名
  930. this.getUserName = function() {
  931. return this._getUserName()
  932. }
  933. //清除水印
  934. this.clearTrackInfo = function() {
  935. this._clearTrackInfo()
  936. }
  937. //设置缩放比例
  938. this.setZoomRadio = function(zoomvalue) {
  939. this._setZoomRadio(zoomvalue)
  940. }
  941. //获取缩放比例
  942. this.getZoomRadio = function() {
  943. return this._getZoomRadio()
  944. }
  945. //设置上传地址
  946. this.setLogSvrURL = function(url) {
  947. this._setLogSvrURL(url)
  948. }
  949. //获取签章个数
  950. this.countSignatures = function() {
  951. return this._countSignatures()
  952. }
  953. //根据索引验章
  954. this.verifySignature = function(index, nFlag) {
  955. return this._verifySignature(index, nFlag)
  956. }
  957. //全部验章
  958. this.isSignVerify = function() {
  959. return this._isSignVerify()
  960. }
  961. //导入表单数据
  962. this.importFormData = function(fromdata) {
  963. return this._importFormData(fromdata)
  964. }
  965. //显示工具栏
  966. this.showToolbar = function(isVisible) {
  967. return this._showToolbar(isVisible)
  968. }
  969. //火狐显示右键工具菜单
  970. this.showContextMenu = function(isVisible) {
  971. return this._showContextMenu(isVisible)
  972. }
  973. //IE显示右键工具菜单
  974. this.showViewContextMenu = function(isVisible) {
  975. return this._showViewContextMenu(isVisible)
  976. }
  977. //设置阅读模式
  978. this.setReadMode = function(bReadMode) {
  979. return this._setReadMode(bReadMode)
  980. }
  981. //获取当前页的页码
  982. this.getCurrentPageIndex = function() {
  983. if (this._check()) {
  984. return this.ax.getCurrentPageIndex()
  985. }
  986. }
  987. //获取当前文档页数
  988. this.getPageCount = function(Index) {
  989. if (this._check()) {
  990. return this.ax.getPageCount(Index)
  991. }
  992. }
  993. //获取当前文档个数
  994. this.getDocumentCount = function() {
  995. if (this._check()) {
  996. return this.ax.getDocumentCount()
  997. }
  998. }
  999. //跳转页面
  1000. this.gotoPage = function(index) {
  1001. if (this._check()) {
  1002. return this.ax.gotoPage(index)
  1003. }
  1004. }
  1005. //外交部激活码激活
  1006. this.installKey = function(installKey) {
  1007. if (this._check()) {
  1008. return this.ax.installKey(installKey)
  1009. }
  1010. }
  1011. //设置线宽
  1012. this.setThickness = function(thickness) {
  1013. if (this._check()) {
  1014. this.ax.setThickness(thickness)
  1015. }
  1016. }
  1017. //设置线条颜色
  1018. this.setColor = function(a, r, g, b) {
  1019. if (this._check()) {
  1020. this.ax.setColor(a, r, g, b)
  1021. }
  1022. }
  1023. //设置签批区域
  1024. this.setForm = function(setForm) {
  1025. if (this._check()) {
  1026. this.ax.setForm(setForm)
  1027. }
  1028. }
  1029. //设置签批区域颜色
  1030. this.setFormHighlightColor = function(a, r, g, b) {
  1031. if (this._check()) {
  1032. this.ax.setFormHighlightColor(a, r, g, b)
  1033. }
  1034. }
  1035. //设置哪些签批区域可用
  1036. this.setAvalibleFieldNames = function(setavalible) {
  1037. if (this._check()) {
  1038. this.ax.setAvalibleFieldNames(setavalible)
  1039. }
  1040. }
  1041. //设置绘板空白区域的颜色。
  1042. this.setMaskLayerColor = function(a, r, g, b) {
  1043. if (this._check()) {
  1044. this.ax.setMaskLayerColor(a, r, g, b)
  1045. }
  1046. }
  1047. //获取签批的图片内容
  1048. this.getRuntimeFormImage = function(name) {
  1049. if (this._check()) {
  1050. return this.ax.getRuntimeFormImage(name)
  1051. }
  1052. }
  1053. //设置铅笔线宽
  1054. this.setPencilThickness = function(thickness) {
  1055. if (this._check()) {
  1056. this.ax.setPencilThickness(thickness)
  1057. }
  1058. }
  1059. //设置铅笔颜色
  1060. this.setPencilColor = function(r, g, b) {
  1061. if (this._check()) {
  1062. this.ax.setPencilColor(r, g, b)
  1063. }
  1064. }
  1065. //设置铅笔工具
  1066. this.setCurrentTool = function(pencil) {
  1067. if (this._check()) {
  1068. this.ax.setCurrentTool(pencil)
  1069. }
  1070. }
  1071. //添加手写签批
  1072. this.AddSign = function(certurl, signurl) {
  1073. if (this._check()) {
  1074. this.ax.AddSign(certurl, signurl)
  1075. }
  1076. }
  1077. //获取证书列表
  1078. this.GetCertList = function() {
  1079. if (this._check()) {
  1080. return this.ax.GetCertList()
  1081. }
  1082. }
  1083. //获取笔记列表
  1084. this.GetSignList = function() {
  1085. if (this._check()) {
  1086. return this.ax.GetSignList()
  1087. }
  1088. }
  1089. //删除书写的内容或笔记
  1090. this.ClearSign = function() {
  1091. if (this._check()) {
  1092. this.ax.ClearSign()
  1093. }
  1094. }
  1095. //应用手写签批
  1096. this.ApplySign = function() {
  1097. if (this._check()) {
  1098. this.ax.ApplySign()
  1099. }
  1100. }
  1101. //签名上添加水印
  1102. this.AddWaterMark = function(wmInfo) {
  1103. if (this._check()) {
  1104. this.ax.AddWaterMark(wmInfo)
  1105. }
  1106. }
  1107. //显示打印进度框
  1108. this.showPrintingTip = function(copies) {
  1109. if (this._check()) {
  1110. this.ax.showPrintingTip(copies)
  1111. }
  1112. }
  1113. //隐藏打印进度框
  1114. this.hidePrintingTip = function() {
  1115. if (this._check()) {
  1116. this.ax.hidePrintingTip()
  1117. }
  1118. }
  1119. //获取第nDocIndex文档页码
  1120. this.getPageCount = function(docIndex) {
  1121. if (this._check()) {
  1122. return this.ax.getPageCount(docIndex)
  1123. }
  1124. }
  1125. //提取第nDocIndex文档第pageindex页的缩略图
  1126. this.getPageBitmap = function(pageindex, dpi) {
  1127. if (this._check()) {
  1128. return this.ax.getPageBitmap(pageindex, dpi)
  1129. }
  1130. }
  1131. //设置文件是否可读
  1132. this.setReadOnly = function(isread) {
  1133. if (this._check()) {
  1134. this.ax.setReadOnly(isread)
  1135. }
  1136. }
  1137. //设置画笔属性
  1138. this.setAnnotProperty = function(bsName, nThickness, alpha, r, g, b) {
  1139. if (this._check()) {
  1140. this.ax.setAnnotProperty(bsName, nThickness, alpha, r, g, b)
  1141. }
  1142. }
  1143. //设置文本框属性
  1144. this.setTextEditProperty = function(
  1145. bsName,
  1146. bsFontName,
  1147. nFontSize,
  1148. nBorderThickness,
  1149. alpha,
  1150. r,
  1151. g,
  1152. b,
  1153. bShowFormatToolbar
  1154. ) {
  1155. if (this._check()) {
  1156. this.ax.setTextEditProperty(
  1157. bsName,
  1158. bsFontName,
  1159. nFontSize,
  1160. nBorderThickness,
  1161. alpha,
  1162. r,
  1163. g,
  1164. b,
  1165. bShowFormatToolbar
  1166. )
  1167. }
  1168. }
  1169. //批量打印
  1170. this.batchPrint = function(bsFontName, nFontSize, nXPos, nYPos, bsFenhao, bsTitle) {
  1171. if (this._check()) {
  1172. this.ax.batchPrint(bsFontName, nFontSize, nXPos, nYPos, bsFenhao, bsTitle)
  1173. }
  1174. }
  1175. //设置页面滚动方式
  1176. this.scrollPage = function(bScrollUp) {
  1177. if (this._check()) {
  1178. this.ax.scrollPage(bScrollUp)
  1179. }
  1180. }
  1181. this.addWaterMark = function(n1, n2, n3, n4, n5, n6, n7) {
  1182. if (this._check()) {
  1183. if (arguments.length == 1) {
  1184. return this.ax.addWaterMark(n1)
  1185. } else if (arguments.length == 6) {
  1186. // alert(6);
  1187. this.ax.addWaterMark(n1, n2, n3, n4, n5, n6)
  1188. } else if (arguments.length == 7) {
  1189. // alert(7);
  1190. this.ax.addWaterMark(n1, n2, n3, n4, n5, n6, n7)
  1191. }
  1192. }
  1193. }
  1194. //火狐回调
  1195. this.jsCallbackFun_InitSetting = function() {
  1196. if (this._check()) {
  1197. return (this.ax.JsCallbackFun_InitSetting = initSetting)
  1198. }
  1199. }
  1200. this.jsCallbackFun_UpdateInfo = function() {
  1201. return (this.ax.JsCallbackFun_UpdateInfo = UpdateInfo)
  1202. }
  1203. }
  1204. // 控件加载完毕后的回调方法
  1205. var onOFDLoaded = function(objID) {
  1206. if (OFD._isValid(objID)) {
  1207. var ocx = OFD.find(objID)
  1208. if (ocx) {
  1209. ocx.ready()
  1210. }
  1211. }
  1212. }
  1213. // 快速加载并初始化OCX控件
  1214. OFD.OCX.init = function(divID, width, height) {
  1215. var config = {}
  1216. if (OFD._isValid(divID)) {
  1217. config.div = divID
  1218. }
  1219. if (OFD._isValid(width)) {
  1220. config.width = width
  1221. }
  1222. if (OFD._isValid(height)) {
  1223. config.height = height
  1224. }
  1225. return new OFD.OCX(config).load()
  1226. }
  1227. export default OFD