Browse Source

PDF.js version 1.6.297 - See mozilla/pdf.js@9f8d67475ea668e3e8eaeb241733b998d64e90ca

Pdf Bot 8 years ago
parent
commit
c0467c87f3
5 changed files with 80 additions and 70 deletions
  1. 1 1
      bower.json
  2. 38 33
      build/pdf.combined.js
  3. 2 2
      build/pdf.js
  4. 38 33
      build/pdf.worker.js
  5. 1 1
      package.json

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.6.295",
+  "version": "1.6.297",
   "main": [
     "build/pdf.js",
     "build/pdf.worker.js"

+ 38 - 33
build/pdf.combined.js

@@ -24,8 +24,8 @@
 }(this, function (exports) {
   // Use strict in our context only - users might not want it
   'use strict';
-  var pdfjsVersion = '1.6.295';
-  var pdfjsBuild = '6e22b32';
+  var pdfjsVersion = '1.6.297';
+  var pdfjsBuild = '9f8d674';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {
@@ -59561,6 +59561,7 @@
           var dict = params.dict;
           var data = this.data;
           data.annotationType = AnnotationType.WIDGET;
+          data.fieldName = this._constructFieldName(dict);
           data.fieldValue = Util.getInheritableProperty(dict, 'V', /* getArray = */
           true);
           data.alternativeText = stringToPDFString(dict.get('TU') || '');
@@ -59577,39 +59578,43 @@
           if (data.fieldType === 'Sig') {
             this.setFlags(AnnotationFlag.HIDDEN);
           }
-          // Building the full field name by collecting the field and
-          // its ancestors 'T' data and joining them using '.'.
-          var fieldName = [];
-          var namedItem = dict;
-          var ref = params.ref;
-          while (namedItem) {
-            var parent = namedItem.get('Parent');
-            var parentRef = namedItem.getRaw('Parent');
-            var name = namedItem.get('T');
-            if (name) {
-              fieldName.unshift(stringToPDFString(name));
-            } else if (parent && ref) {
-              // The field name is absent, that means more than one field
-              // with the same name may exist. Replacing the empty name
-              // with the '`' plus index in the parent's 'Kids' array.
-              // This is not in the PDF spec but necessary to id the
-              // the input controls.
-              var kids = parent.get('Kids');
-              var j, jj;
-              for (j = 0, jj = kids.length; j < jj; j++) {
-                var kidRef = kids[j];
-                if (kidRef.num === ref.num && kidRef.gen === ref.gen) {
-                  break;
-                }
-              }
-              fieldName.unshift('`' + j);
-            }
-            namedItem = parent;
-            ref = parentRef;
-          }
-          data.fullName = fieldName.join('.');
         }
         Util.inherit(WidgetAnnotation, Annotation, {
+          /**
+           * Construct the (fully qualified) field name from the (partial) field
+           * names of the field and its ancestors.
+           *
+           * @private
+           * @memberof WidgetAnnotation
+           * @param {Dict} dict - Complete widget annotation dictionary
+           * @return {string}
+           */
+          _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
+            // Both the `Parent` and `T` fields are optional. While at least one of
+            // them should be provided, bad PDF generators may fail to do so.
+            if (!dict.has('T') && !dict.has('Parent')) {
+              warn('Unknown field name, falling back to empty field name.');
+              return '';
+            }
+            // If no parent exists, the partial and fully qualified names are equal.
+            if (!dict.has('Parent')) {
+              return stringToPDFString(dict.get('T'));
+            }
+            // Form the fully qualified field name by appending the partial name to
+            // the parent's fully qualified name, separated by a period.
+            var fieldName = [];
+            if (dict.has('T')) {
+              fieldName.unshift(stringToPDFString(dict.get('T')));
+            }
+            var loopDict = dict;
+            while (loopDict.has('Parent')) {
+              loopDict = loopDict.get('Parent');
+              if (loopDict.has('T')) {
+                fieldName.unshift(stringToPDFString(loopDict.get('T')));
+              }
+            }
+            return fieldName.join('.');
+          },
           /**
            * Check if a provided field flag is set.
            *

+ 2 - 2
build/pdf.js

@@ -24,8 +24,8 @@
 }(this, function (exports) {
   // Use strict in our context only - users might not want it
   'use strict';
-  var pdfjsVersion = '1.6.295';
-  var pdfjsBuild = '6e22b32';
+  var pdfjsVersion = '1.6.297';
+  var pdfjsBuild = '9f8d674';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {

+ 38 - 33
build/pdf.worker.js

@@ -24,8 +24,8 @@
 }(this, function (exports) {
   // Use strict in our context only - users might not want it
   'use strict';
-  var pdfjsVersion = '1.6.295';
-  var pdfjsBuild = '6e22b32';
+  var pdfjsVersion = '1.6.297';
+  var pdfjsBuild = '9f8d674';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {
@@ -51624,6 +51624,7 @@
           var dict = params.dict;
           var data = this.data;
           data.annotationType = AnnotationType.WIDGET;
+          data.fieldName = this._constructFieldName(dict);
           data.fieldValue = Util.getInheritableProperty(dict, 'V', /* getArray = */
           true);
           data.alternativeText = stringToPDFString(dict.get('TU') || '');
@@ -51640,39 +51641,43 @@
           if (data.fieldType === 'Sig') {
             this.setFlags(AnnotationFlag.HIDDEN);
           }
-          // Building the full field name by collecting the field and
-          // its ancestors 'T' data and joining them using '.'.
-          var fieldName = [];
-          var namedItem = dict;
-          var ref = params.ref;
-          while (namedItem) {
-            var parent = namedItem.get('Parent');
-            var parentRef = namedItem.getRaw('Parent');
-            var name = namedItem.get('T');
-            if (name) {
-              fieldName.unshift(stringToPDFString(name));
-            } else if (parent && ref) {
-              // The field name is absent, that means more than one field
-              // with the same name may exist. Replacing the empty name
-              // with the '`' plus index in the parent's 'Kids' array.
-              // This is not in the PDF spec but necessary to id the
-              // the input controls.
-              var kids = parent.get('Kids');
-              var j, jj;
-              for (j = 0, jj = kids.length; j < jj; j++) {
-                var kidRef = kids[j];
-                if (kidRef.num === ref.num && kidRef.gen === ref.gen) {
-                  break;
-                }
-              }
-              fieldName.unshift('`' + j);
-            }
-            namedItem = parent;
-            ref = parentRef;
-          }
-          data.fullName = fieldName.join('.');
         }
         Util.inherit(WidgetAnnotation, Annotation, {
+          /**
+           * Construct the (fully qualified) field name from the (partial) field
+           * names of the field and its ancestors.
+           *
+           * @private
+           * @memberof WidgetAnnotation
+           * @param {Dict} dict - Complete widget annotation dictionary
+           * @return {string}
+           */
+          _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
+            // Both the `Parent` and `T` fields are optional. While at least one of
+            // them should be provided, bad PDF generators may fail to do so.
+            if (!dict.has('T') && !dict.has('Parent')) {
+              warn('Unknown field name, falling back to empty field name.');
+              return '';
+            }
+            // If no parent exists, the partial and fully qualified names are equal.
+            if (!dict.has('Parent')) {
+              return stringToPDFString(dict.get('T'));
+            }
+            // Form the fully qualified field name by appending the partial name to
+            // the parent's fully qualified name, separated by a period.
+            var fieldName = [];
+            if (dict.has('T')) {
+              fieldName.unshift(stringToPDFString(dict.get('T')));
+            }
+            var loopDict = dict;
+            while (loopDict.has('Parent')) {
+              loopDict = loopDict.get('Parent');
+              if (loopDict.has('T')) {
+                fieldName.unshift(stringToPDFString(loopDict.get('T')));
+              }
+            }
+            return fieldName.join('.');
+          },
           /**
            * Check if a provided field flag is set.
            *

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.6.295",
+  "version": "1.6.297",
   "main": "build/pdf.js",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [