@syncfusion/ej2-pdf 1.0.23 → 23.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (518) hide show
  1. package/.eslintrc.json +260 -0
  2. package/.gitleaksignore +1 -0
  3. package/CHANGELOG.md +17 -0
  4. package/README.md +17 -0
  5. package/dist/ej2-pdf.umd.min.js +4 -14
  6. package/dist/ej2-pdf.umd.min.js.map +1 -11
  7. package/dist/es6/ej2-pdf.es2015.js +48245 -0
  8. package/dist/es6/ej2-pdf.es2015.js.map +1 -0
  9. package/dist/es6/ej2-pdf.es5.js +50124 -0
  10. package/dist/es6/ej2-pdf.es5.js.map +1 -0
  11. package/dist/global/ej2-pdf.min.js +11 -0
  12. package/dist/global/ej2-pdf.min.js.map +1 -0
  13. package/dist/global/index.d.ts +14 -0
  14. package/index.js +4 -8
  15. package/license +10 -3
  16. package/package.json +58 -16
  17. package/pdf.d.ts +4 -0
  18. package/pdf.js +4 -0
  19. package/src/global.js +1 -0
  20. package/src/index.d.ts +45 -98
  21. package/src/index.js +45 -96
  22. package/src/pdf/core/annotations/annotation-collection.d.ts +289 -0
  23. package/src/pdf/core/annotations/annotation-collection.js +744 -0
  24. package/src/pdf/core/annotations/annotation.d.ts +5845 -0
  25. package/src/pdf/core/annotations/annotation.js +14195 -0
  26. package/src/pdf/core/annotations/index.d.ts +4 -0
  27. package/src/pdf/core/annotations/index.js +4 -0
  28. package/src/pdf/core/annotations/pdf-appearance.d.ts +102 -0
  29. package/src/pdf/core/annotations/pdf-appearance.js +124 -0
  30. package/src/pdf/core/annotations/pdf-paddings.d.ts +8 -0
  31. package/src/pdf/core/annotations/pdf-paddings.js +22 -0
  32. package/src/pdf/core/base-stream.d.ts +86 -0
  33. package/src/pdf/core/base-stream.js +332 -0
  34. package/src/pdf/core/content-parser.d.ts +38 -0
  35. package/src/pdf/core/content-parser.js +359 -0
  36. package/src/pdf/core/decode-stream.d.ts +21 -0
  37. package/src/pdf/core/decode-stream.js +120 -0
  38. package/src/pdf/core/decrypt-stream.d.ts +11 -0
  39. package/src/pdf/core/decrypt-stream.js +53 -0
  40. package/src/pdf/core/enumerator.d.ts +1668 -0
  41. package/src/pdf/core/enumerator.js +1717 -0
  42. package/src/pdf/core/flate-stream.d.ts +13 -0
  43. package/src/pdf/core/flate-stream.js +329 -0
  44. package/src/pdf/core/fonts/index.d.ts +7 -0
  45. package/{dist/es6/implementation/graphics → src/pdf/core}/fonts/index.js +3 -4
  46. package/src/pdf/core/fonts/pdf-font-metrics.d.ts +66 -0
  47. package/src/pdf/core/fonts/pdf-font-metrics.js +192 -0
  48. package/src/pdf/core/fonts/pdf-standard-font.d.ts +1023 -0
  49. package/src/pdf/core/fonts/pdf-standard-font.js +1682 -0
  50. package/src/pdf/core/fonts/pdf-string-format.d.ts +236 -0
  51. package/src/pdf/core/fonts/pdf-string-format.js +213 -0
  52. package/src/pdf/core/fonts/string-layouter.d.ts +68 -0
  53. package/src/pdf/core/fonts/string-layouter.js +437 -0
  54. package/src/pdf/core/fonts/ttf-reader.d.ts +167 -0
  55. package/src/pdf/core/fonts/ttf-reader.js +1150 -0
  56. package/src/pdf/core/fonts/ttf-table.d.ts +132 -0
  57. package/src/pdf/core/fonts/ttf-table.js +74 -0
  58. package/src/pdf/core/fonts/unicode-true-type-font.d.ts +50 -0
  59. package/src/pdf/core/fonts/unicode-true-type-font.js +289 -0
  60. package/src/pdf/core/form/field.d.ts +3011 -0
  61. package/src/pdf/core/form/field.js +6828 -0
  62. package/src/pdf/core/form/form.d.ts +279 -0
  63. package/src/pdf/core/form/form.js +782 -0
  64. package/src/pdf/core/form/index.d.ts +2 -0
  65. package/src/pdf/core/form/index.js +2 -0
  66. package/src/pdf/core/graphics/images/image-decoder.d.ts +31 -0
  67. package/src/pdf/core/graphics/images/image-decoder.js +130 -0
  68. package/src/{implementation → pdf/core}/graphics/images/index.d.ts +0 -5
  69. package/{dist/es6/implementation → src/pdf/core}/graphics/images/index.js +0 -1
  70. package/src/pdf/core/graphics/images/pdf-bitmap.d.ts +73 -0
  71. package/src/pdf/core/graphics/images/pdf-bitmap.js +68 -0
  72. package/src/pdf/core/graphics/images/pdf-image.d.ts +201 -0
  73. package/src/pdf/core/graphics/images/pdf-image.js +201 -0
  74. package/src/pdf/core/graphics/index.d.ts +10 -0
  75. package/src/pdf/core/graphics/index.js +10 -0
  76. package/src/pdf/core/graphics/pdf-graphics.d.ts +956 -0
  77. package/src/pdf/core/graphics/pdf-graphics.js +1860 -0
  78. package/src/pdf/core/graphics/pdf-path.d.ts +34 -0
  79. package/src/pdf/core/graphics/pdf-path.js +177 -0
  80. package/src/pdf/core/graphics/pdf-stream-writer.d.ts +56 -0
  81. package/src/pdf/core/graphics/pdf-stream-writer.js +231 -0
  82. package/src/pdf/core/graphics/pdf-template.d.ts +79 -0
  83. package/src/pdf/core/graphics/pdf-template.js +100 -0
  84. package/src/pdf/core/graphics/rightToLeft/bidirectional.d.ts +69 -0
  85. package/src/pdf/core/graphics/rightToLeft/bidirectional.js +831 -0
  86. package/src/pdf/core/graphics/rightToLeft/index.d.ts +3 -0
  87. package/src/pdf/core/graphics/rightToLeft/index.js +3 -0
  88. package/src/pdf/core/graphics/rightToLeft/text-renderer.d.ts +13 -0
  89. package/src/pdf/core/graphics/rightToLeft/text-renderer.js +116 -0
  90. package/src/pdf/core/graphics/rightToLeft/text-shape.d.ts +48 -0
  91. package/src/pdf/core/graphics/rightToLeft/text-shape.js +289 -0
  92. package/src/pdf/core/import-export/fdf-document.d.ts +37 -0
  93. package/src/pdf/core/import-export/fdf-document.js +667 -0
  94. package/src/pdf/core/import-export/index.d.ts +5 -0
  95. package/src/pdf/core/import-export/index.js +5 -0
  96. package/src/pdf/core/import-export/json-document.d.ts +47 -0
  97. package/src/pdf/core/import-export/json-document.js +1547 -0
  98. package/src/pdf/core/import-export/xfdf-document.d.ts +146 -0
  99. package/src/pdf/core/import-export/xfdf-document.js +2920 -0
  100. package/src/pdf/core/import-export/xml-document.d.ts +14 -0
  101. package/src/pdf/core/import-export/xml-document.js +166 -0
  102. package/src/pdf/core/import-export/xml-writer.d.ts +69 -0
  103. package/src/pdf/core/import-export/xml-writer.js +494 -0
  104. package/src/pdf/core/pdf-catalog.d.ts +18 -0
  105. package/src/pdf/core/pdf-catalog.js +166 -0
  106. package/src/pdf/core/pdf-cross-reference.d.ts +80 -0
  107. package/src/pdf/core/pdf-cross-reference.js +1049 -0
  108. package/src/pdf/core/pdf-document.d.ts +821 -0
  109. package/src/pdf/core/pdf-document.js +1022 -0
  110. package/src/pdf/core/pdf-file-structure.d.ts +54 -0
  111. package/src/pdf/core/pdf-file-structure.js +65 -0
  112. package/src/pdf/core/pdf-outline.d.ts +362 -0
  113. package/src/pdf/core/pdf-outline.js +860 -0
  114. package/src/pdf/core/pdf-page.d.ts +589 -0
  115. package/src/pdf/core/pdf-page.js +1049 -0
  116. package/src/pdf/core/pdf-parser.d.ts +62 -0
  117. package/src/pdf/core/pdf-parser.js +1035 -0
  118. package/src/pdf/core/pdf-primitives.d.ts +87 -0
  119. package/src/pdf/core/pdf-primitives.js +305 -0
  120. package/src/pdf/core/predictor-stream.d.ts +15 -0
  121. package/src/pdf/core/predictor-stream.js +214 -0
  122. package/src/pdf/core/security/encryptor.d.ts +140 -0
  123. package/src/pdf/core/security/encryptor.js +1616 -0
  124. package/src/pdf/core/security/index.d.ts +1 -0
  125. package/src/pdf/core/security/index.js +1 -0
  126. package/src/pdf/core/utils.d.ts +678 -0
  127. package/src/pdf/core/utils.js +3607 -0
  128. package/src/pdf/index.d.ts +44 -0
  129. package/src/pdf/index.js +44 -0
  130. package/tslint.json +111 -0
  131. package/ReadMe.md +0 -13
  132. package/dist/es6/implementation/actions/action.js +0 -44
  133. package/dist/es6/implementation/actions/index.js +0 -2
  134. package/dist/es6/implementation/actions/uri-action.js +0 -38
  135. package/dist/es6/implementation/annotations/action-link-annotation.js +0 -29
  136. package/dist/es6/implementation/annotations/annotation-collection.js +0 -93
  137. package/dist/es6/implementation/annotations/annotation.js +0 -156
  138. package/dist/es6/implementation/annotations/document-link-annotation.js +0 -48
  139. package/dist/es6/implementation/annotations/index.js +0 -7
  140. package/dist/es6/implementation/annotations/link-annotation.js +0 -31
  141. package/dist/es6/implementation/annotations/pdf-text-web-link.js +0 -178
  142. package/dist/es6/implementation/annotations/uri-annotation.js +0 -64
  143. package/dist/es6/implementation/collections/dictionary.js +0 -71
  144. package/dist/es6/implementation/collections/index.js +0 -3
  145. package/dist/es6/implementation/collections/object-object-pair/dictionary.js +0 -84
  146. package/dist/es6/implementation/collections/object-object-pair/index.js +0 -1
  147. package/dist/es6/implementation/collections/utils.js +0 -8
  148. package/dist/es6/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -17
  149. package/dist/es6/implementation/document/automatic-fields/automatic-field-info.js +0 -68
  150. package/dist/es6/implementation/document/automatic-fields/automatic-field.js +0 -145
  151. package/dist/es6/implementation/document/automatic-fields/composite-field.js +0 -61
  152. package/dist/es6/implementation/document/automatic-fields/index.js +0 -7
  153. package/dist/es6/implementation/document/automatic-fields/multiple-value-field.js +0 -36
  154. package/dist/es6/implementation/document/automatic-fields/page-count-field.js +0 -53
  155. package/dist/es6/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -91
  156. package/dist/es6/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
  157. package/dist/es6/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -34
  158. package/dist/es6/implementation/document/automatic-fields/single-value-field.js +0 -47
  159. package/dist/es6/implementation/document/index.js +0 -11
  160. package/dist/es6/implementation/document/pdf-catalog.js +0 -38
  161. package/dist/es6/implementation/document/pdf-document-base.js +0 -71
  162. package/dist/es6/implementation/document/pdf-document-template.js +0 -204
  163. package/dist/es6/implementation/document/pdf-document.js +0 -175
  164. package/dist/es6/implementation/drawing/index.js +0 -1
  165. package/dist/es6/implementation/drawing/pdf-drawing.js +0 -80
  166. package/dist/es6/implementation/general/enum.js +0 -6
  167. package/dist/es6/implementation/general/index.js +0 -3
  168. package/dist/es6/implementation/general/pdf-cache-collection.js +0 -24
  169. package/dist/es6/implementation/general/pdf-collection.js +0 -26
  170. package/dist/es6/implementation/general/pdf-destination.js +0 -107
  171. package/dist/es6/implementation/graphics/brushes/index.js +0 -2
  172. package/dist/es6/implementation/graphics/brushes/pdf-brush.js +0 -6
  173. package/dist/es6/implementation/graphics/brushes/pdf-solid-brush.js +0 -53
  174. package/dist/es6/implementation/graphics/constants.js +0 -11
  175. package/dist/es6/implementation/graphics/enum.js +0 -100
  176. package/dist/es6/implementation/graphics/figures/base/element-layouter.js +0 -154
  177. package/dist/es6/implementation/graphics/figures/base/graphics-element.js +0 -18
  178. package/dist/es6/implementation/graphics/figures/base/index.js +0 -3
  179. package/dist/es6/implementation/graphics/figures/base/pdf-shape-element.js +0 -32
  180. package/dist/es6/implementation/graphics/figures/base/shape-layouter.js +0 -55
  181. package/dist/es6/implementation/graphics/figures/base/text-layouter.js +0 -123
  182. package/dist/es6/implementation/graphics/figures/enum.js +0 -11
  183. package/dist/es6/implementation/graphics/figures/index.js +0 -5
  184. package/dist/es6/implementation/graphics/figures/layout-element.js +0 -41
  185. package/dist/es6/implementation/graphics/figures/pdf-template.js +0 -110
  186. package/dist/es6/implementation/graphics/figures/text-element.js +0 -298
  187. package/dist/es6/implementation/graphics/fonts/enum.js +0 -45
  188. package/dist/es6/implementation/graphics/fonts/pdf-font-metrics.js +0 -122
  189. package/dist/es6/implementation/graphics/fonts/pdf-font.js +0 -159
  190. package/dist/es6/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -357
  191. package/dist/es6/implementation/graphics/fonts/pdf-standard-font.js +0 -124
  192. package/dist/es6/implementation/graphics/fonts/pdf-string-format.js +0 -239
  193. package/dist/es6/implementation/graphics/fonts/string-layouter.js +0 -335
  194. package/dist/es6/implementation/graphics/fonts/string-tokenizer.js +0 -162
  195. package/dist/es6/implementation/graphics/images/byte-array.js +0 -82
  196. package/dist/es6/implementation/graphics/images/image-decoder.js +0 -167
  197. package/dist/es6/implementation/graphics/images/pdf-bitmap.js +0 -41
  198. package/dist/es6/implementation/graphics/images/pdf-image.js +0 -68
  199. package/dist/es6/implementation/graphics/index.js +0 -20
  200. package/dist/es6/implementation/graphics/pdf-color.js +0 -205
  201. package/dist/es6/implementation/graphics/pdf-graphics.js +0 -1034
  202. package/dist/es6/implementation/graphics/pdf-margins.js +0 -75
  203. package/dist/es6/implementation/graphics/pdf-pen.js +0 -180
  204. package/dist/es6/implementation/graphics/pdf-resources.js +0 -223
  205. package/dist/es6/implementation/graphics/pdf-transformation-matrix.js +0 -134
  206. package/dist/es6/implementation/graphics/pdf-transparency.js +0 -22
  207. package/dist/es6/implementation/graphics/unit-convertor.js +0 -33
  208. package/dist/es6/implementation/index.js +0 -85
  209. package/dist/es6/implementation/input-output/cross-table.js +0 -6
  210. package/dist/es6/implementation/input-output/enum.js +0 -5
  211. package/dist/es6/implementation/input-output/index.js +0 -8
  212. package/dist/es6/implementation/input-output/pdf-cross-table.js +0 -346
  213. package/dist/es6/implementation/input-output/pdf-dictionary-properties.js +0 -60
  214. package/dist/es6/implementation/input-output/pdf-main-object-collection.js +0 -115
  215. package/dist/es6/implementation/input-output/pdf-operators.js +0 -75
  216. package/dist/es6/implementation/input-output/pdf-stream-writer.js +0 -364
  217. package/dist/es6/implementation/input-output/pdf-writer.js +0 -44
  218. package/dist/es6/implementation/pages/enum.js +0 -51
  219. package/dist/es6/implementation/pages/index.js +0 -13
  220. package/dist/es6/implementation/pages/page-added-event-arguments.js +0 -19
  221. package/dist/es6/implementation/pages/pdf-document-page-collection.js +0 -120
  222. package/dist/es6/implementation/pages/pdf-page-base.js +0 -104
  223. package/dist/es6/implementation/pages/pdf-page-layer-collection.js +0 -115
  224. package/dist/es6/implementation/pages/pdf-page-layer.js +0 -160
  225. package/dist/es6/implementation/pages/pdf-page-settings.js +0 -126
  226. package/dist/es6/implementation/pages/pdf-page-size.js +0 -36
  227. package/dist/es6/implementation/pages/pdf-page-template-element.js +0 -510
  228. package/dist/es6/implementation/pages/pdf-page.js +0 -130
  229. package/dist/es6/implementation/pages/pdf-section-collection.js +0 -95
  230. package/dist/es6/implementation/pages/pdf-section-page-collection.js +0 -30
  231. package/dist/es6/implementation/pages/pdf-section-templates.js +0 -71
  232. package/dist/es6/implementation/pages/pdf-section.js +0 -388
  233. package/dist/es6/implementation/primitives/index.js +0 -8
  234. package/dist/es6/implementation/primitives/pdf-array.js +0 -199
  235. package/dist/es6/implementation/primitives/pdf-boolean.js +0 -66
  236. package/dist/es6/implementation/primitives/pdf-dictionary.js +0 -220
  237. package/dist/es6/implementation/primitives/pdf-name.js +0 -102
  238. package/dist/es6/implementation/primitives/pdf-number.js +0 -94
  239. package/dist/es6/implementation/primitives/pdf-reference.js +0 -195
  240. package/dist/es6/implementation/primitives/pdf-stream.js +0 -149
  241. package/dist/es6/implementation/primitives/pdf-string.js +0 -143
  242. package/dist/es6/implementation/structured-elements/grid/index.js +0 -1
  243. package/dist/es6/implementation/structured-elements/grid/pdf-grid-cell.js +0 -512
  244. package/dist/es6/implementation/structured-elements/grid/pdf-grid-column.js +0 -125
  245. package/dist/es6/implementation/structured-elements/grid/pdf-grid-row.js +0 -244
  246. package/dist/es6/implementation/structured-elements/grid/pdf-grid.js +0 -989
  247. package/dist/es6/implementation/structured-elements/grid/styles/index.js +0 -2
  248. package/dist/es6/implementation/structured-elements/grid/styles/pdf-borders.js +0 -145
  249. package/dist/es6/implementation/structured-elements/grid/styles/style.js +0 -267
  250. package/dist/es6/implementation/structured-elements/index.js +0 -1
  251. package/dist/es6/implementation/structured-elements/tables/light-tables/enum.js +0 -5
  252. package/dist/es6/index.js +0 -89
  253. package/dist/es6/interfaces/i-pdf-cache.js +0 -1
  254. package/dist/es6/interfaces/i-pdf-changable.js +0 -1
  255. package/dist/es6/interfaces/i-pdf-primitives.js +0 -1
  256. package/dist/es6/interfaces/i-pdf-wrapper.js +0 -1
  257. package/dist/es6/interfaces/i-pdf-writer.js +0 -1
  258. package/dist/es6/interfaces/index.js +0 -1
  259. package/dist/global/ej2-pdf-export.js +0 -15979
  260. package/implementation.d.ts +0 -4
  261. package/implementation.js +0 -8
  262. package/interfaces.d.ts +0 -4
  263. package/interfaces.js +0 -4
  264. package/src/implementation/actions/action.d.ts +0 -50
  265. package/src/implementation/actions/action.js +0 -44
  266. package/src/implementation/actions/index.d.ts +0 -6
  267. package/src/implementation/actions/index.js +0 -9
  268. package/src/implementation/actions/uri-action.d.ts +0 -33
  269. package/src/implementation/actions/uri-action.js +0 -39
  270. package/src/implementation/annotations/action-link-annotation.d.ts +0 -30
  271. package/src/implementation/annotations/action-link-annotation.js +0 -32
  272. package/src/implementation/annotations/annotation-collection.d.ts +0 -77
  273. package/src/implementation/annotations/annotation-collection.js +0 -91
  274. package/src/implementation/annotations/annotation.d.ts +0 -152
  275. package/src/implementation/annotations/annotation.js +0 -146
  276. package/src/implementation/annotations/document-link-annotation.d.ts +0 -89
  277. package/src/implementation/annotations/document-link-annotation.js +0 -51
  278. package/src/implementation/annotations/index.d.ts +0 -11
  279. package/src/implementation/annotations/index.js +0 -14
  280. package/src/implementation/annotations/link-annotation.d.ts +0 -23
  281. package/src/implementation/annotations/link-annotation.js +0 -33
  282. package/src/implementation/annotations/pdf-text-web-link.d.ts +0 -118
  283. package/src/implementation/annotations/pdf-text-web-link.js +0 -173
  284. package/src/implementation/annotations/uri-annotation.d.ts +0 -48
  285. package/src/implementation/annotations/uri-annotation.js +0 -65
  286. package/src/implementation/collections/dictionary.d.ts +0 -76
  287. package/src/implementation/collections/dictionary.js +0 -74
  288. package/src/implementation/collections/index.d.ts +0 -7
  289. package/src/implementation/collections/index.js +0 -10
  290. package/src/implementation/collections/object-object-pair/dictionary.d.ts +0 -62
  291. package/src/implementation/collections/object-object-pair/dictionary.js +0 -88
  292. package/src/implementation/collections/object-object-pair/index.d.ts +0 -5
  293. package/src/implementation/collections/object-object-pair/index.js +0 -8
  294. package/src/implementation/collections/utils.d.ts +0 -27
  295. package/src/implementation/collections/utils.js +0 -13
  296. package/src/implementation/document/automatic-fields/automatic-field-info-collection.d.ts +0 -31
  297. package/src/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -21
  298. package/src/implementation/document/automatic-fields/automatic-field-info.d.ts +0 -67
  299. package/src/implementation/document/automatic-fields/automatic-field-info.js +0 -70
  300. package/src/implementation/document/automatic-fields/automatic-field.d.ts +0 -41
  301. package/src/implementation/document/automatic-fields/automatic-field.js +0 -143
  302. package/src/implementation/document/automatic-fields/composite-field.d.ts +0 -46
  303. package/src/implementation/document/automatic-fields/composite-field.js +0 -64
  304. package/src/implementation/document/automatic-fields/index.d.ts +0 -11
  305. package/src/implementation/document/automatic-fields/index.js +0 -14
  306. package/src/implementation/document/automatic-fields/multiple-value-field.d.ts +0 -18
  307. package/src/implementation/document/automatic-fields/multiple-value-field.js +0 -35
  308. package/src/implementation/document/automatic-fields/page-count-field.d.ts +0 -44
  309. package/src/implementation/document/automatic-fields/page-count-field.js +0 -53
  310. package/src/implementation/document/automatic-fields/pdf-numbers-convertor.d.ts +0 -53
  311. package/src/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -94
  312. package/src/implementation/document/automatic-fields/pdf-page-number-field.d.ts +0 -51
  313. package/src/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
  314. package/src/implementation/document/automatic-fields/pdf-template-value-pair.d.ts +0 -38
  315. package/src/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -38
  316. package/src/implementation/document/automatic-fields/single-value-field.d.ts +0 -15
  317. package/src/implementation/document/automatic-fields/single-value-field.js +0 -46
  318. package/src/implementation/document/index.d.ts +0 -15
  319. package/src/implementation/document/index.js +0 -18
  320. package/src/implementation/document/pdf-catalog.d.ts +0 -32
  321. package/src/implementation/document/pdf-catalog.js +0 -38
  322. package/src/implementation/document/pdf-document-base.d.ts +0 -117
  323. package/src/implementation/document/pdf-document-base.js +0 -72
  324. package/src/implementation/document/pdf-document-template.d.ts +0 -166
  325. package/src/implementation/document/pdf-document-template.js +0 -207
  326. package/src/implementation/document/pdf-document.d.ts +0 -206
  327. package/src/implementation/document/pdf-document.js +0 -166
  328. package/src/implementation/drawing/index.d.ts +0 -5
  329. package/src/implementation/drawing/index.js +0 -8
  330. package/src/implementation/drawing/pdf-drawing.d.ts +0 -93
  331. package/src/implementation/drawing/pdf-drawing.js +0 -84
  332. package/src/implementation/general/enum.d.ts +0 -21
  333. package/src/implementation/general/enum.js +0 -10
  334. package/src/implementation/general/index.d.ts +0 -7
  335. package/src/implementation/general/index.js +0 -10
  336. package/src/implementation/general/pdf-cache-collection.d.ts +0 -33
  337. package/src/implementation/general/pdf-cache-collection.js +0 -27
  338. package/src/implementation/general/pdf-collection.d.ts +0 -26
  339. package/src/implementation/general/pdf-collection.js +0 -30
  340. package/src/implementation/general/pdf-destination.d.ts +0 -103
  341. package/src/implementation/general/pdf-destination.js +0 -103
  342. package/src/implementation/graphics/brushes/index.d.ts +0 -6
  343. package/src/implementation/graphics/brushes/index.js +0 -9
  344. package/src/implementation/graphics/brushes/pdf-brush.d.ts +0 -55
  345. package/src/implementation/graphics/brushes/pdf-brush.js +0 -10
  346. package/src/implementation/graphics/brushes/pdf-solid-brush.d.ts +0 -77
  347. package/src/implementation/graphics/brushes/pdf-solid-brush.js +0 -54
  348. package/src/implementation/graphics/constants.d.ts +0 -31
  349. package/src/implementation/graphics/constants.js +0 -15
  350. package/src/implementation/graphics/enum.d.ts +0 -392
  351. package/src/implementation/graphics/enum.js +0 -104
  352. package/src/implementation/graphics/figures/base/element-layouter.d.ts +0 -160
  353. package/src/implementation/graphics/figures/base/element-layouter.js +0 -156
  354. package/src/implementation/graphics/figures/base/graphics-element.d.ts +0 -16
  355. package/src/implementation/graphics/figures/base/graphics-element.js +0 -22
  356. package/src/implementation/graphics/figures/base/index.d.ts +0 -7
  357. package/src/implementation/graphics/figures/base/index.js +0 -10
  358. package/src/implementation/graphics/figures/base/pdf-shape-element.d.ts +0 -28
  359. package/src/implementation/graphics/figures/base/pdf-shape-element.js +0 -34
  360. package/src/implementation/graphics/figures/base/shape-layouter.d.ts +0 -80
  361. package/src/implementation/graphics/figures/base/shape-layouter.js +0 -57
  362. package/src/implementation/graphics/figures/base/text-layouter.d.ts +0 -107
  363. package/src/implementation/graphics/figures/base/text-layouter.js +0 -121
  364. package/src/implementation/graphics/figures/enum.d.ts +0 -37
  365. package/src/implementation/graphics/figures/enum.js +0 -15
  366. package/src/implementation/graphics/figures/index.d.ts +0 -9
  367. package/src/implementation/graphics/figures/index.js +0 -12
  368. package/src/implementation/graphics/figures/layout-element.d.ts +0 -57
  369. package/src/implementation/graphics/figures/layout-element.js +0 -43
  370. package/src/implementation/graphics/figures/pdf-template.d.ts +0 -113
  371. package/src/implementation/graphics/figures/pdf-template.js +0 -106
  372. package/src/implementation/graphics/figures/text-element.d.ts +0 -213
  373. package/src/implementation/graphics/figures/text-element.js +0 -289
  374. package/src/implementation/graphics/fonts/enum.d.ts +0 -179
  375. package/src/implementation/graphics/fonts/enum.js +0 -49
  376. package/src/implementation/graphics/fonts/index.d.ts +0 -12
  377. package/src/implementation/graphics/fonts/index.js +0 -15
  378. package/src/implementation/graphics/fonts/pdf-font-metrics.d.ts +0 -160
  379. package/src/implementation/graphics/fonts/pdf-font-metrics.js +0 -123
  380. package/src/implementation/graphics/fonts/pdf-font.d.ts +0 -187
  381. package/src/implementation/graphics/fonts/pdf-font.js +0 -158
  382. package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.d.ts +0 -301
  383. package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -359
  384. package/src/implementation/graphics/fonts/pdf-standard-font.d.ts +0 -143
  385. package/src/implementation/graphics/fonts/pdf-standard-font.js +0 -121
  386. package/src/implementation/graphics/fonts/pdf-string-format.d.ts +0 -319
  387. package/src/implementation/graphics/fonts/pdf-string-format.js +0 -241
  388. package/src/implementation/graphics/fonts/string-layouter.d.ts +0 -255
  389. package/src/implementation/graphics/fonts/string-layouter.js +0 -336
  390. package/src/implementation/graphics/fonts/string-tokenizer.d.ts +0 -107
  391. package/src/implementation/graphics/fonts/string-tokenizer.js +0 -166
  392. package/src/implementation/graphics/images/byte-array.d.ts +0 -68
  393. package/src/implementation/graphics/images/byte-array.js +0 -86
  394. package/src/implementation/graphics/images/image-decoder.d.ts +0 -227
  395. package/src/implementation/graphics/images/image-decoder.js +0 -164
  396. package/src/implementation/graphics/images/index.js +0 -11
  397. package/src/implementation/graphics/images/pdf-bitmap.d.ts +0 -90
  398. package/src/implementation/graphics/images/pdf-bitmap.js +0 -41
  399. package/src/implementation/graphics/images/pdf-image.d.ts +0 -88
  400. package/src/implementation/graphics/images/pdf-image.js +0 -69
  401. package/src/implementation/graphics/index.d.ts +0 -24
  402. package/src/implementation/graphics/index.js +0 -27
  403. package/src/implementation/graphics/pdf-color.d.ts +0 -170
  404. package/src/implementation/graphics/pdf-color.js +0 -204
  405. package/src/implementation/graphics/pdf-graphics.d.ts +0 -1085
  406. package/src/implementation/graphics/pdf-graphics.js +0 -1017
  407. package/src/implementation/graphics/pdf-margins.d.ts +0 -82
  408. package/src/implementation/graphics/pdf-margins.js +0 -79
  409. package/src/implementation/graphics/pdf-pen.d.ts +0 -237
  410. package/src/implementation/graphics/pdf-pen.js +0 -181
  411. package/src/implementation/graphics/pdf-resources.d.ts +0 -147
  412. package/src/implementation/graphics/pdf-resources.js +0 -215
  413. package/src/implementation/graphics/pdf-transformation-matrix.d.ts +0 -143
  414. package/src/implementation/graphics/pdf-transformation-matrix.js +0 -136
  415. package/src/implementation/graphics/pdf-transparency.d.ts +0 -34
  416. package/src/implementation/graphics/pdf-transparency.js +0 -22
  417. package/src/implementation/graphics/unit-convertor.d.ts +0 -72
  418. package/src/implementation/graphics/unit-convertor.js +0 -37
  419. package/src/implementation/index.d.ts +0 -89
  420. package/src/implementation/index.js +0 -92
  421. package/src/implementation/input-output/cross-table.d.ts +0 -21
  422. package/src/implementation/input-output/cross-table.js +0 -10
  423. package/src/implementation/input-output/enum.d.ts +0 -16
  424. package/src/implementation/input-output/enum.js +0 -9
  425. package/src/implementation/input-output/index.d.ts +0 -12
  426. package/src/implementation/input-output/index.js +0 -15
  427. package/src/implementation/input-output/pdf-cross-table.d.ts +0 -249
  428. package/src/implementation/input-output/pdf-cross-table.js +0 -340
  429. package/src/implementation/input-output/pdf-dictionary-properties.d.ts +0 -283
  430. package/src/implementation/input-output/pdf-dictionary-properties.js +0 -64
  431. package/src/implementation/input-output/pdf-main-object-collection.d.ts +0 -120
  432. package/src/implementation/input-output/pdf-main-object-collection.js +0 -117
  433. package/src/implementation/input-output/pdf-operators.d.ts +0 -352
  434. package/src/implementation/input-output/pdf-operators.js +0 -79
  435. package/src/implementation/input-output/pdf-stream-writer.d.ts +0 -314
  436. package/src/implementation/input-output/pdf-stream-writer.js +0 -363
  437. package/src/implementation/input-output/pdf-writer.d.ts +0 -68
  438. package/src/implementation/input-output/pdf-writer.js +0 -48
  439. package/src/implementation/pages/enum.d.ts +0 -201
  440. package/src/implementation/pages/enum.js +0 -55
  441. package/src/implementation/pages/index.d.ts +0 -17
  442. package/src/implementation/pages/index.js +0 -20
  443. package/src/implementation/pages/page-added-event-arguments.d.ts +0 -30
  444. package/src/implementation/pages/page-added-event-arguments.js +0 -23
  445. package/src/implementation/pages/pdf-document-page-collection.d.ts +0 -92
  446. package/src/implementation/pages/pdf-document-page-collection.js +0 -121
  447. package/src/implementation/pages/pdf-page-base.d.ts +0 -121
  448. package/src/implementation/pages/pdf-page-base.js +0 -104
  449. package/src/implementation/pages/pdf-page-layer-collection.d.ts +0 -99
  450. package/src/implementation/pages/pdf-page-layer-collection.js +0 -113
  451. package/src/implementation/pages/pdf-page-layer.d.ts +0 -160
  452. package/src/implementation/pages/pdf-page-layer.js +0 -159
  453. package/src/implementation/pages/pdf-page-settings.d.ts +0 -111
  454. package/src/implementation/pages/pdf-page-settings.js +0 -126
  455. package/src/implementation/pages/pdf-page-size.d.ts +0 -159
  456. package/src/implementation/pages/pdf-page-size.js +0 -39
  457. package/src/implementation/pages/pdf-page-template-element.d.ts +0 -230
  458. package/src/implementation/pages/pdf-page-template-element.js +0 -509
  459. package/src/implementation/pages/pdf-page.d.ts +0 -153
  460. package/src/implementation/pages/pdf-page.js +0 -127
  461. package/src/implementation/pages/pdf-section-collection.d.ts +0 -109
  462. package/src/implementation/pages/pdf-section-collection.js +0 -91
  463. package/src/implementation/pages/pdf-section-page-collection.d.ts +0 -41
  464. package/src/implementation/pages/pdf-section-page-collection.js +0 -34
  465. package/src/implementation/pages/pdf-section-templates.d.ts +0 -64
  466. package/src/implementation/pages/pdf-section-templates.js +0 -74
  467. package/src/implementation/pages/pdf-section.d.ts +0 -319
  468. package/src/implementation/pages/pdf-section.js +0 -379
  469. package/src/implementation/primitives/index.d.ts +0 -12
  470. package/src/implementation/primitives/index.js +0 -15
  471. package/src/implementation/primitives/pdf-array.d.ts +0 -186
  472. package/src/implementation/primitives/pdf-array.js +0 -201
  473. package/src/implementation/primitives/pdf-boolean.d.ts +0 -84
  474. package/src/implementation/primitives/pdf-boolean.js +0 -70
  475. package/src/implementation/primitives/pdf-dictionary.d.ts +0 -311
  476. package/src/implementation/primitives/pdf-dictionary.js +0 -220
  477. package/src/implementation/primitives/pdf-name.d.ts +0 -121
  478. package/src/implementation/primitives/pdf-name.js +0 -106
  479. package/src/implementation/primitives/pdf-number.d.ts +0 -104
  480. package/src/implementation/primitives/pdf-number.js +0 -98
  481. package/src/implementation/primitives/pdf-reference.d.ts +0 -222
  482. package/src/implementation/primitives/pdf-reference.js +0 -192
  483. package/src/implementation/primitives/pdf-stream.d.ts +0 -111
  484. package/src/implementation/primitives/pdf-stream.js +0 -146
  485. package/src/implementation/primitives/pdf-string.d.ts +0 -212
  486. package/src/implementation/primitives/pdf-string.js +0 -147
  487. package/src/implementation/structured-elements/grid/index.d.ts +0 -0
  488. package/src/implementation/structured-elements/grid/index.js +0 -1
  489. package/src/implementation/structured-elements/grid/pdf-grid-cell.d.ts +0 -248
  490. package/src/implementation/structured-elements/grid/pdf-grid-cell.js +0 -504
  491. package/src/implementation/structured-elements/grid/pdf-grid-column.d.ts +0 -108
  492. package/src/implementation/structured-elements/grid/pdf-grid-column.js +0 -127
  493. package/src/implementation/structured-elements/grid/pdf-grid-row.d.ts +0 -207
  494. package/src/implementation/structured-elements/grid/pdf-grid-row.js +0 -246
  495. package/src/implementation/structured-elements/grid/pdf-grid.d.ts +0 -678
  496. package/src/implementation/structured-elements/grid/pdf-grid.js +0 -982
  497. package/src/implementation/structured-elements/grid/styles/index.d.ts +0 -5
  498. package/src/implementation/structured-elements/grid/styles/index.js +0 -9
  499. package/src/implementation/structured-elements/grid/styles/pdf-borders.d.ts +0 -126
  500. package/src/implementation/structured-elements/grid/styles/pdf-borders.js +0 -146
  501. package/src/implementation/structured-elements/grid/styles/style.d.ts +0 -250
  502. package/src/implementation/structured-elements/grid/styles/style.js +0 -269
  503. package/src/implementation/structured-elements/index.d.ts +0 -0
  504. package/src/implementation/structured-elements/index.js +0 -1
  505. package/src/implementation/structured-elements/tables/light-tables/enum.d.ts +0 -16
  506. package/src/implementation/structured-elements/tables/light-tables/enum.js +0 -9
  507. package/src/interfaces/i-pdf-cache.d.ts +0 -23
  508. package/src/interfaces/i-pdf-cache.js +0 -4
  509. package/src/interfaces/i-pdf-changable.d.ts +0 -17
  510. package/src/interfaces/i-pdf-changable.js +0 -4
  511. package/src/interfaces/i-pdf-primitives.d.ts +0 -45
  512. package/src/interfaces/i-pdf-primitives.js +0 -4
  513. package/src/interfaces/i-pdf-wrapper.d.ts +0 -13
  514. package/src/interfaces/i-pdf-wrapper.js +0 -4
  515. package/src/interfaces/i-pdf-writer.d.ts +0 -29
  516. package/src/interfaces/i-pdf-writer.js +0 -4
  517. package/src/interfaces/index.d.ts +0 -9
  518. package/src/interfaces/index.js +0 -4
