annotation.js 44 KB

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