annotation.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.MarkupAnnotation = exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = void 0;
  27. var _util = require("../shared/util");
  28. var _obj = require("./obj");
  29. var _primitives = require("./primitives");
  30. var _colorspace = require("./colorspace");
  31. var _core_utils = require("./core_utils");
  32. var _operator_list = require("./operator_list");
  33. var _stream = require("./stream");
  34. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  35. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  36. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  37. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  39. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  40. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  41. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  42. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  44. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  45. var AnnotationFactory =
  46. /*#__PURE__*/
  47. function () {
  48. function AnnotationFactory() {
  49. _classCallCheck(this, AnnotationFactory);
  50. }
  51. _createClass(AnnotationFactory, null, [{
  52. key: "create",
  53. value: function create(xref, ref, pdfManager, idFactory) {
  54. return pdfManager.ensure(this, '_create', [xref, ref, pdfManager, idFactory]);
  55. }
  56. }, {
  57. key: "_create",
  58. value: function _create(xref, ref, pdfManager, idFactory) {
  59. var dict = xref.fetchIfRef(ref);
  60. if (!(0, _primitives.isDict)(dict)) {
  61. return undefined;
  62. }
  63. var id = (0, _primitives.isRef)(ref) ? ref.toString() : "annot_".concat(idFactory.createObjId());
  64. var subtype = dict.get('Subtype');
  65. subtype = (0, _primitives.isName)(subtype) ? subtype.name : null;
  66. var parameters = {
  67. xref: xref,
  68. dict: dict,
  69. subtype: subtype,
  70. id: id,
  71. pdfManager: pdfManager
  72. };
  73. switch (subtype) {
  74. case 'Link':
  75. return new LinkAnnotation(parameters);
  76. case 'Text':
  77. return new TextAnnotation(parameters);
  78. case 'Widget':
  79. var fieldType = (0, _core_utils.getInheritableProperty)({
  80. dict: dict,
  81. key: 'FT'
  82. });
  83. fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
  84. switch (fieldType) {
  85. case 'Tx':
  86. return new TextWidgetAnnotation(parameters);
  87. case 'Btn':
  88. return new ButtonWidgetAnnotation(parameters);
  89. case 'Ch':
  90. return new ChoiceWidgetAnnotation(parameters);
  91. }
  92. (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  93. return new WidgetAnnotation(parameters);
  94. case 'Popup':
  95. return new PopupAnnotation(parameters);
  96. case 'FreeText':
  97. return new FreeTextAnnotation(parameters);
  98. case 'Line':
  99. return new LineAnnotation(parameters);
  100. case 'Square':
  101. return new SquareAnnotation(parameters);
  102. case 'Circle':
  103. return new CircleAnnotation(parameters);
  104. case 'PolyLine':
  105. return new PolylineAnnotation(parameters);
  106. case 'Polygon':
  107. return new PolygonAnnotation(parameters);
  108. case 'Caret':
  109. return new CaretAnnotation(parameters);
  110. case 'Ink':
  111. return new InkAnnotation(parameters);
  112. case 'Highlight':
  113. return new HighlightAnnotation(parameters);
  114. case 'Underline':
  115. return new UnderlineAnnotation(parameters);
  116. case 'Squiggly':
  117. return new SquigglyAnnotation(parameters);
  118. case 'StrikeOut':
  119. return new StrikeOutAnnotation(parameters);
  120. case 'Stamp':
  121. return new StampAnnotation(parameters);
  122. case 'FileAttachment':
  123. return new FileAttachmentAnnotation(parameters);
  124. default:
  125. if (!subtype) {
  126. (0, _util.warn)('Annotation is missing the required /Subtype.');
  127. } else {
  128. (0, _util.warn)('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  129. }
  130. return new Annotation(parameters);
  131. }
  132. }
  133. }]);
  134. return AnnotationFactory;
  135. }();
  136. exports.AnnotationFactory = AnnotationFactory;
  137. function getTransformMatrix(rect, bbox, matrix) {
  138. var bounds = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
  139. var minX = bounds[0];
  140. var minY = bounds[1];
  141. var maxX = bounds[2];
  142. var maxY = bounds[3];
  143. if (minX === maxX || minY === maxY) {
  144. return [1, 0, 0, 1, rect[0], rect[1]];
  145. }
  146. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  147. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  148. return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
  149. }
  150. var Annotation =
  151. /*#__PURE__*/
  152. function () {
  153. function Annotation(params) {
  154. _classCallCheck(this, Annotation);
  155. var dict = params.dict;
  156. this.setContents(dict.get('Contents'));
  157. this.setModificationDate(dict.get('M'));
  158. this.setFlags(dict.get('F'));
  159. this.setRectangle(dict.getArray('Rect'));
  160. this.setColor(dict.getArray('C'));
  161. this.setBorderStyle(dict);
  162. this.setAppearance(dict);
  163. this.data = {
  164. annotationFlags: this.flags,
  165. borderStyle: this.borderStyle,
  166. color: this.color,
  167. contents: this.contents,
  168. hasAppearance: !!this.appearance,
  169. id: params.id,
  170. modificationDate: this.modificationDate,
  171. rect: this.rectangle,
  172. subtype: params.subtype
  173. };
  174. }
  175. _createClass(Annotation, [{
  176. key: "_hasFlag",
  177. value: function _hasFlag(flags, flag) {
  178. return !!(flags & flag);
  179. }
  180. }, {
  181. key: "_isViewable",
  182. value: function _isViewable(flags) {
  183. return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
  184. }
  185. }, {
  186. key: "_isPrintable",
  187. value: function _isPrintable(flags) {
  188. return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN);
  189. }
  190. }, {
  191. key: "setContents",
  192. value: function setContents(contents) {
  193. this.contents = (0, _util.stringToPDFString)(contents || '');
  194. }
  195. }, {
  196. key: "setModificationDate",
  197. value: function setModificationDate(modificationDate) {
  198. this.modificationDate = (0, _util.isString)(modificationDate) ? modificationDate : null;
  199. }
  200. }, {
  201. key: "setFlags",
  202. value: function setFlags(flags) {
  203. this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
  204. }
  205. }, {
  206. key: "hasFlag",
  207. value: function hasFlag(flag) {
  208. return this._hasFlag(this.flags, flag);
  209. }
  210. }, {
  211. key: "setRectangle",
  212. value: function setRectangle(rectangle) {
  213. if (Array.isArray(rectangle) && rectangle.length === 4) {
  214. this.rectangle = _util.Util.normalizeRect(rectangle);
  215. } else {
  216. this.rectangle = [0, 0, 0, 0];
  217. }
  218. }
  219. }, {
  220. key: "setColor",
  221. value: function setColor(color) {
  222. var rgbColor = new Uint8ClampedArray(3);
  223. if (!Array.isArray(color)) {
  224. this.color = rgbColor;
  225. return;
  226. }
  227. switch (color.length) {
  228. case 0:
  229. this.color = null;
  230. break;
  231. case 1:
  232. _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  233. this.color = rgbColor;
  234. break;
  235. case 3:
  236. _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  237. this.color = rgbColor;
  238. break;
  239. case 4:
  240. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  241. this.color = rgbColor;
  242. break;
  243. default:
  244. this.color = rgbColor;
  245. break;
  246. }
  247. }
  248. }, {
  249. key: "setBorderStyle",
  250. value: function setBorderStyle(borderStyle) {
  251. this.borderStyle = new AnnotationBorderStyle();
  252. if (!(0, _primitives.isDict)(borderStyle)) {
  253. return;
  254. }
  255. if (borderStyle.has('BS')) {
  256. var dict = borderStyle.get('BS');
  257. var dictType = dict.get('Type');
  258. if (!dictType || (0, _primitives.isName)(dictType, 'Border')) {
  259. this.borderStyle.setWidth(dict.get('W'), this.rectangle);
  260. this.borderStyle.setStyle(dict.get('S'));
  261. this.borderStyle.setDashArray(dict.getArray('D'));
  262. }
  263. } else if (borderStyle.has('Border')) {
  264. var array = borderStyle.getArray('Border');
  265. if (Array.isArray(array) && array.length >= 3) {
  266. this.borderStyle.setHorizontalCornerRadius(array[0]);
  267. this.borderStyle.setVerticalCornerRadius(array[1]);
  268. this.borderStyle.setWidth(array[2], this.rectangle);
  269. if (array.length === 4) {
  270. this.borderStyle.setDashArray(array[3]);
  271. }
  272. }
  273. } else {
  274. this.borderStyle.setWidth(0);
  275. }
  276. }
  277. }, {
  278. key: "setAppearance",
  279. value: function setAppearance(dict) {
  280. this.appearance = null;
  281. var appearanceStates = dict.get('AP');
  282. if (!(0, _primitives.isDict)(appearanceStates)) {
  283. return;
  284. }
  285. var normalAppearanceState = appearanceStates.get('N');
  286. if ((0, _primitives.isStream)(normalAppearanceState)) {
  287. this.appearance = normalAppearanceState;
  288. return;
  289. }
  290. if (!(0, _primitives.isDict)(normalAppearanceState)) {
  291. return;
  292. }
  293. var as = dict.get('AS');
  294. if (!(0, _primitives.isName)(as) || !normalAppearanceState.has(as.name)) {
  295. return;
  296. }
  297. this.appearance = normalAppearanceState.get(as.name);
  298. }
  299. }, {
  300. key: "loadResources",
  301. value: function loadResources(keys) {
  302. return this.appearance.dict.getAsync('Resources').then(function (resources) {
  303. if (!resources) {
  304. return undefined;
  305. }
  306. var objectLoader = new _obj.ObjectLoader(resources, keys, resources.xref);
  307. return objectLoader.load().then(function () {
  308. return resources;
  309. });
  310. });
  311. }
  312. }, {
  313. key: "getOperatorList",
  314. value: function getOperatorList(evaluator, task, renderForms) {
  315. var _this = this;
  316. if (!this.appearance) {
  317. return Promise.resolve(new _operator_list.OperatorList());
  318. }
  319. var data = this.data;
  320. var appearanceDict = this.appearance.dict;
  321. var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
  322. var bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
  323. var matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0, 0];
  324. var transform = getTransformMatrix(data.rect, bbox, matrix);
  325. return resourcesPromise.then(function (resources) {
  326. var opList = new _operator_list.OperatorList();
  327. opList.addOp(_util.OPS.beginAnnotation, [data.rect, transform, matrix]);
  328. return evaluator.getOperatorList({
  329. stream: _this.appearance,
  330. task: task,
  331. resources: resources,
  332. operatorList: opList
  333. }).then(function () {
  334. opList.addOp(_util.OPS.endAnnotation, []);
  335. _this.appearance.reset();
  336. return opList;
  337. });
  338. });
  339. }
  340. }, {
  341. key: "viewable",
  342. get: function get() {
  343. if (this.flags === 0) {
  344. return true;
  345. }
  346. return this._isViewable(this.flags);
  347. }
  348. }, {
  349. key: "printable",
  350. get: function get() {
  351. if (this.flags === 0) {
  352. return false;
  353. }
  354. return this._isPrintable(this.flags);
  355. }
  356. }]);
  357. return Annotation;
  358. }();
  359. exports.Annotation = Annotation;
  360. var AnnotationBorderStyle =
  361. /*#__PURE__*/
  362. function () {
  363. function AnnotationBorderStyle() {
  364. _classCallCheck(this, AnnotationBorderStyle);
  365. this.width = 1;
  366. this.style = _util.AnnotationBorderStyleType.SOLID;
  367. this.dashArray = [3];
  368. this.horizontalCornerRadius = 0;
  369. this.verticalCornerRadius = 0;
  370. }
  371. _createClass(AnnotationBorderStyle, [{
  372. key: "setWidth",
  373. value: function setWidth(width) {
  374. var rect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0, 0];
  375. if ((0, _primitives.isName)(width)) {
  376. this.width = 0;
  377. return;
  378. }
  379. if (Number.isInteger(width)) {
  380. if (width > 0) {
  381. var maxWidth = (rect[2] - rect[0]) / 2;
  382. var maxHeight = (rect[3] - rect[1]) / 2;
  383. if (maxWidth > 0 && maxHeight > 0 && (width > maxWidth || width > maxHeight)) {
  384. (0, _util.warn)("AnnotationBorderStyle.setWidth - ignoring width: ".concat(width));
  385. width = 1;
  386. }
  387. }
  388. this.width = width;
  389. }
  390. }
  391. }, {
  392. key: "setStyle",
  393. value: function setStyle(style) {
  394. if (!(0, _primitives.isName)(style)) {
  395. return;
  396. }
  397. switch (style.name) {
  398. case 'S':
  399. this.style = _util.AnnotationBorderStyleType.SOLID;
  400. break;
  401. case 'D':
  402. this.style = _util.AnnotationBorderStyleType.DASHED;
  403. break;
  404. case 'B':
  405. this.style = _util.AnnotationBorderStyleType.BEVELED;
  406. break;
  407. case 'I':
  408. this.style = _util.AnnotationBorderStyleType.INSET;
  409. break;
  410. case 'U':
  411. this.style = _util.AnnotationBorderStyleType.UNDERLINE;
  412. break;
  413. default:
  414. break;
  415. }
  416. }
  417. }, {
  418. key: "setDashArray",
  419. value: function setDashArray(dashArray) {
  420. if (Array.isArray(dashArray) && dashArray.length > 0) {
  421. var isValid = true;
  422. var allZeros = true;
  423. for (var i = 0, len = dashArray.length; i < len; i++) {
  424. var element = dashArray[i];
  425. var validNumber = +element >= 0;
  426. if (!validNumber) {
  427. isValid = false;
  428. break;
  429. } else if (element > 0) {
  430. allZeros = false;
  431. }
  432. }
  433. if (isValid && !allZeros) {
  434. this.dashArray = dashArray;
  435. } else {
  436. this.width = 0;
  437. }
  438. } else if (dashArray) {
  439. this.width = 0;
  440. }
  441. }
  442. }, {
  443. key: "setHorizontalCornerRadius",
  444. value: function setHorizontalCornerRadius(radius) {
  445. if (Number.isInteger(radius)) {
  446. this.horizontalCornerRadius = radius;
  447. }
  448. }
  449. }, {
  450. key: "setVerticalCornerRadius",
  451. value: function setVerticalCornerRadius(radius) {
  452. if (Number.isInteger(radius)) {
  453. this.verticalCornerRadius = radius;
  454. }
  455. }
  456. }]);
  457. return AnnotationBorderStyle;
  458. }();
  459. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  460. var MarkupAnnotation =
  461. /*#__PURE__*/
  462. function (_Annotation) {
  463. _inherits(MarkupAnnotation, _Annotation);
  464. function MarkupAnnotation(parameters) {
  465. var _this2;
  466. _classCallCheck(this, MarkupAnnotation);
  467. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(MarkupAnnotation).call(this, parameters));
  468. var dict = parameters.dict;
  469. if (!dict.has('C')) {
  470. _this2.data.color = null;
  471. }
  472. _this2.setCreationDate(dict.get('CreationDate'));
  473. _this2.data.creationDate = _this2.creationDate;
  474. _this2.data.hasPopup = dict.has('Popup');
  475. _this2.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
  476. return _this2;
  477. }
  478. _createClass(MarkupAnnotation, [{
  479. key: "setCreationDate",
  480. value: function setCreationDate(creationDate) {
  481. this.creationDate = (0, _util.isString)(creationDate) ? creationDate : null;
  482. }
  483. }]);
  484. return MarkupAnnotation;
  485. }(Annotation);
  486. exports.MarkupAnnotation = MarkupAnnotation;
  487. var WidgetAnnotation =
  488. /*#__PURE__*/
  489. function (_Annotation2) {
  490. _inherits(WidgetAnnotation, _Annotation2);
  491. function WidgetAnnotation(params) {
  492. var _this3;
  493. _classCallCheck(this, WidgetAnnotation);
  494. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotation).call(this, params));
  495. var dict = params.dict;
  496. var data = _this3.data;
  497. data.annotationType = _util.AnnotationType.WIDGET;
  498. data.fieldName = _this3._constructFieldName(dict);
  499. data.fieldValue = (0, _core_utils.getInheritableProperty)({
  500. dict: dict,
  501. key: 'V',
  502. getArray: true
  503. });
  504. data.alternativeText = (0, _util.stringToPDFString)(dict.get('TU') || '');
  505. data.defaultAppearance = (0, _core_utils.getInheritableProperty)({
  506. dict: dict,
  507. key: 'DA'
  508. }) || '';
  509. var fieldType = (0, _core_utils.getInheritableProperty)({
  510. dict: dict,
  511. key: 'FT'
  512. });
  513. data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
  514. _this3.fieldResources = (0, _core_utils.getInheritableProperty)({
  515. dict: dict,
  516. key: 'DR'
  517. }) || _primitives.Dict.empty;
  518. data.fieldFlags = (0, _core_utils.getInheritableProperty)({
  519. dict: dict,
  520. key: 'Ff'
  521. });
  522. if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
  523. data.fieldFlags = 0;
  524. }
  525. data.readOnly = _this3.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
  526. if (data.fieldType === 'Sig') {
  527. data.fieldValue = null;
  528. _this3.setFlags(_util.AnnotationFlag.HIDDEN);
  529. }
  530. return _this3;
  531. }
  532. _createClass(WidgetAnnotation, [{
  533. key: "_constructFieldName",
  534. value: function _constructFieldName(dict) {
  535. if (!dict.has('T') && !dict.has('Parent')) {
  536. (0, _util.warn)('Unknown field name, falling back to empty field name.');
  537. return '';
  538. }
  539. if (!dict.has('Parent')) {
  540. return (0, _util.stringToPDFString)(dict.get('T'));
  541. }
  542. var fieldName = [];
  543. if (dict.has('T')) {
  544. fieldName.unshift((0, _util.stringToPDFString)(dict.get('T')));
  545. }
  546. var loopDict = dict;
  547. while (loopDict.has('Parent')) {
  548. loopDict = loopDict.get('Parent');
  549. if (!(0, _primitives.isDict)(loopDict)) {
  550. break;
  551. }
  552. if (loopDict.has('T')) {
  553. fieldName.unshift((0, _util.stringToPDFString)(loopDict.get('T')));
  554. }
  555. }
  556. return fieldName.join('.');
  557. }
  558. }, {
  559. key: "hasFieldFlag",
  560. value: function hasFieldFlag(flag) {
  561. return !!(this.data.fieldFlags & flag);
  562. }
  563. }, {
  564. key: "getOperatorList",
  565. value: function getOperatorList(evaluator, task, renderForms) {
  566. if (renderForms) {
  567. return Promise.resolve(new _operator_list.OperatorList());
  568. }
  569. return _get(_getPrototypeOf(WidgetAnnotation.prototype), "getOperatorList", this).call(this, evaluator, task, renderForms);
  570. }
  571. }]);
  572. return WidgetAnnotation;
  573. }(Annotation);
  574. var TextWidgetAnnotation =
  575. /*#__PURE__*/
  576. function (_WidgetAnnotation) {
  577. _inherits(TextWidgetAnnotation, _WidgetAnnotation);
  578. function TextWidgetAnnotation(params) {
  579. var _this4;
  580. _classCallCheck(this, TextWidgetAnnotation);
  581. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotation).call(this, params));
  582. var dict = params.dict;
  583. _this4.data.fieldValue = (0, _util.stringToPDFString)(_this4.data.fieldValue || '');
  584. var alignment = (0, _core_utils.getInheritableProperty)({
  585. dict: dict,
  586. key: 'Q'
  587. });
  588. if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
  589. alignment = null;
  590. }
  591. _this4.data.textAlignment = alignment;
  592. var maximumLength = (0, _core_utils.getInheritableProperty)({
  593. dict: dict,
  594. key: 'MaxLen'
  595. });
  596. if (!Number.isInteger(maximumLength) || maximumLength < 0) {
  597. maximumLength = null;
  598. }
  599. _this4.data.maxLen = maximumLength;
  600. _this4.data.multiLine = _this4.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
  601. _this4.data.comb = _this4.hasFieldFlag(_util.AnnotationFieldFlag.COMB) && !_this4.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE) && !_this4.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD) && !_this4.hasFieldFlag(_util.AnnotationFieldFlag.FILESELECT) && _this4.data.maxLen !== null;
  602. return _this4;
  603. }
  604. _createClass(TextWidgetAnnotation, [{
  605. key: "getOperatorList",
  606. value: function getOperatorList(evaluator, task, renderForms) {
  607. if (renderForms || this.appearance) {
  608. return _get(_getPrototypeOf(TextWidgetAnnotation.prototype), "getOperatorList", this).call(this, evaluator, task, renderForms);
  609. }
  610. var operatorList = new _operator_list.OperatorList();
  611. if (!this.data.defaultAppearance) {
  612. return Promise.resolve(operatorList);
  613. }
  614. var stream = new _stream.Stream((0, _util.stringToBytes)(this.data.defaultAppearance));
  615. return evaluator.getOperatorList({
  616. stream: stream,
  617. task: task,
  618. resources: this.fieldResources,
  619. operatorList: operatorList
  620. }).then(function () {
  621. return operatorList;
  622. });
  623. }
  624. }]);
  625. return TextWidgetAnnotation;
  626. }(WidgetAnnotation);
  627. var ButtonWidgetAnnotation =
  628. /*#__PURE__*/
  629. function (_WidgetAnnotation2) {
  630. _inherits(ButtonWidgetAnnotation, _WidgetAnnotation2);
  631. function ButtonWidgetAnnotation(params) {
  632. var _this5;
  633. _classCallCheck(this, ButtonWidgetAnnotation);
  634. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(ButtonWidgetAnnotation).call(this, params));
  635. _this5.data.checkBox = !_this5.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !_this5.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  636. _this5.data.radioButton = _this5.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !_this5.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  637. _this5.data.pushButton = _this5.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  638. if (_this5.data.checkBox) {
  639. _this5._processCheckBox(params);
  640. } else if (_this5.data.radioButton) {
  641. _this5._processRadioButton(params);
  642. } else if (_this5.data.pushButton) {
  643. _this5._processPushButton(params);
  644. } else {
  645. (0, _util.warn)('Invalid field flags for button widget annotation');
  646. }
  647. return _this5;
  648. }
  649. _createClass(ButtonWidgetAnnotation, [{
  650. key: "_processCheckBox",
  651. value: function _processCheckBox(params) {
  652. if ((0, _primitives.isName)(this.data.fieldValue)) {
  653. this.data.fieldValue = this.data.fieldValue.name;
  654. }
  655. var customAppearance = params.dict.get('AP');
  656. if (!(0, _primitives.isDict)(customAppearance)) {
  657. return;
  658. }
  659. var exportValueOptionsDict = customAppearance.get('D');
  660. if (!(0, _primitives.isDict)(exportValueOptionsDict)) {
  661. return;
  662. }
  663. var exportValues = exportValueOptionsDict.getKeys();
  664. var hasCorrectOptionCount = exportValues.length === 2;
  665. if (!hasCorrectOptionCount) {
  666. return;
  667. }
  668. this.data.exportValue = exportValues[0] === 'Off' ? exportValues[1] : exportValues[0];
  669. }
  670. }, {
  671. key: "_processRadioButton",
  672. value: function _processRadioButton(params) {
  673. this.data.fieldValue = this.data.buttonValue = null;
  674. var fieldParent = params.dict.get('Parent');
  675. if ((0, _primitives.isDict)(fieldParent) && fieldParent.has('V')) {
  676. var fieldParentValue = fieldParent.get('V');
  677. if ((0, _primitives.isName)(fieldParentValue)) {
  678. this.data.fieldValue = fieldParentValue.name;
  679. }
  680. }
  681. var appearanceStates = params.dict.get('AP');
  682. if (!(0, _primitives.isDict)(appearanceStates)) {
  683. return;
  684. }
  685. var normalAppearanceState = appearanceStates.get('N');
  686. if (!(0, _primitives.isDict)(normalAppearanceState)) {
  687. return;
  688. }
  689. var keys = normalAppearanceState.getKeys();
  690. for (var i = 0, ii = keys.length; i < ii; i++) {
  691. if (keys[i] !== 'Off') {
  692. this.data.buttonValue = keys[i];
  693. break;
  694. }
  695. }
  696. }
  697. }, {
  698. key: "_processPushButton",
  699. value: function _processPushButton(params) {
  700. if (!params.dict.has('A')) {
  701. (0, _util.warn)('Push buttons without action dictionaries are not supported');
  702. return;
  703. }
  704. _obj.Catalog.parseDestDictionary({
  705. destDict: params.dict,
  706. resultObj: this.data,
  707. docBaseUrl: params.pdfManager.docBaseUrl
  708. });
  709. }
  710. }]);
  711. return ButtonWidgetAnnotation;
  712. }(WidgetAnnotation);
  713. var ChoiceWidgetAnnotation =
  714. /*#__PURE__*/
  715. function (_WidgetAnnotation3) {
  716. _inherits(ChoiceWidgetAnnotation, _WidgetAnnotation3);
  717. function ChoiceWidgetAnnotation(params) {
  718. var _this6;
  719. _classCallCheck(this, ChoiceWidgetAnnotation);
  720. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotation).call(this, params));
  721. _this6.data.options = [];
  722. var options = (0, _core_utils.getInheritableProperty)({
  723. dict: params.dict,
  724. key: 'Opt'
  725. });
  726. if (Array.isArray(options)) {
  727. var xref = params.xref;
  728. for (var i = 0, ii = options.length; i < ii; i++) {
  729. var option = xref.fetchIfRef(options[i]);
  730. var isOptionArray = Array.isArray(option);
  731. _this6.data.options[i] = {
  732. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  733. displayValue: (0, _util.stringToPDFString)(isOptionArray ? xref.fetchIfRef(option[1]) : option)
  734. };
  735. }
  736. }
  737. if (!Array.isArray(_this6.data.fieldValue)) {
  738. _this6.data.fieldValue = [_this6.data.fieldValue];
  739. }
  740. _this6.data.combo = _this6.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
  741. _this6.data.multiSelect = _this6.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
  742. return _this6;
  743. }
  744. return ChoiceWidgetAnnotation;
  745. }(WidgetAnnotation);
  746. var TextAnnotation =
  747. /*#__PURE__*/
  748. function (_MarkupAnnotation) {
  749. _inherits(TextAnnotation, _MarkupAnnotation);
  750. function TextAnnotation(parameters) {
  751. var _this7;
  752. _classCallCheck(this, TextAnnotation);
  753. var DEFAULT_ICON_SIZE = 22;
  754. _this7 = _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotation).call(this, parameters));
  755. _this7.data.annotationType = _util.AnnotationType.TEXT;
  756. if (_this7.data.hasAppearance) {
  757. _this7.data.name = 'NoIcon';
  758. } else {
  759. _this7.data.rect[1] = _this7.data.rect[3] - DEFAULT_ICON_SIZE;
  760. _this7.data.rect[2] = _this7.data.rect[0] + DEFAULT_ICON_SIZE;
  761. _this7.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  762. }
  763. return _this7;
  764. }
  765. return TextAnnotation;
  766. }(MarkupAnnotation);
  767. var LinkAnnotation =
  768. /*#__PURE__*/
  769. function (_Annotation3) {
  770. _inherits(LinkAnnotation, _Annotation3);
  771. function LinkAnnotation(params) {
  772. var _this8;
  773. _classCallCheck(this, LinkAnnotation);
  774. _this8 = _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotation).call(this, params));
  775. _this8.data.annotationType = _util.AnnotationType.LINK;
  776. _obj.Catalog.parseDestDictionary({
  777. destDict: params.dict,
  778. resultObj: _this8.data,
  779. docBaseUrl: params.pdfManager.docBaseUrl
  780. });
  781. return _this8;
  782. }
  783. return LinkAnnotation;
  784. }(Annotation);
  785. var PopupAnnotation =
  786. /*#__PURE__*/
  787. function (_Annotation4) {
  788. _inherits(PopupAnnotation, _Annotation4);
  789. function PopupAnnotation(parameters) {
  790. var _this9;
  791. _classCallCheck(this, PopupAnnotation);
  792. _this9 = _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotation).call(this, parameters));
  793. _this9.data.annotationType = _util.AnnotationType.POPUP;
  794. var dict = parameters.dict;
  795. var parentItem = dict.get('Parent');
  796. if (!parentItem) {
  797. (0, _util.warn)('Popup annotation has a missing or invalid parent annotation.');
  798. return _possibleConstructorReturn(_this9);
  799. }
  800. var parentSubtype = parentItem.get('Subtype');
  801. _this9.data.parentType = (0, _primitives.isName)(parentSubtype) ? parentSubtype.name : null;
  802. _this9.data.parentId = dict.getRaw('Parent').toString();
  803. _this9.data.title = (0, _util.stringToPDFString)(parentItem.get('T') || '');
  804. _this9.data.contents = (0, _util.stringToPDFString)(parentItem.get('Contents') || '');
  805. if (!parentItem.has('M')) {
  806. _this9.data.modificationDate = null;
  807. } else {
  808. _this9.setModificationDate(parentItem.get('M'));
  809. _this9.data.modificationDate = _this9.modificationDate;
  810. }
  811. if (!parentItem.has('C')) {
  812. _this9.data.color = null;
  813. } else {
  814. _this9.setColor(parentItem.getArray('C'));
  815. _this9.data.color = _this9.color;
  816. }
  817. if (!_this9.viewable) {
  818. var parentFlags = parentItem.get('F');
  819. if (_this9._isViewable(parentFlags)) {
  820. _this9.setFlags(parentFlags);
  821. }
  822. }
  823. return _this9;
  824. }
  825. return PopupAnnotation;
  826. }(Annotation);
  827. var FreeTextAnnotation =
  828. /*#__PURE__*/
  829. function (_MarkupAnnotation2) {
  830. _inherits(FreeTextAnnotation, _MarkupAnnotation2);
  831. function FreeTextAnnotation(parameters) {
  832. var _this10;
  833. _classCallCheck(this, FreeTextAnnotation);
  834. _this10 = _possibleConstructorReturn(this, _getPrototypeOf(FreeTextAnnotation).call(this, parameters));
  835. _this10.data.annotationType = _util.AnnotationType.FREETEXT;
  836. return _this10;
  837. }
  838. return FreeTextAnnotation;
  839. }(MarkupAnnotation);
  840. var LineAnnotation =
  841. /*#__PURE__*/
  842. function (_MarkupAnnotation3) {
  843. _inherits(LineAnnotation, _MarkupAnnotation3);
  844. function LineAnnotation(parameters) {
  845. var _this11;
  846. _classCallCheck(this, LineAnnotation);
  847. _this11 = _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotation).call(this, parameters));
  848. _this11.data.annotationType = _util.AnnotationType.LINE;
  849. var dict = parameters.dict;
  850. _this11.data.lineCoordinates = _util.Util.normalizeRect(dict.getArray('L'));
  851. return _this11;
  852. }
  853. return LineAnnotation;
  854. }(MarkupAnnotation);
  855. var SquareAnnotation =
  856. /*#__PURE__*/
  857. function (_MarkupAnnotation4) {
  858. _inherits(SquareAnnotation, _MarkupAnnotation4);
  859. function SquareAnnotation(parameters) {
  860. var _this12;
  861. _classCallCheck(this, SquareAnnotation);
  862. _this12 = _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotation).call(this, parameters));
  863. _this12.data.annotationType = _util.AnnotationType.SQUARE;
  864. return _this12;
  865. }
  866. return SquareAnnotation;
  867. }(MarkupAnnotation);
  868. var CircleAnnotation =
  869. /*#__PURE__*/
  870. function (_MarkupAnnotation5) {
  871. _inherits(CircleAnnotation, _MarkupAnnotation5);
  872. function CircleAnnotation(parameters) {
  873. var _this13;
  874. _classCallCheck(this, CircleAnnotation);
  875. _this13 = _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotation).call(this, parameters));
  876. _this13.data.annotationType = _util.AnnotationType.CIRCLE;
  877. return _this13;
  878. }
  879. return CircleAnnotation;
  880. }(MarkupAnnotation);
  881. var PolylineAnnotation =
  882. /*#__PURE__*/
  883. function (_MarkupAnnotation6) {
  884. _inherits(PolylineAnnotation, _MarkupAnnotation6);
  885. function PolylineAnnotation(parameters) {
  886. var _this14;
  887. _classCallCheck(this, PolylineAnnotation);
  888. _this14 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotation).call(this, parameters));
  889. _this14.data.annotationType = _util.AnnotationType.POLYLINE;
  890. var dict = parameters.dict;
  891. var rawVertices = dict.getArray('Vertices');
  892. _this14.data.vertices = [];
  893. for (var i = 0, ii = rawVertices.length; i < ii; i += 2) {
  894. _this14.data.vertices.push({
  895. x: rawVertices[i],
  896. y: rawVertices[i + 1]
  897. });
  898. }
  899. return _this14;
  900. }
  901. return PolylineAnnotation;
  902. }(MarkupAnnotation);
  903. var PolygonAnnotation =
  904. /*#__PURE__*/
  905. function (_PolylineAnnotation) {
  906. _inherits(PolygonAnnotation, _PolylineAnnotation);
  907. function PolygonAnnotation(parameters) {
  908. var _this15;
  909. _classCallCheck(this, PolygonAnnotation);
  910. _this15 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotation).call(this, parameters));
  911. _this15.data.annotationType = _util.AnnotationType.POLYGON;
  912. return _this15;
  913. }
  914. return PolygonAnnotation;
  915. }(PolylineAnnotation);
  916. var CaretAnnotation =
  917. /*#__PURE__*/
  918. function (_MarkupAnnotation7) {
  919. _inherits(CaretAnnotation, _MarkupAnnotation7);
  920. function CaretAnnotation(parameters) {
  921. var _this16;
  922. _classCallCheck(this, CaretAnnotation);
  923. _this16 = _possibleConstructorReturn(this, _getPrototypeOf(CaretAnnotation).call(this, parameters));
  924. _this16.data.annotationType = _util.AnnotationType.CARET;
  925. return _this16;
  926. }
  927. return CaretAnnotation;
  928. }(MarkupAnnotation);
  929. var InkAnnotation =
  930. /*#__PURE__*/
  931. function (_MarkupAnnotation8) {
  932. _inherits(InkAnnotation, _MarkupAnnotation8);
  933. function InkAnnotation(parameters) {
  934. var _this17;
  935. _classCallCheck(this, InkAnnotation);
  936. _this17 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotation).call(this, parameters));
  937. _this17.data.annotationType = _util.AnnotationType.INK;
  938. var dict = parameters.dict;
  939. var xref = parameters.xref;
  940. var originalInkLists = dict.getArray('InkList');
  941. _this17.data.inkLists = [];
  942. for (var i = 0, ii = originalInkLists.length; i < ii; ++i) {
  943. _this17.data.inkLists.push([]);
  944. for (var j = 0, jj = originalInkLists[i].length; j < jj; j += 2) {
  945. _this17.data.inkLists[i].push({
  946. x: xref.fetchIfRef(originalInkLists[i][j]),
  947. y: xref.fetchIfRef(originalInkLists[i][j + 1])
  948. });
  949. }
  950. }
  951. return _this17;
  952. }
  953. return InkAnnotation;
  954. }(MarkupAnnotation);
  955. var HighlightAnnotation =
  956. /*#__PURE__*/
  957. function (_MarkupAnnotation9) {
  958. _inherits(HighlightAnnotation, _MarkupAnnotation9);
  959. function HighlightAnnotation(parameters) {
  960. var _this18;
  961. _classCallCheck(this, HighlightAnnotation);
  962. _this18 = _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotation).call(this, parameters));
  963. _this18.data.annotationType = _util.AnnotationType.HIGHLIGHT;
  964. return _this18;
  965. }
  966. return HighlightAnnotation;
  967. }(MarkupAnnotation);
  968. var UnderlineAnnotation =
  969. /*#__PURE__*/
  970. function (_MarkupAnnotation10) {
  971. _inherits(UnderlineAnnotation, _MarkupAnnotation10);
  972. function UnderlineAnnotation(parameters) {
  973. var _this19;
  974. _classCallCheck(this, UnderlineAnnotation);
  975. _this19 = _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotation).call(this, parameters));
  976. _this19.data.annotationType = _util.AnnotationType.UNDERLINE;
  977. return _this19;
  978. }
  979. return UnderlineAnnotation;
  980. }(MarkupAnnotation);
  981. var SquigglyAnnotation =
  982. /*#__PURE__*/
  983. function (_MarkupAnnotation11) {
  984. _inherits(SquigglyAnnotation, _MarkupAnnotation11);
  985. function SquigglyAnnotation(parameters) {
  986. var _this20;
  987. _classCallCheck(this, SquigglyAnnotation);
  988. _this20 = _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotation).call(this, parameters));
  989. _this20.data.annotationType = _util.AnnotationType.SQUIGGLY;
  990. return _this20;
  991. }
  992. return SquigglyAnnotation;
  993. }(MarkupAnnotation);
  994. var StrikeOutAnnotation =
  995. /*#__PURE__*/
  996. function (_MarkupAnnotation12) {
  997. _inherits(StrikeOutAnnotation, _MarkupAnnotation12);
  998. function StrikeOutAnnotation(parameters) {
  999. var _this21;
  1000. _classCallCheck(this, StrikeOutAnnotation);
  1001. _this21 = _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotation).call(this, parameters));
  1002. _this21.data.annotationType = _util.AnnotationType.STRIKEOUT;
  1003. return _this21;
  1004. }
  1005. return StrikeOutAnnotation;
  1006. }(MarkupAnnotation);
  1007. var StampAnnotation =
  1008. /*#__PURE__*/
  1009. function (_MarkupAnnotation13) {
  1010. _inherits(StampAnnotation, _MarkupAnnotation13);
  1011. function StampAnnotation(parameters) {
  1012. var _this22;
  1013. _classCallCheck(this, StampAnnotation);
  1014. _this22 = _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotation).call(this, parameters));
  1015. _this22.data.annotationType = _util.AnnotationType.STAMP;
  1016. return _this22;
  1017. }
  1018. return StampAnnotation;
  1019. }(MarkupAnnotation);
  1020. var FileAttachmentAnnotation =
  1021. /*#__PURE__*/
  1022. function (_MarkupAnnotation14) {
  1023. _inherits(FileAttachmentAnnotation, _MarkupAnnotation14);
  1024. function FileAttachmentAnnotation(parameters) {
  1025. var _this23;
  1026. _classCallCheck(this, FileAttachmentAnnotation);
  1027. _this23 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotation).call(this, parameters));
  1028. var file = new _obj.FileSpec(parameters.dict.get('FS'), parameters.xref);
  1029. _this23.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
  1030. _this23.data.file = file.serializable;
  1031. return _this23;
  1032. }
  1033. return FileAttachmentAnnotation;
  1034. }(MarkupAnnotation);