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

JavaScript for Acrobat Reader Mobile API Reference (Android)

File: Doc.js

                        /*************************************************************************
                         *
                         * ADOBE CONFIDENTIAL
                         * ___________________
                         *
                         * Copyright 2012 Adobe Systems Incorporated
                         * All Rights Reserved.
                         *
                         * NOTICE: All information contained herein is, and remains
                         * the property of Adobe Systems Incorporated and its suppliers,
                         * if any. The intellectual and technical concepts contained
                         * herein are proprietary to Adobe Systems Incorporated and its
                         * suppliers and are protected by trade secret or copyright law.
                         * Dissemination of this information or reproduction of this material
                         * is strictly forbidden unless prior written permission is obtained
                         * from Adobe Systems Incorporated.
                         *
                         **************************************************************************/
                        
                        /**
                         *  The Doc object provides the interface between a PDF document open in the viewer and the
                         *  JavaScript interpreter. It provides methods and properties for accessing the PDF document.
                         *
                         *  @class Doc
                         */
                        
                        /**
                         *  The total number of fields in the document.
                         *
                         *  @property numFields
                         *  @type {Number}
                         *  @readonly
                         */
                        Object.defineProperty(this, 'numFields',
                        {
                            get: function()
                            {
                                return window._doc.getNumberOfFields();
                            }
                        });
                        
                        /**
                         *  Gets or sets the current page of the document. When setting pageNum to a specific 
                         *  page, remember that the values are 0-based.
                         *
                         *  @property pageNum
                         *  @type {Number}
                         */
                        Object.defineProperty(this, 'pageNum',
                        {
                            get: function()
                            {
                                return window._doc.getPageIndex();
                            },
                            set: function(pageNum)
                            {
                                return window._doc.setPageIndex(pageNum);
                            }
                        });
                        
                        /**
                         *  Gets the name of the nth field in the document.
                         *
                         *  @param nIndex {Number} The index of the field whose name should be obtained.
                         *  @return {String} The name of the field in the document.
                         */
                        getNthFieldName = function(nIndex)
                        {
                            if (arguments.length < 1)
                                throw new TypeError();
                            
                            if (typeof nIndex != "number" || isNaN(nIndex))
                                nIndex = AFMakeNumber(nIndex);
                            
                            if (typeof nIndex != "number" || isNaN(nIndex))
                                throw new TypeError();
                                
                            return window._doc.getNthFieldName(nIndex);
                        }
                        
                        /**
                         *  Maps a Field object in the PDF document to a JavaScript variable.
                         *
                         *  @method getField
                         *  @param cName {String} The name of the field of interest.
                         *  @return {Object} A Field object representing a form field in the PDF document.
                         */
                        getField = function(name)
                        {
                        	var ret;
                        	
                            var fieldName = window._doc.getField(name);
                            if (fieldName == name)
                            {
                            	ret = new Field(name);	
                            }
                            
                            return ret;
                        };
                        
                        /**
                         *  Resets the field values within a document. Resetting a field causes it to take on 
                         *  its default value (which, in the case of text fields, is usually blank).
                         *
                         *  @method resetForm
                         *  @param [fieldNames=null] {Object} An array specifying the fields to reset. If not 
                         *  present or null, all fields in the form are reset.
                         */
                        resetForm = function(fieldNames)
                        {
                            if (typeof fieldNames == "string")
                            {
                                window._doc.resetForm(new Array(fieldNames));
                            }
                            else
                            {
                                window._doc.resetForm(fieldNames);
                            }
                        };
                        
                        /**
                         *  Submits the form to a specified URL.  Currently only supports FormsCentral submissions.
                         *
                         *  submitForm JS API currently only supports FormsCentral submissions.  And FormsCentral has now
                         *  been decommissioned.  Leave the submitForm code intact so that if it is executed, the return
                         *  response can be processed by the application.  Leave the submitForm code intact so that it can
                         *  serve as a guide for any future non-FormsCentral submit functionality.  But mark the API as
                         *  private so that any autogenerated documentation does NOT include this API.
                         *  @private
                         *  @method submitForm
                         *  @param cURL {String} The URL to submit to.  cURL must be a FormsCentral target.
                         *  @param [cSubmitAs='FDF'] {String} This parameter indicates the format for submission.
                         *  Must be 'HTML' to support FormsCentral submission.
                         *  @param [cCharset='utf-8'] {String} The encoding for the values submitted.  Must be
                         *  'utf-8' to support FormsCentral submission.
                         */
                        submitForm = function()
                        {
                        	var cURL= null;
                        	var cSubmitAs = null;
                        	var cCharset = null;
                        	
                        	if (arguments.length > 0)
                        	{
                        		if (typeof arguments[0].cURL == "string")
                        	    {
                        			cSubmitAs = 'FDF';
                        			cCharset = 'utf-8';
                        			
                        	    	cURL = arguments[0].cURL;
                        	    	
                        	    	if (typeof arguments[0].cSubmitAs == "string")
                        	    	{
                        	    		cSubmitAs = arguments[0].cSubmitAs;
                        	    	}
                        	    	
                        	    	if (typeof arguments[0].cCharset == "string")
                        	    	{
                        	    		cCharset = arguments[0].cCharset;
                        	    	}
                        	    }
                        	    else if (typeof arguments[0] == "string")
                        	    {
                        	    	cSubmitAs = 'FDF';
                        			cCharset = 'utf-8';
                        	    	
                        	    	cURL = arguments[0];
                        	    	
                        	    	if (arguments.length >= 9 && typeof arguments[8] == "boolean" && arguments[8] == true)
                        	    	{
                        	    		cSubmitAs = 'PDF';
                        	    	}
                        	    	else if (arguments.length >= 7 && typeof arguments[6] == "boolean" && arguments[6] == true)
                        	    	{
                        	    		cSubmitAs = 'XML;'
                        	    	}
                        	    	else if (arguments.length >= 2 && typeof arguments[1] == "boolean" && arguments[1] == false)
                        	    	{
                        	    		cSubmitAs = 'none';
                        	    	}
                        	    }
                        	}
                        	
                            window._doc.submitForm(cURL, cSubmitAs, cCharset);
                        };
                        
                        //register undefined properties on the 'this' object
                        registerUndefinedProperty(this, 'Doc', 'alternatePresentations');
                        registerUndefinedProperty(this, 'Doc', 'author');
                        registerUndefinedProperty(this, 'Doc', 'baseURL');
                        registerUndefinedProperty(this, 'Doc', 'bookmarkRoot');
                        registerUndefinedProperty(this, 'Doc', 'calculate');
                        registerUndefinedProperty(this, 'Doc', 'creationDate');
                        registerUndefinedProperty(this, 'Doc', 'creator');
                        registerUndefinedProperty(this, 'Doc', 'dataObjects');
                        registerUndefinedProperty(this, 'Doc', 'delay');
                        registerUndefinedProperty(this, 'Doc', 'dirty');
                        registerUndefinedProperty(this, 'Doc', 'disclosed');
                        registerUndefinedProperty(this, 'Doc', 'docID');
                        registerUndefinedProperty(this, 'Doc', 'documentFileName');
                        registerUndefinedProperty(this, 'Doc', 'dynamicXFAForm');
                        registerUndefinedProperty(this, 'Doc', 'external');
                        registerUndefinedProperty(this, 'Doc', 'filesize');
                        registerUndefinedProperty(this, 'Doc', 'hidden');
                        registerUndefinedProperty(this, 'Doc', 'hostContainer');
                        registerUndefinedProperty(this, 'Doc', 'icons');
                        registerUndefinedProperty(this, 'Doc', 'info');
                        registerUndefinedProperty(this, 'Doc', 'innerAppWindowRect');
                        registerUndefinedProperty(this, 'Doc', 'innerDocWindowRect');
                        registerUndefinedProperty(this, 'Doc', 'isModal');
                        registerUndefinedProperty(this, 'Doc', 'keywords');
                        registerUndefinedProperty(this, 'Doc', 'layout');
                        registerUndefinedProperty(this, 'Doc', 'media');
                        registerUndefinedProperty(this, 'Doc', 'metadata');
                        registerUndefinedProperty(this, 'Doc', 'modDate');
                        registerUndefinedProperty(this, 'Doc', 'mouseX');
                        registerUndefinedProperty(this, 'Doc', 'mouseY');
                        registerUndefinedProperty(this, 'Doc', 'noautocomplete');
                        registerUndefinedProperty(this, 'Doc', 'nocache');
                        registerUndefinedProperty(this, 'Doc', 'numPages');
                        registerUndefinedProperty(this, 'Doc', 'numTemplates');
                        registerUndefinedProperty(this, 'Doc', 'path');
                        registerUndefinedProperty(this, 'Doc', 'outerAppWindowRect');
                        registerUndefinedProperty(this, 'Doc', 'outerDocWindowRect');
                        registerUndefinedProperty(this, 'Doc', 'pageWindowRect');
                        registerUndefinedProperty(this, 'Doc', 'permStatusReady');
                        registerUndefinedProperty(this, 'Doc', 'producer');
                        registerUndefinedProperty(this, 'Doc', 'requiresFullSave');
                        registerUndefinedProperty(this, 'Doc', 'securityHandler');
                        registerUndefinedProperty(this, 'Doc', 'selectedAnnots');
                        registerUndefinedProperty(this, 'Doc', 'sounds');
                        registerUndefinedProperty(this, 'Doc', 'spellDictionaryOrder');
                        registerUndefinedProperty(this, 'Doc', 'spellLanguageOrder');
                        registerUndefinedProperty(this, 'Doc', 'subject');
                        registerUndefinedProperty(this, 'Doc', 'templates');
                        registerUndefinedProperty(this, 'Doc', 'title');
                        registerUndefinedProperty(this, 'Doc', 'URL');
                        registerUndefinedProperty(this, 'Doc', 'viewState');
                        registerUndefinedProperty(this, 'Doc', 'xfa');
                        registerUndefinedProperty(this, 'Doc', 'XFAForeground');
                        registerUndefinedProperty(this, 'Doc', 'zoom');
                        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.