Enterprise Tookit for Acrobat Products > Mobile > (Android | iOS)

JavaScript for Acrobat Reader Mobile API Reference (iOS)

File: Doc.js

  1. /*************************************************************************
  2. *
  3. * ADOBE CONFIDENTIAL
  4. * ___________________
  5. *
  6. * Copyright 2014 Adobe Systems Incorporated
  7. * All Rights Reserved.
  8. *
  9. * NOTICE: All information contained herein is, and remains
  10. * the property of Adobe Systems Incorporated and its suppliers,
  11. * if any. The intellectual and technical concepts contained
  12. * herein are proprietary to Adobe Systems Incorporated and its
  13. * suppliers and are protected by trade secret or copyright law.
  14. * Dissemination of this information or reproduction of this material
  15. * is strictly forbidden unless prior written permission is obtained
  16. * from Adobe Systems Incorporated.
  17. *
  18. **************************************************************************/
  19. /**
  20. * The Doc object provides the interface between a PDF document open in the viewer and the
  21. * JavaScript interpreter. It provides methods and properties for accessing the PDF document.
  22. *
  23. * @class Doc
  24. */
  25. /**
  26. * The total number of fields in the document.
  27. *
  28. * @property numFields
  29. * @type {Number}
  30. * @readonly
  31. */
  32. Object.defineProperty(this, 'numFields',
  33. {
  34. get: function()
  35. {
  36. return ARJavaScriptDoc.numFields;
  37. }
  38. });
  39. /**
  40. * Gets or sets the current page of the document. When setting pageNum to a specific
  41. * page, remember that the values are 0-based.
  42. *
  43. * @property pageNum
  44. * @type {Number}
  45. */
  46. Object.defineProperty(this, 'pageNum',
  47. {
  48. // Usage of pageNum has been replaced with pageIndex in the codebase. The Objective-C protocol now exposes pageIndex property instead of pageNum property.
  49. get: function()
  50. {
  51. return ARJavaScriptDoc.pageIndex;
  52. },
  53. set: function(pageNum)
  54. {
  55. ARJavaScriptDoc.pageIndex = pageNum;
  56. }
  57. });
  58. /**
  59. * Gets the name of the nth field in the document.
  60. *
  61. * @param nIndex {Number} The index of the field whose name should be obtained.
  62. * @return {String} The name of the field in the document.
  63. */
  64. getNthFieldName = function(nIndex)
  65. {
  66. if (arguments.length < 1)
  67. throw new TypeError();
  68. if (typeof nIndex != "number" || isNaN(nIndex))
  69. nIndex = AFMakeNumber(nIndex);
  70. if (typeof nIndex != "number" || isNaN(nIndex))
  71. throw new TypeError();
  72. return ARJavaScriptDoc.getNthFieldName(nIndex);
  73. }
  74. /**
  75. * Maps a Field object in the PDF document to a JavaScript variable.
  76. *
  77. * @method getField
  78. * @param cName {String} The name of the field of interest.
  79. * @return {Object} A Field object representing a form field in the PDF document.
  80. */
  81. getField = function(name)
  82. {
  83. var returnVal = null;
  84. var field = ARJavaScriptDoc.getField(name);
  85. if (field)
  86. {
  87. returnVal = new Field(field);
  88. }
  89. return returnVal;
  90. };
  91. /**
  92. * Resets the field values within a document. Resetting a field causes it to take on
  93. * its default value (which, in the case of text fields, is usually blank).
  94. *
  95. * @method resetForm
  96. * @param [fieldNames=null] {Object} An array specifying the fields to reset. If not
  97. * present or null, all fields in the form are reset.
  98. */
  99. resetForm = function(fieldNames)
  100. {
  101. ARJavaScriptDoc.resetForm(fieldNames);
  102. };
  103. /**
  104. * Submits the form to a specified URL. Currently only supports FormsCentral submissions.
  105. *
  106. * submitForm JS API currently only supports FormsCentral submissions. And FormsCentral has now
  107. * been decommissioned. Leave the submitForm code intact so that if it is executed, the return
  108. * response can be processed by the application. Leave the submitForm code intact so that it can
  109. * serve as a guide for any future non-FormsCentral submit functionality. But mark the API as
  110. * private so that any autogenerated documentation does NOT include this API.
  111. * @private
  112. * @method submitForm
  113. * @param cURL {String} The URL to submit to. cURL must be a FormsCentral target.
  114. * @param [cSubmitAs='FDF'] {String} This parameter indicates the format for submission.
  115. * Must be 'HTML' to support FormsCentral submission.
  116. * @param [cCharset='utf-8'] {String} The encoding for the values submitted. Must be
  117. * 'utf-8' to support FormsCentral submission.
  118. */
  119. submitForm = function()
  120. {
  121. var cURL = null;
  122. var cSubmitAs = null;
  123. var cCharset = null;
  124. if (arguments.length > 0)
  125. {
  126. if (typeof arguments[0].cURL == "string")
  127. {
  128. cSubmitAs = 'FDF';
  129. cCharset = 'utf-8';
  130. cURL = arguments[0].cURL;
  131. if (typeof arguments[0].cSubmitAs == "string")
  132. {
  133. cSubmitAs = arguments[0].cSubmitAs;
  134. }
  135. if (typeof arguments[0].cCharset == "string")
  136. {
  137. cCharset = arguments[0].cCharset;
  138. }
  139. }
  140. else if (typeof arguments[0] == "string")
  141. {
  142. cSubmitAs = 'FDF';
  143. cCharset = 'utf-8';
  144. cURL = arguments[0];
  145. if (arguments.length >= 9 && typeof arguments[8] == "boolean" && arguments[8] == true)
  146. {
  147. cSubmitAs = 'PDF';
  148. }
  149. else if (arguments.length >= 7 && typeof arguments[6] == "boolean" && arguments[6] == true)
  150. {
  151. cSubmitAs = 'XML';
  152. }
  153. else if (arguments.length >= 2 && typeof arguments[1] == "boolean" && arguments[1] == false)
  154. {
  155. cSubmitAs = 'none';
  156. }
  157. }
  158. }
  159. ARJavaScriptDoc.submitForm(cURL, cSubmitAs, cCharset);
  160. };
  161. // register undefined properties on the 'this' object
  162. registerUndefinedProperty(this, 'Doc', 'alternatePresentations');
  163. registerUndefinedProperty(this, 'Doc', 'author');
  164. registerUndefinedProperty(this, 'Doc', 'baseURL');
  165. registerUndefinedProperty(this, 'Doc', 'bookmarkRoot');
  166. registerUndefinedProperty(this, 'Doc', 'calculate');
  167. registerUndefinedProperty(this, 'Doc', 'creationDate');
  168. registerUndefinedProperty(this, 'Doc', 'creator');
  169. registerUndefinedProperty(this, 'Doc', 'dataObjects');
  170. registerUndefinedProperty(this, 'Doc', 'delay');
  171. registerUndefinedProperty(this, 'Doc', 'dirty');
  172. registerUndefinedProperty(this, 'Doc', 'disclosed');
  173. registerUndefinedProperty(this, 'Doc', 'docID');
  174. registerUndefinedProperty(this, 'Doc', 'documentFileName');
  175. registerUndefinedProperty(this, 'Doc', 'dynamicXFAForm');
  176. registerUndefinedProperty(this, 'Doc', 'external');
  177. registerUndefinedProperty(this, 'Doc', 'filesize');
  178. registerUndefinedProperty(this, 'Doc', 'hidden');
  179. registerUndefinedProperty(this, 'Doc', 'hostContainer');
  180. registerUndefinedProperty(this, 'Doc', 'icons');
  181. registerUndefinedProperty(this, 'Doc', 'info');
  182. registerUndefinedProperty(this, 'Doc', 'innerAppWindowRect');
  183. registerUndefinedProperty(this, 'Doc', 'innerDocWindowRect');
  184. registerUndefinedProperty(this, 'Doc', 'isModal');
  185. registerUndefinedProperty(this, 'Doc', 'keywords');
  186. registerUndefinedProperty(this, 'Doc', 'layout');
  187. registerUndefinedProperty(this, 'Doc', 'media');
  188. registerUndefinedProperty(this, 'Doc', 'metadata');
  189. registerUndefinedProperty(this, 'Doc', 'modDate');
  190. registerUndefinedProperty(this, 'Doc', 'mouseX');
  191. registerUndefinedProperty(this, 'Doc', 'mouseY');
  192. registerUndefinedProperty(this, 'Doc', 'noautocomplete');
  193. registerUndefinedProperty(this, 'Doc', 'nocache');
  194. registerUndefinedProperty(this, 'Doc', 'numPages');
  195. registerUndefinedProperty(this, 'Doc', 'numTemplates');
  196. registerUndefinedProperty(this, 'Doc', 'path');
  197. registerUndefinedProperty(this, 'Doc', 'outerAppWindowRect');
  198. registerUndefinedProperty(this, 'Doc', 'outerDocWindowRect');
  199. registerUndefinedProperty(this, 'Doc', 'pageWindowRect');
  200. registerUndefinedProperty(this, 'Doc', 'permStatusReady');
  201. registerUndefinedProperty(this, 'Doc', 'producer');
  202. registerUndefinedProperty(this, 'Doc', 'requiresFullSave');
  203. registerUndefinedProperty(this, 'Doc', 'securityHandler');
  204. registerUndefinedProperty(this, 'Doc', 'selectedAnnots');
  205. registerUndefinedProperty(this, 'Doc', 'sounds');
  206. registerUndefinedProperty(this, 'Doc', 'spellDictionaryOrder');
  207. registerUndefinedProperty(this, 'Doc', 'spellLanguageOrder');
  208. registerUndefinedProperty(this, 'Doc', 'subject');
  209. registerUndefinedProperty(this, 'Doc', 'templates');
  210. registerUndefinedProperty(this, 'Doc', 'title');
  211. registerUndefinedProperty(this, 'Doc', 'URL');
  212. registerUndefinedProperty(this, 'Doc', 'viewState');
  213. registerUndefinedProperty(this, 'Doc', 'xfa');
  214. registerUndefinedProperty(this, 'Doc', 'XFAForeground');
  215. registerUndefinedProperty(this, 'Doc', 'zoom');
  216. registerUndefinedProperty(this, 'Doc', 'zoomType');

© 2013-15 Adobe Systems, Inc. All rights reserved. Use of these APIs including, the download of software, submission of comments, ideas, feature requests and techniques, and Adobe's rights to use such submitted materials, is governed by the Adobe.com Terms of Use and the Adobe Privacy Policy.