@@ -0,0 +1,1547 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { _ExportHelper } from './xfdf-document';
15
+ import { _stringToAnnotationFlags, _convertToColor, _encode, _byteArrayToHexString, _stringToBytes, _annotationFlagsToString, _convertStringToBytes, _bytesToString, _hexStringToByteArray, _decode } from './../utils';
16
+ import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives';
17
+ import { _PdfBaseStream, _PdfContentStream } from './../base-stream';
18
+ import { PdfAnnotationFlag } from './../enumerator';
19
+ var _JsonDocument = /** @class */ (function (_super) {
20
+ __extends(_JsonDocument, _super);
21
+ function _JsonDocument(fileName) {
22
+ var _this = _super.call(this) || this;
23
+ if (fileName !== null && typeof fileName !== 'undefined') {
24
+ _this._fileName = fileName;
25
+ }
26
+ return _this;
27
+ }
28
+ // #region Export Annotations
29
+ _JsonDocument.prototype._exportAnnotations = function (document) {
30
+ this._document = document;
31
+ this._crossReference = document._crossReference;
32
+ this._isAnnotationExport = true;
33
+ this._exportAnnotationData(document, document.pageCount);
34
+ return this._save();
35
+ };
36
+ _JsonDocument.prototype._exportFormFields = function (document) {
37
+ this._document = document;
38
+ this._crossReference = document._crossReference;
39
+ this._isAnnotationExport = false;
40
+ var form = this._document.form;
41
+ if (form !== null && typeof form !== 'undefined') {
42
+ this._exportEmptyFields = form.exportEmptyFields;
43
+ var count = this._document.form.count;
44
+ for (var i = 0; i < count; i++) {
45
+ var field = this._document.form.fieldAt(i);
46
+ this._exportFormFieldsData(field);
47
+ }
48
+ this._writeFormFieldData();
49
+ }
50
+ return this._save();
51
+ };
52
+ _JsonDocument.prototype._save = function () {
53
+ var result = new Uint8Array(this._jsonData);
54
+ this._jsonData = [];
55
+ return result;
56
+ };
57
+ _JsonDocument.prototype._writeFormFieldData = function () {
58
+ var _this = this;
59
+ this._jsonData.push(this._openingBrace);
60
+ var index = 0;
61
+ this._table.forEach(function (value, key) {
62
+ key = _this._getValidString(key);
63
+ _this._jsonData.push(_this._doubleQuotes);
64
+ for (var i = 0; i < key.length; i++) {
65
+ _this._jsonData.push(key.charCodeAt(i));
66
+ }
67
+ if (typeof value === 'string' || (Array.isArray(value) && value.length === 1)) {
68
+ value = _this._getValidString(typeof value === 'string' ? value : value[0]);
69
+ _this._jsonData.push(_this._doubleQuotes, _this._colon, _this._doubleQuotes);
70
+ for (var i = 0; i < value.length; i++) {
71
+ _this._jsonData.push(value.charCodeAt(i));
72
+ }
73
+ _this._jsonData.push(_this._doubleQuotes);
74
+ }
75
+ else {
76
+ _this._jsonData.push(_this._doubleQuotes, _this._colon, _this._openingBracket);
77
+ for (var j = 0; j < value.length; j++) {
78
+ _this._jsonData.push(_this._doubleQuotes);
79
+ var entry = value[Number.parseInt(j.toString(), 10)];
80
+ for (var k = 0; k < entry.length; k++) {
81
+ _this._jsonData.push(entry.charCodeAt(k));
82
+ }
83
+ _this._jsonData.push(_this._doubleQuotes);
84
+ if (j < value.length - 1) {
85
+ _this._jsonData.push(_this._comma);
86
+ }
87
+ }
88
+ _this._jsonData.push(_this._closingBracket);
89
+ }
90
+ if (index < _this._table.size - 1) {
91
+ _this._jsonData.push(_this._comma);
92
+ }
93
+ index++;
94
+ });
95
+ this._jsonData.push(this._closingBrace);
96
+ };
97
+ _JsonDocument.prototype._exportAnnotationData = function (document, pageCount) {
98
+ var _this = this;
99
+ var isAnnotationAdded = false;
100
+ this._jsonData.push(this._openingBrace, this._doubleQuotes, 112, 100, 102, 65, 110, 110, 111, 116, 97, 116, 105, 111, 110, this._doubleQuotes, this._colon, this._openingBrace);
101
+ for (var i = 0; i < pageCount; i++) {
102
+ var page = document.getPage(i);
103
+ if (page && page.annotations.count > 0) {
104
+ this._jsonData.push(i !== 0 && isAnnotationAdded ? this._comma : this._space, this._doubleQuotes);
105
+ var pageNumber = _convertStringToBytes(i.toString(), []);
106
+ pageNumber.forEach(function (entry) {
107
+ _this._jsonData.push(entry);
108
+ });
109
+ this._jsonData.push(this._doubleQuotes, this._colon, this._openingBrace, this._doubleQuotes, 115, 104, 97, 112, 101, 65, 110, 110, 111, 116, 97, 116, 105, 111, 110, this._doubleQuotes, this._colon, this._openingBracket);
110
+ isAnnotationAdded = true;
111
+ }
112
+ for (var k = 0; k < page.annotations.count; k++) {
113
+ var annotation = page.annotations.at(k);
114
+ if (annotation) {
115
+ this._exportAnnotation(annotation, i);
116
+ this._jsonData = _convertStringToBytes(this._convertToJson(this._table), this._jsonData);
117
+ if (k < page.annotations.count - 1) {
118
+ this._jsonData.push(this._comma);
119
+ }
120
+ this._table.clear();
121
+ }
122
+ }
123
+ if (page && page.annotations.count > 0) {
124
+ this._jsonData.push(this._closingBracket, this._closingBrace);
125
+ }
126
+ }
127
+ this._jsonData.push(this._closingBrace, this._closingBrace);
128
+ };
129
+ _JsonDocument.prototype._exportAnnotation = function (annotation, index) {
130
+ var hasAppearance = false;
131
+ var dictionary = annotation._dictionary;
132
+ var type = this._getAnnotationType(annotation._dictionary);
133
+ this._skipBorderStyle = false;
134
+ if (type && type !== '') {
135
+ this._table.set('type', type);
136
+ this._table.set('page', index.toString());
137
+ var lineAnnotation = void 0;
138
+ var points = void 0;
139
+ switch (type) {
140
+ case 'Line':
141
+ lineAnnotation = annotation;
142
+ points = lineAnnotation.linePoints;
143
+ this._table.set('start', points[0].toString() + ',' + points[1].toString());
144
+ this._table.set('end', points[2].toString() + ',' + points[3].toString());
145
+ break;
146
+ case 'Stamp':
147
+ hasAppearance = true;
148
+ break;
149
+ case 'Square':
150
+ hasAppearance = true;
151
+ break;
152
+ }
153
+ if (dictionary && dictionary.has('BE') && dictionary.has('BS')) {
154
+ var borderEffect = dictionary.get('BE');
155
+ if (borderEffect && borderEffect.has('S')) {
156
+ this._skipBorderStyle = true;
157
+ }
158
+ }
159
+ this._writeDictionary(dictionary, index, hasAppearance);
160
+ }
161
+ };
162
+ _JsonDocument.prototype._writeDictionary = function (dictionary, pageIndex, hasAppearance) {
163
+ var _this = this;
164
+ var isBorderStyle = false;
165
+ if (dictionary.has('Type')) {
166
+ var type = dictionary.get('Type');
167
+ isBorderStyle = (type && type.name === 'Border' && this._skipBorderStyle);
168
+ }
169
+ dictionary.forEach(function (key, value) {
170
+ if (!((!hasAppearance && key === 'AP') || key === 'P' || key === 'Parent')) {
171
+ var entry = void 0; // eslint-disable-line
172
+ if (value instanceof _PdfReference) {
173
+ entry = dictionary.get(key);
174
+ }
175
+ if (entry && entry instanceof _PdfDictionary) {
176
+ switch (key) {
177
+ case 'BS':
178
+ case 'BE':
179
+ _this._writeDictionary(entry, pageIndex, false);
180
+ break;
181
+ case 'IRT':
182
+ if (entry.has('NM')) {
183
+ _this._table.set('inreplyto', _this._getValue(entry.get('NM'), true));
184
+ }
185
+ break;
186
+ }
187
+ }
188
+ else if (value instanceof _PdfDictionary) {
189
+ _this._writeDictionary(value, pageIndex, false);
190
+ }
191
+ else if ((!isBorderStyle) || (isBorderStyle && key !== 'S')) {
192
+ _this._writeAttribute(key, value, dictionary);
193
+ }
194
+ }
195
+ });
196
+ if (dictionary.has('Measure')) {
197
+ this._exportMeasureDictionary(dictionary.get('Measure'));
198
+ }
199
+ if ((this.exportAppearance || hasAppearance) && dictionary.has('AP')) {
200
+ var stream = this._getAppearanceString(dictionary.get('AP'));
201
+ if (stream && stream.length > 0) {
202
+ this._table.set('appearance', _encode(stream));
203
+ }
204
+ }
205
+ if (dictionary.has('Sound')) {
206
+ var sound = dictionary.get('Sound');
207
+ if (sound && sound.dictionary) {
208
+ var soundDictionary = sound.dictionary;
209
+ if (soundDictionary.has('B')) {
210
+ this._table.set('bits', this._getValue(soundDictionary.get('B'), true));
211
+ }
212
+ if (soundDictionary.has('C')) {
213
+ this._table.set('channels', this._getValue(soundDictionary.get('C'), true));
214
+ }
215
+ if (soundDictionary.has('E')) {
216
+ this._table.set('encoding', this._getValue(soundDictionary.get('E'), true));
217
+ }
218
+ if (soundDictionary.has('R')) {
219
+ this._table.set('rate', this._getValue(soundDictionary.get('R'), true));
220
+ }
221
+ if (soundDictionary.has('Length') && soundDictionary.get('Length') > 0) {
222
+ var data = _byteArrayToHexString(sound.getBytes());
223
+ if (data && data !== '') {
224
+ this._table.set('MODE', 'raw');
225
+ this._table.set('encoding', 'hex');
226
+ if (soundDictionary.has('Length')) {
227
+ this._table.set('length', this._getValue(soundDictionary.get('Length'), true));
228
+ }
229
+ if (soundDictionary.has('Filter')) {
230
+ this._table.set('filter', this._getValue(soundDictionary.get('Filter'), true));
231
+ }
232
+ this._table.set('data', data);
233
+ }
234
+ }
235
+ }
236
+ }
237
+ else if (dictionary.has('FS')) {
238
+ var fsDictionary = dictionary.get('FS');
239
+ if (fsDictionary) {
240
+ if (fsDictionary.has('F')) {
241
+ this._table.set('file', this._getValue(fsDictionary.get('F'), true));
242
+ }
243
+ if (fsDictionary.has('EF')) {
244
+ var efDictionary = fsDictionary.get('EF');
245
+ if (efDictionary && efDictionary.has('F')) {
246
+ var fStream = efDictionary.get('F');
247
+ if (fStream && fStream.dictionary) {
248
+ var fDictionary = fStream.dictionary;
249
+ if (fDictionary.has('Params')) {
250
+ var paramsDictionary = fDictionary.get('Params');
251
+ if (paramsDictionary) {
252
+ if (paramsDictionary.has('CreationDate')) {
253
+ var value = this._getValue(paramsDictionary.get('CreationDate'), true);
254
+ this._table.set('creation', value);
255
+ }
256
+ if (paramsDictionary.has('ModificationDate')) {
257
+ var value = this._getValue(paramsDictionary.get('ModificationDate'), true);
258
+ this._table.set('modification', value);
259
+ }
260
+ if (paramsDictionary.has('Size')) {
261
+ this._table.set('size', this._getValue(paramsDictionary.get('Size'), true));
262
+ }
263
+ if (paramsDictionary.has('CheckSum')) {
264
+ var value = this._getValue(paramsDictionary.get('CheckSum'), true);
265
+ var checksum = _stringToBytes(value);
266
+ var hexString = _byteArrayToHexString(checksum);
267
+ this._table.set('checksum', hexString);
268
+ }
269
+ }
270
+ }
271
+ var data = _byteArrayToHexString(fStream.getBytes());
272
+ if (data && data !== '') {
273
+ this._table.set('MODE', 'raw');
274
+ this._table.set('encoding', 'hex');
275
+ if (fDictionary.has('Length')) {
276
+ this._table.set('length', this._getValue(fDictionary.get('Length'), true));
277
+ }
278
+ if (fDictionary.has('Filter')) {
279
+ this._table.set('filter', this._getValue(fDictionary.get('Filter'), true));
280
+ }
281
+ this._table.set('data', data);
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+ }
288
+ };
289
+ _JsonDocument.prototype._writeColor = function (primitive, attribute, tag) {
290
+ var color = this._getColor(primitive);
291
+ if (typeof primitive === 'number' && tag) {
292
+ var c = this._getValue(primitive, true);
293
+ if (c && c !== '') {
294
+ this._table.set(tag, c);
295
+ }
296
+ }
297
+ if (color && color !== '') {
298
+ this._table.set(attribute, color);
299
+ }
300
+ };
301
+ _JsonDocument.prototype._writeAttributeString = function (attribute, primitive, isLowerCase) {
302
+ if (isLowerCase === void 0) { isLowerCase = false; }
303
+ var value = this._getValue(primitive, true);
304
+ this._table.set(attribute, isLowerCase ? value.toLowerCase() : value);
305
+ };
306
+ _JsonDocument.prototype._writeAttribute = function (key, primitive, dictionary) {
307
+ var value;
308
+ switch (key) {
309
+ case 'C':
310
+ this._writeColor(primitive, 'color', 'c');
311
+ break;
312
+ case 'IC':
313
+ this._writeColor(primitive, 'interior-color');
314
+ break;
315
+ case 'DA':
316
+ value = dictionary.get('DA');
317
+ if (value) {
318
+ this._table.set('defaultappearance', value);
319
+ }
320
+ break;
321
+ case 'M':
322
+ this._writeAttributeString('date', primitive);
323
+ break;
324
+ case 'NM':
325
+ this._table.set('name', primitive);
326
+ break;
327
+ case 'Name':
328
+ this._writeAttributeString('icon', primitive);
329
+ break;
330
+ case 'Subj':
331
+ this._writeAttributeString('subject', primitive);
332
+ break;
333
+ case 'T':
334
+ this._writeAttributeString('title', primitive);
335
+ break;
336
+ case 'Rect':
337
+ value = this._getValue(primitive, true);
338
+ if (value) {
339
+ var rectArray = value.split(',');
340
+ var subTable = new Map();
341
+ subTable.set('x', rectArray[0]);
342
+ subTable.set('y', rectArray[1]);
343
+ subTable.set('width', rectArray[2]);
344
+ subTable.set('height', rectArray[3]);
345
+ this._table.set(key.toLowerCase(), this._convertToJson(subTable));
346
+ }
347
+ break;
348
+ case 'CreationDate':
349
+ this._writeAttributeString('creationdate', primitive);
350
+ break;
351
+ case 'Rotate':
352
+ this._writeAttributeString('rotation', primitive);
353
+ break;
354
+ case 'W':
355
+ this._writeAttributeString('width', primitive);
356
+ break;
357
+ case 'LE':
358
+ if (primitive && Array.isArray(primitive)) {
359
+ if (primitive.length === 2) {
360
+ this._table.set('head', this._getValue(primitive[0], true));
361
+ this._table.set('tail', this._getValue(primitive[1], true));
362
+ }
363
+ }
364
+ else if (primitive instanceof _PdfName) {
365
+ this._writeAttributeString('head', primitive);
366
+ }
367
+ break;
368
+ case 'S':
369
+ switch (this._getValue(primitive, true)) {
370
+ case 'D':
371
+ this._table.set('style', 'dash');
372
+ break;
373
+ case 'C':
374
+ this._table.set('style', 'cloudy');
375
+ break;
376
+ case 'S':
377
+ this._table.set('style', 'solid');
378
+ break;
379
+ case 'B':
380
+ this._table.set('style', 'bevelled');
381
+ break;
382
+ case 'I':
383
+ this._table.set('style', 'inset');
384
+ break;
385
+ case 'U':
386
+ this._table.set('style', 'underline');
387
+ break;
388
+ }
389
+ break;
390
+ case 'D':
391
+ this._writeAttributeString('dashes', primitive);
392
+ break;
393
+ case 'I':
394
+ this._writeAttributeString('intensity', primitive);
395
+ break;
396
+ case 'RD':
397
+ this._writeAttributeString('fringe', primitive);
398
+ break;
399
+ case 'IT':
400
+ this._writeAttributeString('IT', primitive);
401
+ break;
402
+ case 'RT':
403
+ this._writeAttributeString('replyType', primitive, true);
404
+ break;
405
+ case 'LL':
406
+ this._writeAttributeString('leaderLength', primitive);
407
+ break;
408
+ case 'LLE':
409
+ this._writeAttributeString('leaderExtend', primitive);
410
+ break;
411
+ case 'Cap':
412
+ this._writeAttributeString('caption', primitive);
413
+ break;
414
+ case 'CP':
415
+ this._writeAttributeString('caption-style', primitive);
416
+ break;
417
+ case 'CL':
418
+ this._writeAttributeString('callout', primitive);
419
+ break;
420
+ case 'QuadPoints':
421
+ this._writeAttributeString('coords', primitive);
422
+ break;
423
+ case 'CA':
424
+ this._writeAttributeString('opacity', primitive);
425
+ break;
426
+ case 'F':
427
+ if (typeof primitive === 'number') {
428
+ var flag = _annotationFlagsToString(primitive);
429
+ this._table.set('flags', flag);
430
+ }
431
+ break;
432
+ case 'Contents':
433
+ value = dictionary.get('Contents');
434
+ if (value && value.length > 0) {
435
+ this._table.set('contents', this._getValidString(value));
436
+ }
437
+ break;
438
+ case 'InkList':
439
+ this._writeInkList(dictionary);
440
+ break;
441
+ case 'Vertices':
442
+ this._writeVertices(dictionary);
443
+ break;
444
+ case 'DS':
445
+ value = dictionary.get('DS');
446
+ if (value) {
447
+ var styleTable = new Map();
448
+ var textStyle = value.split(';');
449
+ for (var i = 0; i < textStyle.length; i++) {
450
+ var text = textStyle[Number.parseInt(i.toString(), 10)].split(':');
451
+ if (text && text.length > 0 && text[0] && text[0].length > 1 && text[0].startsWith(' ')) {
452
+ text[0] = text[0].substring(1);
453
+ }
454
+ styleTable.set(text[0], text[1]);
455
+ }
456
+ this._table.set('defaultStyle', this._convertToJson(styleTable));
457
+ }
458
+ break;
459
+ case 'AllowedInteractions':
460
+ if (primitive.indexOf('"') !== -1) {
461
+ primitive = primitive.replace(/"/g, '\\"');
462
+ }
463
+ this._table.set(key, primitive);
464
+ break;
465
+ case 'Type':
466
+ case 'Subtype':
467
+ case 'P':
468
+ case 'Parent':
469
+ case 'L':
470
+ case 'RC':
471
+ case 'FS':
472
+ case 'MeasurementTypes':
473
+ case 'GroupNesting':
474
+ case 'ITEx':
475
+ break;
476
+ case 'Border':
477
+ case 'A':
478
+ case 'R':
479
+ case 'X':
480
+ case 'ca':
481
+ this._writeAttributeString(key.toLowerCase(), primitive);
482
+ break;
483
+ default:
484
+ this._writeAttributeString(key, primitive);
485
+ break;
486
+ }
487
+ };
488
+ _JsonDocument.prototype._writeVertices = function (dictionary) {
489
+ var vertices = dictionary.getArray('Vertices');
490
+ if (vertices && vertices.length > 0) {
491
+ var elementCount = vertices.length;
492
+ if (elementCount % 2 === 0) {
493
+ var vertice = '';
494
+ for (var i = 0; i < elementCount - 1; i++) {
495
+ vertice += this._getValue(vertices[Number.parseInt(i.toString(), 10)], true) + (i % 2 !== 0 ? ';' : ',');
496
+ }
497
+ vertice += this._getValue(vertices[elementCount - 1], true);
498
+ if (vertice && vertice !== '') {
499
+ this._table.set('vertices', vertice);
500
+ }
501
+ }
502
+ }
503
+ };
504
+ _JsonDocument.prototype._writeInkList = function (dictionary) {
505
+ var inkList = dictionary.getArray('InkList');
506
+ if (inkList && inkList.length > 0) {
507
+ var points = new Map();
508
+ var json = '[';
509
+ for (var j = 0; j < inkList.length; j++) {
510
+ json += '[' + this._getValue(inkList[Number.parseInt(j.toString(), 10)], true) + ']';
511
+ if (j < inkList.length - 1) {
512
+ json += ',';
513
+ }
514
+ }
515
+ json += ']';
516
+ points.set('gesture', json);
517
+ this._table.set('inklist', this._convertToJson(points));
518
+ }
519
+ };
520
+ _JsonDocument.prototype._exportMeasureDictionary = function (dictionary) {
521
+ if (dictionary) {
522
+ if (dictionary.has('Type')) {
523
+ this._table.set('type1', 'Measure');
524
+ }
525
+ if (dictionary.has('R')) {
526
+ this._table.set('ratevalue', this._getValue(dictionary.get('R'), true));
527
+ }
528
+ if (dictionary.has('SubType')) {
529
+ this._table.set('SubType', this._getValue(dictionary.get('SubType'), true));
530
+ }
531
+ if (dictionary.has('TargetUnitConversion')) {
532
+ this._table.set('TargetUnitConversion', this._getValue(dictionary.get('TargetUnitConversion'), true));
533
+ }
534
+ if (dictionary.has('A')) {
535
+ var array = dictionary.getArray('A');
536
+ this._exportMeasureFormatDetails('area', array[0]);
537
+ }
538
+ if (dictionary.has('D')) {
539
+ var array = dictionary.getArray('D');
540
+ this._exportMeasureFormatDetails('distance', array[0]);
541
+ }
542
+ if (dictionary.has('X')) {
543
+ var array = dictionary.getArray('X');
544
+ this._exportMeasureFormatDetails('xformat', array[0]);
545
+ }
546
+ if (dictionary.has('T')) {
547
+ var array = dictionary.getArray('T');
548
+ this._exportMeasureFormatDetails('tformat', array[0]);
549
+ }
550
+ if (dictionary.has('V')) {
551
+ var array = dictionary.getArray('V');
552
+ this._exportMeasureFormatDetails('vformat', array[0]);
553
+ }
554
+ }
555
+ };
556
+ _JsonDocument.prototype._exportMeasureFormatDetails = function (key, measurementDetails) {
557
+ var details = new Map();
558
+ if (measurementDetails.has('C')) {
559
+ details.set('c', this._getValue(measurementDetails.get('C'), true));
560
+ }
561
+ if (measurementDetails.has('F')) {
562
+ details.set('f', this._getValue(measurementDetails.get('F'), true));
563
+ }
564
+ if (measurementDetails.has('D')) {
565
+ details.set('d', this._getValue(measurementDetails.get('D'), true));
566
+ }
567
+ if (measurementDetails.has('RD')) {
568
+ details.set('rd', this._getValue(measurementDetails.get('RD'), true));
569
+ }
570
+ if (measurementDetails.has('U')) {
571
+ details.set('u', this._getValue(measurementDetails.get('U'), true));
572
+ }
573
+ if (measurementDetails.has('RT')) {
574
+ details.set('rt', this._getValue(measurementDetails.get('RT'), true));
575
+ }
576
+ if (measurementDetails.has('SS')) {
577
+ details.set('ss', this._getValue(measurementDetails.get('SS'), true));
578
+ }
579
+ if (measurementDetails.has('FD')) {
580
+ details.set('fd', this._getValue(measurementDetails.get('FD'), true));
581
+ }
582
+ this._table.set(key, this._convertToJson(details));
583
+ };
584
+ _JsonDocument.prototype._getAppearanceString = function (appearance) {
585
+ var parentTable = new Map();
586
+ var appearanceTable = new Map();
587
+ this._writeAppearanceDictionary(appearanceTable, appearance);
588
+ parentTable.set('ap', this._convertToJson(appearanceTable));
589
+ return _stringToBytes(this._convertToJson(parentTable));
590
+ };
591
+ _JsonDocument.prototype._writeAppearanceDictionary = function (table, dictionary) {
592
+ var _this = this;
593
+ if (dictionary && dictionary.size > 0) {
594
+ dictionary.forEach(function (key, value) {
595
+ _this._writeObject(table, ((value instanceof _PdfReference) ? dictionary.get(key) : value), dictionary, key);
596
+ });
597
+ }
598
+ };
599
+ _JsonDocument.prototype._writeObject = function (table, value, dictionary, key, array) {
600
+ if (value instanceof _PdfName) {
601
+ this._writeTable('name', value.name, table, key, array);
602
+ }
603
+ else if (Array.isArray(value)) {
604
+ var array_1 = [];
605
+ this._writeArray(array_1, value, dictionary);
606
+ this._writeTable('array', this._convertToJsonArray(array_1), table, key, array_1);
607
+ }
608
+ else if (typeof value === 'string') {
609
+ this._writeTable('string', value, table, key, array);
610
+ }
611
+ else if (typeof value === 'number') {
612
+ this._writeTable(Number.isInteger(value) ? 'int' : 'fixed', value.toString(), table, key, array);
613
+ }
614
+ else if (typeof value === 'boolean') {
615
+ this._writeTable('boolean', value ? 'true' : 'false', table, key, array);
616
+ }
617
+ else if (value instanceof _PdfDictionary) {
618
+ var subTable = new Map();
619
+ this._writeAppearanceDictionary(subTable, value);
620
+ this._writeTable('dict', this._convertToJson(subTable), table, key, array);
621
+ }
622
+ else if (value instanceof _PdfBaseStream && value.dictionary) {
623
+ var dataTable = new Map(); // eslint-disable-line
624
+ var streamTable = new Map(); // eslint-disable-line
625
+ var streamDictionary = value.dictionary;
626
+ this._writeAppearanceDictionary(streamTable, streamDictionary);
627
+ var length_1 = streamDictionary.get('Length');
628
+ var type = void 0;
629
+ if (streamDictionary.has('Subtype')) {
630
+ type = this._getValue(streamDictionary.get('Subtype'));
631
+ }
632
+ if (length_1 > 0) {
633
+ if ((!streamDictionary.has('Type') && !streamDictionary.has('Subtype')) ||
634
+ (streamDictionary.has('Subtype') &&
635
+ (type === 'Image' || type === 'Form' || type === 'CIDFontType0C' || type === 'OpenType'))) {
636
+ dataTable.set('mode', 'raw');
637
+ dataTable.set('encoding', 'hex');
638
+ }
639
+ else {
640
+ dataTable.set('mode', 'filtered');
641
+ dataTable.set('encoding', 'ascii');
642
+ }
643
+ var data = value.getString(true);
644
+ if (data && data !== '') {
645
+ dataTable.set('bytes', data);
646
+ }
647
+ }
648
+ streamTable.set('data', this._convertToJson(dataTable));
649
+ this._writeTable('stream', this._convertToJson(streamTable), table, key, array);
650
+ }
651
+ else if (value instanceof _PdfReference && this._crossReference) {
652
+ this._writeObject(table, this._crossReference._fetch(value), dictionary, key);
653
+ }
654
+ else if (value === null || typeof value === 'undefined') {
655
+ this._writeTable('null', 'null', table, key, array);
656
+ }
657
+ };
658
+ _JsonDocument.prototype._writeTable = function (tableKey, value, table, key, array) {
659
+ var map = new Map();
660
+ map.set(tableKey, value);
661
+ if (key) {
662
+ table.set(key, this._convertToJson(map));
663
+ }
664
+ else if (array) {
665
+ array.push(map);
666
+ }
667
+ };
668
+ _JsonDocument.prototype._writeArray = function (array, value, dictionary) {
669
+ for (var i = 0; i < value.length; i++) {
670
+ this._writeObject(null, value[Number.parseInt(i.toString(), 10)], dictionary, null, array);
671
+ }
672
+ };
673
+ _JsonDocument.prototype._convertToJson = function (table) {
674
+ var j = 0;
675
+ var json = '{';
676
+ table.forEach(function (value, key) {
677
+ if (value.startsWith('{') || value.startsWith('[')) {
678
+ if (key === 'AllowedInteractions') {
679
+ json += '"' + key + '":"' + value + '"';
680
+ }
681
+ else {
682
+ json += '"' + key + '":' + value;
683
+ }
684
+ }
685
+ else {
686
+ if (value.startsWith(' ') && value.length > 1 && (value[1] === '[' || value[1] === '{')) {
687
+ value = value.substring(1);
688
+ }
689
+ json += '"' + key + '":"' + value + '"';
690
+ }
691
+ if (j < table.size - 1) {
692
+ json += ',';
693
+ }
694
+ j++;
695
+ });
696
+ return json + '}';
697
+ };
698
+ _JsonDocument.prototype._convertToJsonArray = function (array) {
699
+ var json = '[';
700
+ for (var i = 0; i < array.length; i++) {
701
+ json += this._convertToJson(array[Number.parseInt(i.toString(), 10)]);
702
+ if (i < array.length - 1) {
703
+ json += ',';
704
+ }
705
+ }
706
+ return json + ']';
707
+ };
708
+ // #import
709
+ _JsonDocument.prototype._parseJson = function (document, data) {
710
+ this._document = document;
711
+ this._crossReference = document._crossReference;
712
+ var stringData = _bytesToString(data);
713
+ if (stringData.startsWith('{') && !stringData.endsWith('}')) {
714
+ while (stringData.length > 0 && !stringData.endsWith('}')) {
715
+ stringData = stringData.substring(0, stringData.length - 1);
716
+ }
717
+ }
718
+ return JSON.parse(stringData);
719
+ };
720
+ _JsonDocument.prototype._importFormData = function (document, data) {
721
+ var _this = this;
722
+ var json = this._parseJson(document, data); // eslint-disable-line
723
+ if (json) {
724
+ var keys = Object.keys(json);
725
+ if (keys && keys.length > 0) {
726
+ var _loop_1 = function (i) {
727
+ var key = keys[Number.parseInt(i.toString(), 10)];
728
+ var value = json[key]; // eslint-disable-line
729
+ if (Array.isArray(value)) {
730
+ if (this_1._fields.has('key')) {
731
+ value.forEach(function (entry) {
732
+ _this._fields.get(key).push(entry);
733
+ });
734
+ }
735
+ else {
736
+ this_1._fields.set(key, value);
737
+ }
738
+ }
739
+ else {
740
+ if (this_1._fields.has('key')) {
741
+ this_1._fields.get(key).push(value);
742
+ }
743
+ else {
744
+ this_1._fields.set(key, [value]);
745
+ }
746
+ }
747
+ };
748
+ var this_1 = this;
749
+ for (var i = 0; i < keys.length; i++) {
750
+ _loop_1(i);
751
+ }
752
+ this._importField();
753
+ }
754
+ }
755
+ };
756
+ _JsonDocument.prototype._importAnnotations = function (document, data) {
757
+ var _this = this;
758
+ var json = this._parseJson(document, data); // eslint-disable-line
759
+ if (json) {
760
+ var keys = Object.keys(json);
761
+ if (keys.indexOf('pdfAnnotation') !== -1) {
762
+ var pageAnnotations_1 = json.pdfAnnotation; // eslint-disable-line
763
+ var pageCount_1 = document.pageCount;
764
+ var pageKeys = Object.keys(pageAnnotations_1);
765
+ if (pageKeys && pageKeys.length > 0) {
766
+ pageKeys.forEach(function (key) {
767
+ var pageIndex = Number.parseInt(key, 10);
768
+ if (typeof pageIndex !== 'undefined' && pageIndex < pageCount_1) {
769
+ var page_1 = document.getPage(pageIndex);
770
+ var pageAnnotation = pageAnnotations_1[key]; // eslint-disable-line
771
+ if (pageAnnotation) {
772
+ var pageAnnotationKeys = Object.keys(pageAnnotation);
773
+ if (pageAnnotationKeys && pageAnnotationKeys.length > 0 && pageAnnotationKeys.indexOf('shapeAnnotation') !== -1) {
774
+ var annotations = pageAnnotation['shapeAnnotation']; // eslint-disable-line
775
+ if (annotations && annotations.length > 0) {
776
+ annotations.forEach(function (annotation) {
777
+ var annotationKeys = Object.keys(annotation);
778
+ if (annotationKeys && annotationKeys.length > 0 && annotationKeys.indexOf('type') !== -1) {
779
+ var dictionary = new _PdfDictionary(_this._crossReference);
780
+ dictionary.update('Type', _PdfName.get('Annot'));
781
+ var isValidType = true;
782
+ switch (annotation['type'].toLowerCase()) {
783
+ case 'line':
784
+ dictionary.update('Subtype', _PdfName.get('Line'));
785
+ break;
786
+ case 'circle':
787
+ dictionary.update('Subtype', _PdfName.get('Circle'));
788
+ break;
789
+ case 'square':
790
+ dictionary.update('Subtype', _PdfName.get('Square'));
791
+ break;
792
+ case 'polyline':
793
+ dictionary.update('Subtype', _PdfName.get('PolyLine'));
794
+ break;
795
+ case 'polygon':
796
+ dictionary.update('Subtype', _PdfName.get('Polygon'));
797
+ break;
798
+ case 'ink':
799
+ dictionary.update('Subtype', _PdfName.get('Ink'));
800
+ break;
801
+ case 'popup':
802
+ dictionary.update('Subtype', _PdfName.get('Popup'));
803
+ break;
804
+ case 'text':
805
+ dictionary.update('Subtype', _PdfName.get('Text'));
806
+ break;
807
+ case 'freetext':
808
+ dictionary.update('Subtype', _PdfName.get('FreeText'));
809
+ break;
810
+ case 'stamp':
811
+ dictionary.update('Subtype', _PdfName.get('Stamp'));
812
+ break;
813
+ case 'highlight':
814
+ dictionary.update('Subtype', _PdfName.get('Highlight'));
815
+ break;
816
+ case 'squiggly':
817
+ dictionary.update('Subtype', _PdfName.get('Squiggly'));
818
+ break;
819
+ case 'underline':
820
+ dictionary.update('Subtype', _PdfName.get('Underline'));
821
+ break;
822
+ case 'strikeout':
823
+ dictionary.update('Subtype', _PdfName.get('StrikeOut'));
824
+ break;
825
+ case 'fileattachment':
826
+ dictionary.update('Subtype', _PdfName.get('FileAttachment'));
827
+ break;
828
+ case 'sound':
829
+ dictionary.update('Subtype', _PdfName.get('Sound'));
830
+ break;
831
+ case 'redact':
832
+ dictionary.update('Subtype', _PdfName.get('Redact'));
833
+ break;
834
+ case 'caret':
835
+ dictionary.update('Subtype', _PdfName.get('Caret'));
836
+ break;
837
+ default:
838
+ isValidType = false;
839
+ break;
840
+ }
841
+ if (isValidType) {
842
+ _this._addAnnotationData(dictionary, annotation, annotationKeys);
843
+ var pageDictionary = page_1._pageDictionary;
844
+ if (pageDictionary) {
845
+ var annotations_1 = page_1.annotations;
846
+ var annotation_1 = annotations_1._parseAnnotation(dictionary);
847
+ if (annotation_1) {
848
+ annotation_1._isImported = true;
849
+ var reference = _this._crossReference._getNextReference();
850
+ _this._crossReference._cacheMap.set(reference, dictionary);
851
+ if (dictionary.has('NM') || dictionary.has('IRT')) {
852
+ _this._addReferenceToGroup(reference, dictionary);
853
+ }
854
+ annotation_1._ref = reference;
855
+ var index = annotations_1._annotations.length;
856
+ annotations_1._annotations.push(reference);
857
+ pageDictionary.set('Annots', annotations_1._annotations);
858
+ pageDictionary._updated = true;
859
+ annotations_1._parsedAnnotations.set(index, annotation_1);
860
+ _this._handlePopup(annotations_1, reference, dictionary, pageDictionary);
861
+ }
862
+ }
863
+ }
864
+ }
865
+ });
866
+ }
867
+ }
868
+ }
869
+ }
870
+ });
871
+ }
872
+ if (this._groupHolders.length > 0) {
873
+ for (var i = 0; i < this._groupHolders.length; i++) {
874
+ var dictionary = this._groupHolders[Number.parseInt(i.toString(), 10)];
875
+ var inReplyTo = dictionary.get('IRT');
876
+ if (inReplyTo && inReplyTo !== '') {
877
+ if (this._groupReferences.has(inReplyTo)) {
878
+ dictionary.update('IRT', this._groupReferences.get(inReplyTo));
879
+ }
880
+ else {
881
+ delete dictionary._map.IRT;
882
+ }
883
+ }
884
+ }
885
+ }
886
+ this._groupHolders = [];
887
+ this._groupReferences = new Map();
888
+ }
889
+ }
890
+ };
891
+ _JsonDocument.prototype._addAnnotationData = function (dictionary, annotation, annotationKeys) {
892
+ var _this = this;
893
+ var borderEffectDictionary = new _PdfDictionary(this._crossReference);
894
+ var borderStyleDictionary = new _PdfDictionary(this._crossReference);
895
+ var dataStream = new Map();
896
+ var linePoints = [];
897
+ var beginLineStyle;
898
+ var endLineStyle;
899
+ var values = '';
900
+ var rect;
901
+ var outColor;
902
+ annotationKeys.forEach(function (key) {
903
+ var value = annotation[key]; // eslint-disable-line
904
+ switch (key.toLowerCase()) {
905
+ case 'start':
906
+ case 'end':
907
+ _this._addLinePoints(value, linePoints);
908
+ if (linePoints.length === 4) {
909
+ dictionary.update('L', linePoints);
910
+ linePoints = [];
911
+ }
912
+ break;
913
+ case 'itex':
914
+ break;
915
+ case 'state':
916
+ _this._addString(dictionary, 'State', value);
917
+ break;
918
+ case 'statemodel':
919
+ _this._addString(dictionary, 'StateModel', value);
920
+ break;
921
+ case 'replytype':
922
+ if (value.toLowerCase() === 'group') {
923
+ dictionary.update('RT', _PdfName.get('Group'));
924
+ }
925
+ break;
926
+ case 'inreplyto':
927
+ _this._addString(dictionary, 'IRT', value);
928
+ break;
929
+ case 'dashes':
930
+ case 'width':
931
+ case 'intensity':
932
+ case 'style':
933
+ _this._addBorderStyle(key, value, borderEffectDictionary, borderStyleDictionary);
934
+ break;
935
+ case 'rect':
936
+ rect = value;
937
+ if (rect) {
938
+ var points = [];
939
+ points.push(Number.parseFloat(rect.x));
940
+ points.push(Number.parseFloat(rect.y));
941
+ points.push(Number.parseFloat(rect.width));
942
+ points.push(Number.parseFloat(rect.height));
943
+ if (points && points.length === 4) {
944
+ dictionary.update('Rect', points);
945
+ }
946
+ }
947
+ break;
948
+ case 'color':
949
+ value = _convertToColor(value);
950
+ if (value && value.length === 3) {
951
+ dictionary.update('C', [value[0] / 255, value[1] / 255, value[2] / 255]);
952
+ }
953
+ break;
954
+ case 'oc':
955
+ if (value && dictionary.get('Subtype').name === 'Redact') {
956
+ outColor = value.split(',');
957
+ var color_1 = [];
958
+ outColor.forEach(function (entry) {
959
+ color_1.push(Number.parseFloat(entry));
960
+ });
961
+ if (color_1 && color_1.length > 0) {
962
+ dictionary.update('OC', color_1);
963
+ }
964
+ }
965
+ break;
966
+ case 'interior-color':
967
+ value = _convertToColor(value);
968
+ if (value && value.length === 3) {
969
+ dictionary.update('IC', [value[0] / 255, value[1] / 255, value[2] / 255]);
970
+ }
971
+ break;
972
+ case 'date':
973
+ _this._addString(dictionary, 'M', value);
974
+ break;
975
+ case 'creationdate':
976
+ _this._addString(dictionary, 'CreationDate', value);
977
+ break;
978
+ case 'name':
979
+ _this._addString(dictionary, 'NM', value);
980
+ break;
981
+ case 'icon':
982
+ if (value) {
983
+ dictionary.update('Name', _PdfName.get(value));
984
+ }
985
+ break;
986
+ case 'subject':
987
+ _this._addString(dictionary, 'Subj', value);
988
+ break;
989
+ case 'title':
990
+ _this._addString(dictionary, 'T', value);
991
+ break;
992
+ case 'rotation':
993
+ dictionary.update('Rotate', Number.parseFloat(value));
994
+ break;
995
+ case 'fringe':
996
+ _this._addFloatPoints(dictionary, 'RD', _this._parseFloatPoints(value));
997
+ break;
998
+ case 'it':
999
+ if (value) {
1000
+ dictionary.update('IT', _PdfName.get(value));
1001
+ }
1002
+ break;
1003
+ case 'leaderlength':
1004
+ dictionary.update('LL', Number.parseFloat(value));
1005
+ break;
1006
+ case 'leaderextend':
1007
+ dictionary.update('LLE', Number.parseFloat(value));
1008
+ break;
1009
+ case 'caption':
1010
+ _this._addBoolean(dictionary, 'Cap', value.toLowerCase());
1011
+ break;
1012
+ case 'caption-style':
1013
+ if (value) {
1014
+ dictionary.update('CP', _PdfName.get(value));
1015
+ }
1016
+ break;
1017
+ case 'callout':
1018
+ _this._addFloatPoints(dictionary, 'CL', _this._parseFloatPoints(value));
1019
+ break;
1020
+ case 'coords':
1021
+ _this._addFloatPoints(dictionary, 'QuadPoints', _this._parseFloatPoints(value));
1022
+ break;
1023
+ case 'border':
1024
+ _this._addFloatPoints(dictionary, 'Border', _this._parseFloatPoints(value));
1025
+ break;
1026
+ case 'opacity':
1027
+ dictionary.update('CA', Number.parseFloat(value));
1028
+ break;
1029
+ case 'defaultstyle':
1030
+ if (value) {
1031
+ var styleKeys_1 = Object.keys(value);
1032
+ if (styleKeys_1 && styleKeys_1.length > 0) {
1033
+ var style_1 = '';
1034
+ var count_1 = 0;
1035
+ styleKeys_1.forEach(function (styleKey) {
1036
+ var styleValue = value[styleKey]; // eslint-disable-line
1037
+ style_1 += styleKey + ':' + styleValue;
1038
+ if (count_1 < styleKeys_1.length - 1) {
1039
+ style_1 += ';';
1040
+ }
1041
+ count_1++;
1042
+ });
1043
+ _this._addString(dictionary, 'DS', style_1);
1044
+ }
1045
+ }
1046
+ break;
1047
+ case 'defaultappearance':
1048
+ _this._addString(dictionary, 'DA', value);
1049
+ break;
1050
+ case 'flags':
1051
+ if (value && typeof value === 'string') {
1052
+ var annotFlag = PdfAnnotationFlag.default;
1053
+ var flags = value.split(',');
1054
+ for (var i = 0; i < flags.length; i++) {
1055
+ var flagType = _stringToAnnotationFlags(flags[Number.parseInt(i.toString(), 10)]);
1056
+ if (i === 0) {
1057
+ annotFlag = flagType;
1058
+ }
1059
+ else {
1060
+ annotFlag |= flagType;
1061
+ }
1062
+ }
1063
+ dictionary.update('F', annotFlag);
1064
+ }
1065
+ break;
1066
+ case 'open':
1067
+ _this._addBoolean(dictionary, 'Open', value.toLowerCase());
1068
+ break;
1069
+ case 'repeat':
1070
+ _this._addBoolean(dictionary, 'Repeat', value.toLowerCase());
1071
+ break;
1072
+ case 'overlaytext':
1073
+ _this._addString(dictionary, 'OverlayText', value);
1074
+ break;
1075
+ case 'contents':
1076
+ if (typeof value === 'string') {
1077
+ if (value.indexOf('\\r') !== -1) {
1078
+ value = value.replace('\\r', '\r');
1079
+ }
1080
+ if (value) {
1081
+ _this._addString(dictionary, 'Contents', value);
1082
+ }
1083
+ }
1084
+ break;
1085
+ case 'q':
1086
+ dictionary.update('Q', Number.parseInt(value, 10));
1087
+ break;
1088
+ case 'inklist':
1089
+ if (value) {
1090
+ var gestureKeys = Object.keys(value);
1091
+ if (gestureKeys && gestureKeys.length > 0 && gestureKeys.indexOf('gesture') !== -1) {
1092
+ var gesture = value.gesture;
1093
+ if (gesture && gesture.length > 0) {
1094
+ dictionary.update('InkList', gesture);
1095
+ }
1096
+ }
1097
+ }
1098
+ break;
1099
+ case 'head':
1100
+ beginLineStyle = value;
1101
+ break;
1102
+ case 'tail':
1103
+ endLineStyle = value;
1104
+ break;
1105
+ case 'creation':
1106
+ case 'modification':
1107
+ case 'file':
1108
+ case 'bits':
1109
+ case 'channels':
1110
+ case 'encoding':
1111
+ case 'rate':
1112
+ case 'length':
1113
+ case 'filter':
1114
+ case 'mode':
1115
+ case 'size':
1116
+ dataStream.set(key, value);
1117
+ break;
1118
+ case 'data':
1119
+ values = value;
1120
+ break;
1121
+ case 'vertices':
1122
+ if (value && typeof value === 'string') {
1123
+ var split = value.split(/[,;]/);
1124
+ if (split && split.length > 0) {
1125
+ var vertices = [];
1126
+ for (var i = 0; i < split.length; i++) {
1127
+ vertices.push(Number.parseFloat(split[Number.parseInt(i.toString(), 10)]));
1128
+ }
1129
+ if (vertices.length > 0 && vertices.length % 2 === 0) {
1130
+ dictionary.update('Vertices', vertices);
1131
+ }
1132
+ }
1133
+ }
1134
+ break;
1135
+ case 'customdata':
1136
+ _this._addString(dictionary, 'CustomData', value);
1137
+ break;
1138
+ case 'appearance':
1139
+ _this._addAppearanceData(dictionary, value);
1140
+ break;
1141
+ case 'allowedinteractions':
1142
+ _this._addString(dictionary, 'AllowedInteractions', value);
1143
+ break;
1144
+ default:
1145
+ if (_this._document._allowImportCustomData && key !== 'type' && key !== 'page') {
1146
+ _this._addString(dictionary, key, value);
1147
+ }
1148
+ break;
1149
+ }
1150
+ });
1151
+ this._addMeasureDictionary(dictionary, annotation, annotationKeys);
1152
+ if (beginLineStyle) {
1153
+ if (endLineStyle) {
1154
+ dictionary.update('LE', [_PdfName.get(beginLineStyle), _PdfName.get(endLineStyle)]);
1155
+ }
1156
+ else {
1157
+ dictionary.update('LE', beginLineStyle);
1158
+ }
1159
+ }
1160
+ else if (endLineStyle) {
1161
+ dictionary.update('LE', endLineStyle);
1162
+ }
1163
+ if (borderStyleDictionary.size > 0) {
1164
+ borderStyleDictionary.update('Type', _PdfName.get('Border'));
1165
+ var reference = this._crossReference._getNextReference();
1166
+ borderStyleDictionary.objId = reference.objectNumber + ' ' + reference.generationNumber;
1167
+ this._crossReference._cacheMap.set(reference, borderStyleDictionary);
1168
+ dictionary.update('BS', reference);
1169
+ }
1170
+ if (borderEffectDictionary.size > 0) {
1171
+ var reference = this._crossReference._getNextReference();
1172
+ borderStyleDictionary.objId = reference.objectNumber + ' ' + reference.generationNumber;
1173
+ this._crossReference._cacheMap.set(reference, borderEffectDictionary);
1174
+ dictionary.update('BE', reference);
1175
+ }
1176
+ this._addStreamData(dictionary, dataStream, values);
1177
+ };
1178
+ _JsonDocument.prototype._addLinePoints = function (value, linePoints) {
1179
+ if (value && value.indexOf(',') !== -1) {
1180
+ var points = value.split(',');
1181
+ points.forEach(function (point) {
1182
+ linePoints.push(Number.parseFloat(point));
1183
+ });
1184
+ }
1185
+ };
1186
+ _JsonDocument.prototype._addString = function (dictionary, key, value) {
1187
+ if (value) {
1188
+ dictionary.update(key, value);
1189
+ }
1190
+ };
1191
+ _JsonDocument.prototype._addBoolean = function (dictionary, key, value) {
1192
+ if (value) {
1193
+ dictionary.update(key, value === 'yes' || value === 'true');
1194
+ }
1195
+ };
1196
+ _JsonDocument.prototype._addBorderStyle = function (key, value, borderEffectDictionary, borderStyleDictionary) {
1197
+ var style = '';
1198
+ var isBasicStyle = true;
1199
+ switch (value) {
1200
+ case 'dash':
1201
+ style = 'D';
1202
+ break;
1203
+ case 'solid':
1204
+ style = 'S';
1205
+ break;
1206
+ case 'bevelled':
1207
+ style = 'B';
1208
+ break;
1209
+ case 'inset':
1210
+ style = 'I';
1211
+ break;
1212
+ case 'underline':
1213
+ style = 'U';
1214
+ break;
1215
+ case 'cloudy':
1216
+ style = 'C';
1217
+ isBasicStyle = false;
1218
+ break;
1219
+ }
1220
+ switch (key.toLowerCase()) {
1221
+ case 'width':
1222
+ borderStyleDictionary.update('W', Number.parseFloat(value));
1223
+ break;
1224
+ case 'intensity':
1225
+ borderEffectDictionary.update('I', Number.parseFloat(value));
1226
+ break;
1227
+ case 'dashes':
1228
+ if (value && value.indexOf(',') !== -1) {
1229
+ borderStyleDictionary.update('D', this._parseFloatPoints(value));
1230
+ }
1231
+ break;
1232
+ }
1233
+ if (style) {
1234
+ if (isBasicStyle) {
1235
+ borderStyleDictionary.update('S', _PdfName.get(style));
1236
+ }
1237
+ else {
1238
+ borderEffectDictionary.update('S', _PdfName.get(style));
1239
+ }
1240
+ }
1241
+ };
1242
+ _JsonDocument.prototype._parseFloatPoints = function (value) {
1243
+ var dashes = value.split(',');
1244
+ var dashArray = [];
1245
+ dashes.forEach(function (dash) {
1246
+ dashArray.push(Number.parseFloat(dash));
1247
+ });
1248
+ return dashArray;
1249
+ };
1250
+ _JsonDocument.prototype._addFloatPoints = function (dictionary, key, value) {
1251
+ if (value && value.length > 0) {
1252
+ dictionary.update(key, value);
1253
+ }
1254
+ };
1255
+ _JsonDocument.prototype._addMeasureDictionary = function (dictionary, annotation, annotationKeys) {
1256
+ var measureDictionary = new _PdfDictionary(this._crossReference);
1257
+ var aArray = [];
1258
+ var dArray = [];
1259
+ var xArray = [];
1260
+ var tArray = [];
1261
+ var vArray = [];
1262
+ measureDictionary.set('A', aArray);
1263
+ measureDictionary.set('D', dArray);
1264
+ measureDictionary.set('X', xArray);
1265
+ measureDictionary.set('T', tArray);
1266
+ measureDictionary.set('V', vArray);
1267
+ if (annotationKeys.indexOf('ratevalue') !== -1) {
1268
+ this._addString(measureDictionary, 'R', annotation['ratevalue']);
1269
+ }
1270
+ if (annotationKeys.indexOf('subtype') !== -1) {
1271
+ this._addString(measureDictionary, 'Subtype', annotation['subtype']);
1272
+ }
1273
+ if (annotationKeys.indexOf('targetunitconversion') !== -1) {
1274
+ this._addString(measureDictionary, 'TargetUnitConversion', annotation['targetunitconversion']);
1275
+ }
1276
+ if (annotationKeys.indexOf('area') !== -1) {
1277
+ aArray.push(this._readDictionaryElements(annotation['area']));
1278
+ }
1279
+ if (annotationKeys.indexOf('distance') !== -1) {
1280
+ dArray.push(this._readDictionaryElements(annotation['distance']));
1281
+ }
1282
+ if (annotationKeys.indexOf('xformat') !== -1) {
1283
+ xArray.push(this._readDictionaryElements(annotation['xformat']));
1284
+ }
1285
+ if (annotationKeys.indexOf('tformat') !== -1) {
1286
+ tArray.push(this._readDictionaryElements(annotation['tformat']));
1287
+ }
1288
+ if (annotationKeys.indexOf('vformat') !== -1) {
1289
+ vArray.push(this._readDictionaryElements(annotation['vformat']));
1290
+ }
1291
+ if (annotationKeys.indexOf('type1') !== -1) {
1292
+ measureDictionary.set('Type', _PdfName.get('Measure'));
1293
+ var reference = this._crossReference._getNextReference();
1294
+ measureDictionary.objId = reference.objectNumber + ' ' + reference.generationNumber;
1295
+ this._crossReference._cacheMap.set(reference, measureDictionary);
1296
+ dictionary.update('Measure', reference);
1297
+ }
1298
+ };
1299
+ _JsonDocument.prototype._readDictionaryElements = function (elements) {
1300
+ var keys = Object.keys(elements);
1301
+ var dictionary = new _PdfDictionary(this._crossReference);
1302
+ if (keys && keys.length > 0) {
1303
+ keys.forEach(function (key) {
1304
+ var value = elements[key]; // eslint-disable-line
1305
+ if (key && value) {
1306
+ switch (key) {
1307
+ case 'd':
1308
+ dictionary.set('D', Number.parseFloat(value));
1309
+ break;
1310
+ case 'c':
1311
+ dictionary.set('C', Number.parseFloat(value));
1312
+ break;
1313
+ case 'rt':
1314
+ dictionary.set('RT', value);
1315
+ break;
1316
+ case 'rd':
1317
+ dictionary.set('RD', value);
1318
+ break;
1319
+ case 'ss':
1320
+ dictionary.set('SS', value);
1321
+ break;
1322
+ case 'u':
1323
+ dictionary.set('U', value);
1324
+ break;
1325
+ case 'f':
1326
+ dictionary.set('F', _PdfName.get(value));
1327
+ break;
1328
+ case 'fd':
1329
+ dictionary.set('FD', value);
1330
+ break;
1331
+ case 'type':
1332
+ dictionary.set('Type', _PdfName.get(value));
1333
+ break;
1334
+ }
1335
+ }
1336
+ });
1337
+ }
1338
+ return dictionary;
1339
+ };
1340
+ _JsonDocument.prototype._addStreamData = function (dictionary, data, values) {
1341
+ var _this = this;
1342
+ var subtype = dictionary.get('Subtype').name;
1343
+ var bytes = _hexStringToByteArray(values, true);
1344
+ if (subtype === 'Sound') {
1345
+ var soundStream_1 = new _PdfContentStream(bytes);
1346
+ soundStream_1.dictionary._crossReference = this._crossReference;
1347
+ soundStream_1.dictionary.update('Type', _PdfName.get('Sound'));
1348
+ data.forEach(function (value, key) {
1349
+ if (key && value) {
1350
+ switch (key) {
1351
+ case 'bits':
1352
+ case 'rate':
1353
+ case 'channels':
1354
+ soundStream_1.dictionary.set(key, Number.parseInt(value, 10));
1355
+ break;
1356
+ case 'encoding':
1357
+ soundStream_1.dictionary.set('E', _PdfName.get(value));
1358
+ break;
1359
+ case 'filter':
1360
+ soundStream_1.dictionary.set('Filter', _PdfName.get('FlateDecode'));
1361
+ break;
1362
+ }
1363
+ }
1364
+ });
1365
+ soundStream_1.reference = this._crossReference._getNextReference();
1366
+ soundStream_1.dictionary.objId = soundStream_1.reference.objectNumber + ' ' + soundStream_1.reference.generationNumber;
1367
+ this._crossReference._cacheMap.set(soundStream_1.reference, soundStream_1);
1368
+ dictionary.update('Sound', soundStream_1.reference);
1369
+ }
1370
+ else if (subtype === 'FileAttachment') {
1371
+ var fileDictionary_1 = new _PdfDictionary(this._crossReference);
1372
+ fileDictionary_1.update('Type', _PdfName.get('Filespec'));
1373
+ var fileStream_1 = new _PdfContentStream(bytes);
1374
+ fileStream_1.dictionary._crossReference = this._crossReference;
1375
+ var param_1 = new _PdfDictionary(this._crossReference);
1376
+ data.forEach(function (value, key) {
1377
+ if (key && value) {
1378
+ var size = void 0;
1379
+ switch (key) {
1380
+ case 'file':
1381
+ _this._addString(fileDictionary_1, 'F', value);
1382
+ _this._addString(fileDictionary_1, 'UF', value);
1383
+ break;
1384
+ case 'size':
1385
+ size = Number.parseInt(value, 10);
1386
+ if (typeof size !== 'undefined') {
1387
+ param_1.update('Size', size);
1388
+ fileStream_1.dictionary.update('DL', size);
1389
+ }
1390
+ break;
1391
+ case 'creation':
1392
+ _this._addString(param_1, 'CreationDate', value);
1393
+ break;
1394
+ case 'modification':
1395
+ _this._addString(param_1, 'ModificationDate', value);
1396
+ break;
1397
+ }
1398
+ }
1399
+ });
1400
+ fileStream_1.dictionary.update('Params', param_1);
1401
+ fileStream_1.dictionary.update('Filter', _PdfName.get('FlateDecode'));
1402
+ fileStream_1.reference = this._crossReference._getNextReference();
1403
+ fileStream_1.dictionary.objId = fileStream_1.reference.objectNumber + ' ' + fileStream_1.reference.generationNumber;
1404
+ this._crossReference._cacheMap.set(fileStream_1.reference, fileStream_1);
1405
+ var embeddedFile = new _PdfDictionary(this._crossReference);
1406
+ embeddedFile.update('F', fileStream_1.reference);
1407
+ fileDictionary_1.update('EF', embeddedFile);
1408
+ var reference = this._crossReference._getNextReference();
1409
+ fileDictionary_1.objId = reference.objectNumber + ' ' + reference.generationNumber;
1410
+ this._crossReference._cacheMap.set(reference, fileDictionary_1);
1411
+ dictionary.update('FS', reference);
1412
+ }
1413
+ };
1414
+ _JsonDocument.prototype._addAppearanceData = function (dictionary, data) {
1415
+ if (data) {
1416
+ var encoded = _decode(data, false);
1417
+ var decoded = _bytesToString(encoded);
1418
+ if (decoded.startsWith('{') && !decoded.endsWith('}')) {
1419
+ while (decoded.length > 0 && !decoded.endsWith('}')) {
1420
+ decoded = decoded.substring(0, decoded.length - 1);
1421
+ }
1422
+ }
1423
+ var json = JSON.parse(decoded); // eslint-disable-line
1424
+ if (json) {
1425
+ var keys = Object.keys(json);
1426
+ if (keys && keys.length > 0 && keys.indexOf('ap') !== -1) {
1427
+ dictionary.update('AP', this._parseDictionary(json['ap']));
1428
+ }
1429
+ }
1430
+ }
1431
+ };
1432
+ _JsonDocument.prototype._parseAppearance = function (element) {
1433
+ var _this = this;
1434
+ var value; // eslint-disable-line
1435
+ var keys = Object.keys(element);
1436
+ if (keys.indexOf('name') !== -1) {
1437
+ value = _PdfName.get(element.name);
1438
+ }
1439
+ else if (keys.indexOf('int') !== -1) {
1440
+ value = Number.parseInt(element.int, 10);
1441
+ }
1442
+ else if (keys.indexOf('fixed') !== -1) {
1443
+ value = Number.parseFloat(element.fixed);
1444
+ }
1445
+ else if (keys.indexOf('string') !== -1) {
1446
+ value = element.string;
1447
+ }
1448
+ else if (keys.indexOf('boolean') !== -1) {
1449
+ value = element.boolean === 'true' ? true : false;
1450
+ }
1451
+ else if (keys.indexOf('array') !== -1) {
1452
+ var array = element.array; // eslint-disable-line
1453
+ value = [];
1454
+ array.forEach(function (element) {
1455
+ value.push(_this._parseAppearance(element));
1456
+ });
1457
+ }
1458
+ else if (keys.indexOf('dict') !== -1) {
1459
+ var dictionary = this._parseDictionary(element.dict);
1460
+ value = this._crossReference._getNextReference();
1461
+ dictionary.objId = value.objectNumber + ' ' + value.generationNumber;
1462
+ this._crossReference._cacheMap.set(value, dictionary);
1463
+ }
1464
+ else if (keys.indexOf('stream') !== -1) {
1465
+ var stream = this._parseStream(element.stream);
1466
+ value = this._crossReference._getNextReference();
1467
+ stream.reference = value;
1468
+ stream.dictionary.objId = value.objectNumber + ' ' + value.generationNumber;
1469
+ this._crossReference._cacheMap.set(value, stream);
1470
+ }
1471
+ else {
1472
+ value = null;
1473
+ }
1474
+ return value;
1475
+ };
1476
+ _JsonDocument.prototype._parseDictionary = function (element) {
1477
+ var _this = this;
1478
+ var result = new _PdfDictionary(this._crossReference);
1479
+ if (element) {
1480
+ var keys = Object.keys(element);
1481
+ if (keys && keys.length > 0) {
1482
+ keys.forEach(function (key) {
1483
+ var value = element[key]; // eslint-disable-line
1484
+ if (key !== 'data') {
1485
+ var primitive = _this._parseAppearance(value); // eslint-disable-line
1486
+ result.update(key, primitive);
1487
+ }
1488
+ });
1489
+ }
1490
+ }
1491
+ return result;
1492
+ };
1493
+ _JsonDocument.prototype._parseStream = function (element) {
1494
+ var result;
1495
+ var keys = Object.keys(element);
1496
+ if (element && keys.indexOf('data')) {
1497
+ var data = element.data; // eslint-disable-line
1498
+ var bytes = void 0;
1499
+ if (data) {
1500
+ var dataKeys = Object.keys(data);
1501
+ if (dataKeys && dataKeys.indexOf('bytes') !== -1) {
1502
+ var byteString = data.bytes;
1503
+ if (byteString) {
1504
+ bytes = _hexStringToByteArray(byteString, true);
1505
+ }
1506
+ }
1507
+ }
1508
+ if (!bytes) {
1509
+ bytes = [];
1510
+ }
1511
+ var stream = new _PdfContentStream(bytes);
1512
+ var dictionary = this._parseDictionary(element);
1513
+ stream.dictionary = dictionary;
1514
+ result = stream;
1515
+ }
1516
+ return result;
1517
+ };
1518
+ _JsonDocument.prototype._getValidString = function (value) {
1519
+ if (value.indexOf('\\') !== -1) {
1520
+ value = value.replace(/\\/g, '\\\\');
1521
+ }
1522
+ if (value.indexOf('"') !== -1) {
1523
+ value = value.replace(/"/g, '\\"');
1524
+ }
1525
+ if (value.indexOf('[') !== -1) {
1526
+ value = value.replace(/\[/g, '\\[');
1527
+ }
1528
+ if (value.indexOf(']') !== -1) {
1529
+ value = value.replace(/\[/g, '\\]');
1530
+ }
1531
+ if (value.indexOf('{') !== -1) {
1532
+ value = value.replace(/\[/g, '\\{');
1533
+ }
1534
+ if (value.indexOf('}') !== -1) {
1535
+ value = value.replace(/\}/g, '\\}');
1536
+ }
1537
+ if (value.indexOf('\n') !== -1) {
1538
+ value = value.replace(/\n/g, '\\n');
1539
+ }
1540
+ if (value.indexOf('\r') !== -1) {
1541
+ value = value.replace(/\r/g, '\\r');
1542
+ }
1543
+ return value;
1544
+ };
1545
+ return _JsonDocument;
1546
+ }(_ExportHelper));
1547
+ export { _JsonDocument };