@syncfusion/ej2-pdf 1.0.23 → 23.1.38

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 +28 -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 +48372 -0
  8. package/dist/es6/ej2-pdf.es2015.js.map +1 -0
  9. package/dist/es6/ej2-pdf.es5.js +50250 -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 +755 -0
  24. package/src/pdf/core/annotations/annotation.d.ts +5865 -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 +38 -0
  67. package/src/pdf/core/graphics/images/image-decoder.js +227 -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 +686 -0
  127. package/src/pdf/core/utils.js +3625 -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,1035 @@
1
+ import { _PdfCommand, _PdfName, _PdfDictionary, _isCommand, _PdfReference } from './pdf-primitives';
2
+ import { _isWhiteSpace, FormatError, ParserEndOfFileException } from './utils';
3
+ import { _PdfNullStream } from './base-stream';
4
+ import { PdfPredictorStream } from './predictor-stream';
5
+ import { _PdfFlateStream } from './flate-stream';
6
+ var maxCacheLength = 1000;
7
+ var maxNumberLength = 5552;
8
+ var endOfFile = 'EOF';
9
+ var specialChars = [
10
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0,
11
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
12
+ 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2,
13
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0,
14
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0,
16
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0,
18
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
24
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
26
+ ];
27
+ var _PdfLexicalOperator = /** @class */ (function () {
28
+ function _PdfLexicalOperator(stream) {
29
+ this.stream = stream;
30
+ this.nextChar();
31
+ this.stringBuffer = [];
32
+ this._hexStringNumber = 0;
33
+ this.beginInlineImagePosition = -1;
34
+ }
35
+ _PdfLexicalOperator.prototype.nextChar = function () {
36
+ return (this.currentChar = this.stream.getByte());
37
+ };
38
+ _PdfLexicalOperator.prototype.peekChar = function () {
39
+ return this.stream.peekByte();
40
+ };
41
+ _PdfLexicalOperator.prototype.getNumber = function () {
42
+ var ch = this.currentChar;
43
+ var eNotation = false;
44
+ var divideBy = 0;
45
+ var sign = 0;
46
+ if (ch === 0x2d) {
47
+ sign = -1;
48
+ ch = this.nextChar();
49
+ if (ch === 0x2d) {
50
+ ch = this.nextChar();
51
+ }
52
+ }
53
+ else if (ch === 0x2b) {
54
+ sign = 1;
55
+ ch = this.nextChar();
56
+ }
57
+ if (ch === 0x0a || ch === 0x0d) {
58
+ do {
59
+ ch = this.nextChar();
60
+ } while (ch === 0x0a || ch === 0x0d);
61
+ }
62
+ if (ch === 0x2e) {
63
+ divideBy = 10;
64
+ ch = this.nextChar();
65
+ }
66
+ if (ch < 0x30 || ch > 0x39) {
67
+ if (_isWhiteSpace(ch) || ch === -1) {
68
+ if (divideBy === 10 && sign === 0) {
69
+ return 0;
70
+ }
71
+ if (divideBy === 0 && sign === -1) {
72
+ return 0;
73
+ }
74
+ }
75
+ throw new FormatError("Invalid number: " + String.fromCharCode(ch) + " (charCode " + ch + ")");
76
+ }
77
+ sign = sign || 1;
78
+ var baseValue = ch - 0x30;
79
+ var powerValue = 0;
80
+ var powerValueSign = 1;
81
+ ch = this.nextChar();
82
+ while (ch >= 0) {
83
+ if (ch >= 0x30 && ch <= 0x39) {
84
+ var currentDigit = ch - 0x30;
85
+ if (eNotation) {
86
+ powerValue = powerValue * 10 + currentDigit;
87
+ }
88
+ else {
89
+ if (divideBy !== 0) {
90
+ divideBy *= 10;
91
+ }
92
+ baseValue = baseValue * 10 + currentDigit;
93
+ }
94
+ }
95
+ else if (ch === 0x2e) {
96
+ if (divideBy === 0) {
97
+ divideBy = 1;
98
+ }
99
+ else {
100
+ break;
101
+ }
102
+ }
103
+ else if (ch === 0x2d) {
104
+ ch = this.nextChar();
105
+ continue;
106
+ }
107
+ else if (ch === 0x45 || ch === 0x65) {
108
+ ch = this.peekChar();
109
+ if (ch === 0x2b || ch === 0x2d) {
110
+ powerValueSign = ch === 0x2d ? -1 : 1;
111
+ this.nextChar();
112
+ }
113
+ else if (ch < 0x30 || ch > 0x39) {
114
+ break;
115
+ }
116
+ eNotation = true;
117
+ }
118
+ else {
119
+ break;
120
+ }
121
+ ch = this.nextChar();
122
+ }
123
+ if (divideBy !== 0) {
124
+ baseValue /= divideBy;
125
+ }
126
+ if (eNotation) {
127
+ baseValue *= Math.pow(10, (powerValueSign * powerValue));
128
+ }
129
+ return sign * baseValue;
130
+ };
131
+ _PdfLexicalOperator.prototype.getString = function () {
132
+ var numParen = 1;
133
+ var done = false;
134
+ var stringBuffer = this.stringBuffer;
135
+ stringBuffer.length = 0;
136
+ var ch = this.nextChar();
137
+ while (true) { // eslint-disable-line
138
+ var charBuffered = false;
139
+ switch (ch | 0) {
140
+ case -1:
141
+ done = true;
142
+ break;
143
+ case 0x28:
144
+ ++numParen;
145
+ stringBuffer.push('(');
146
+ break;
147
+ case 0x29:
148
+ if (--numParen === 0) {
149
+ this.nextChar();
150
+ done = true;
151
+ }
152
+ else {
153
+ stringBuffer.push(')');
154
+ }
155
+ break;
156
+ case 0x5c:
157
+ ch = this.nextChar();
158
+ switch (ch) {
159
+ case -1:
160
+ done = true;
161
+ break;
162
+ case 0x6e:
163
+ stringBuffer.push('\n');
164
+ break;
165
+ case 0x72:
166
+ stringBuffer.push('\r');
167
+ break;
168
+ case 0x74:
169
+ stringBuffer.push('\t');
170
+ break;
171
+ case 0x62:
172
+ stringBuffer.push('\b');
173
+ break;
174
+ case 0x66:
175
+ stringBuffer.push('\f');
176
+ break;
177
+ case 0x5c:
178
+ case 0x28:
179
+ case 0x29:
180
+ stringBuffer.push(String.fromCharCode(ch));
181
+ break;
182
+ case 0x30:
183
+ case 0x31:
184
+ case 0x32:
185
+ case 0x33:
186
+ case 0x34:
187
+ case 0x35:
188
+ case 0x36:
189
+ case 0x37:
190
+ var x = ch & 0x0f; // eslint-disable-line
191
+ ch = this.nextChar();
192
+ charBuffered = true;
193
+ if (ch >= 0x30 && ch <= 0x37) {
194
+ x = (x << 3) + (ch & 0x0f);
195
+ ch = this.nextChar();
196
+ if (ch >= 0x30 && ch <= 0x37) {
197
+ charBuffered = false;
198
+ x = (x << 3) + (ch & 0x0f);
199
+ }
200
+ }
201
+ stringBuffer.push(String.fromCharCode(x));
202
+ break;
203
+ case 0x0d:
204
+ if (this.peekChar() === 0x0a) {
205
+ this.nextChar();
206
+ }
207
+ break;
208
+ case 0x0a:
209
+ break;
210
+ default:
211
+ stringBuffer.push(String.fromCharCode(ch));
212
+ break;
213
+ }
214
+ break;
215
+ default:
216
+ stringBuffer.push(String.fromCharCode(ch));
217
+ break;
218
+ }
219
+ if (done) {
220
+ break;
221
+ }
222
+ if (!charBuffered) {
223
+ ch = this.nextChar();
224
+ }
225
+ }
226
+ return stringBuffer.join('');
227
+ };
228
+ _PdfLexicalOperator.prototype.getName = function () {
229
+ var ch;
230
+ var previousCh;
231
+ var stringBuffer = this.stringBuffer;
232
+ stringBuffer.length = 0;
233
+ ch = this.nextChar();
234
+ while (ch >= 0 && !specialChars[ch]) { // eslint-disable-line
235
+ if (ch === 0x23) {
236
+ ch = this.nextChar();
237
+ if (specialChars[ch]) { // eslint-disable-line
238
+ stringBuffer.push('#');
239
+ break;
240
+ }
241
+ var x = this._toHexDigit(ch);
242
+ if (x !== -1) {
243
+ previousCh = ch;
244
+ ch = this.nextChar();
245
+ var x2 = this._toHexDigit(ch);
246
+ if (x2 === -1) {
247
+ stringBuffer.push('#', String.fromCharCode(previousCh));
248
+ if (specialChars[ch]) { // eslint-disable-line
249
+ break;
250
+ }
251
+ stringBuffer.push(String.fromCharCode(ch));
252
+ ch = this.nextChar();
253
+ continue;
254
+ }
255
+ stringBuffer.push(String.fromCharCode((x << 4) | x2));
256
+ }
257
+ else {
258
+ stringBuffer.push('#', String.fromCharCode(ch));
259
+ }
260
+ }
261
+ else {
262
+ stringBuffer.push(String.fromCharCode(ch));
263
+ }
264
+ ch = this.nextChar();
265
+ }
266
+ return _PdfName.get(stringBuffer.join(''));
267
+ };
268
+ _PdfLexicalOperator.prototype.getHexString = function () {
269
+ var stringBuffer = this.stringBuffer;
270
+ stringBuffer.length = 0;
271
+ var ch = this.currentChar;
272
+ var isFirstHex = true;
273
+ var firstDigit;
274
+ var secondDigit;
275
+ this._hexStringNumber = 0;
276
+ while (true) { // eslint-disable-line
277
+ if (ch < 0) {
278
+ break;
279
+ }
280
+ else if (ch === 0x3e) {
281
+ this.nextChar();
282
+ break;
283
+ }
284
+ else if (specialChars[ch] === 1) { // eslint-disable-line
285
+ ch = this.nextChar();
286
+ continue;
287
+ }
288
+ else {
289
+ if (isFirstHex) {
290
+ firstDigit = this._toHexDigit(ch);
291
+ if (firstDigit === -1) {
292
+ ch = this.nextChar();
293
+ continue;
294
+ }
295
+ }
296
+ else {
297
+ secondDigit = this._toHexDigit(ch);
298
+ if (secondDigit === -1) {
299
+ ch = this.nextChar();
300
+ continue;
301
+ }
302
+ stringBuffer.push(String.fromCharCode((firstDigit << 4) | secondDigit));
303
+ }
304
+ isFirstHex = !isFirstHex;
305
+ ch = this.nextChar();
306
+ }
307
+ }
308
+ return stringBuffer.join('');
309
+ };
310
+ _PdfLexicalOperator.prototype.getObject = function () {
311
+ var comment = false;
312
+ var ch = this.currentChar;
313
+ while (true) { // eslint-disable-line
314
+ if (ch < 0) {
315
+ return endOfFile;
316
+ }
317
+ if (comment) {
318
+ if (ch === 0x0a || ch === 0x0d) {
319
+ comment = false;
320
+ }
321
+ }
322
+ else if (ch === 0x25) {
323
+ comment = true;
324
+ }
325
+ else if (specialChars[ch] !== 1) { // eslint-disable-line
326
+ break;
327
+ }
328
+ ch = this.nextChar();
329
+ }
330
+ switch (ch | 0) {
331
+ case 0x30:
332
+ case 0x31:
333
+ case 0x32:
334
+ case 0x33:
335
+ case 0x34:
336
+ case 0x35:
337
+ case 0x36:
338
+ case 0x37:
339
+ case 0x38:
340
+ case 0x39:
341
+ case 0x2b:
342
+ case 0x2d:
343
+ case 0x2e:
344
+ return this.getNumber();
345
+ case 0x28:
346
+ return this.getString();
347
+ case 0x2f:
348
+ return this.getName();
349
+ case 0x5b:
350
+ this.nextChar();
351
+ return _PdfCommand.get('[');
352
+ case 0x5d:
353
+ this.nextChar();
354
+ return _PdfCommand.get(']');
355
+ case 0x3c:
356
+ ch = this.nextChar();
357
+ if (ch === 0x3c) {
358
+ this.nextChar();
359
+ return _PdfCommand.get('<<');
360
+ }
361
+ return this.getHexString();
362
+ case 0x3e:
363
+ ch = this.nextChar();
364
+ if (ch === 0x3e) {
365
+ this.nextChar();
366
+ return _PdfCommand.get('>>');
367
+ }
368
+ return _PdfCommand.get('>');
369
+ case 0x7b:
370
+ this.nextChar();
371
+ return _PdfCommand.get('{');
372
+ case 0x7d:
373
+ this.nextChar();
374
+ return _PdfCommand.get('}');
375
+ case 0x29:
376
+ this.nextChar();
377
+ throw new FormatError("Illegal character: " + ch);
378
+ }
379
+ var str = String.fromCharCode(ch);
380
+ if (ch < 0x20 || ch > 0x7f) {
381
+ var nextCh = this.peekChar();
382
+ if (nextCh >= 0x20 && nextCh <= 0x7f) {
383
+ this.nextChar();
384
+ return _PdfCommand.get(str);
385
+ }
386
+ }
387
+ ch = this.nextChar();
388
+ while (ch >= 0 && !specialChars[ch]) { // eslint-disable-line
389
+ var possibleCommand = str + String.fromCharCode(ch);
390
+ if (str.length === 128) {
391
+ throw new FormatError("Command token too long: " + str.length);
392
+ }
393
+ str = possibleCommand;
394
+ ch = this.nextChar();
395
+ }
396
+ if (str === 'true') {
397
+ return true;
398
+ }
399
+ if (str === 'false') {
400
+ return false;
401
+ }
402
+ if (str === 'null') {
403
+ return null;
404
+ }
405
+ if (str === 'BI') {
406
+ this.beginInlineImagePosition = this.stream.position;
407
+ }
408
+ return _PdfCommand.get(str);
409
+ };
410
+ _PdfLexicalOperator.prototype.peekObj = function () {
411
+ var streamPos = this.stream.position;
412
+ var currentChar = this.currentChar;
413
+ var beginInlineImagePosition = this.beginInlineImagePosition;
414
+ var nextObj; // eslint-disable-line
415
+ try {
416
+ nextObj = this.getObject();
417
+ }
418
+ catch (ex) { } // eslint-disable-line
419
+ this.stream.position = streamPos;
420
+ this.currentChar = currentChar;
421
+ this.beginInlineImagePosition = beginInlineImagePosition;
422
+ return nextObj;
423
+ };
424
+ _PdfLexicalOperator.prototype.skipToNextLine = function () {
425
+ var ch = this.currentChar;
426
+ while (ch >= 0) {
427
+ if (ch === 0x0d) {
428
+ ch = this.nextChar();
429
+ if (ch === 0x0a) {
430
+ this.nextChar();
431
+ }
432
+ break;
433
+ }
434
+ else if (ch === 0x0a) {
435
+ this.nextChar();
436
+ break;
437
+ }
438
+ ch = this.nextChar();
439
+ }
440
+ };
441
+ _PdfLexicalOperator.prototype._toHexDigit = function (ch) {
442
+ if (ch >= 0x30 && ch <= 0x39) {
443
+ return ch & 0x0f;
444
+ }
445
+ if ((ch >= 0x41 && ch <= 0x46) || (ch >= 0x61 && ch <= 0x66)) {
446
+ return (ch & 0x0f) + 9;
447
+ }
448
+ return -1;
449
+ };
450
+ return _PdfLexicalOperator;
451
+ }());
452
+ export { _PdfLexicalOperator };
453
+ var _PdfParser = /** @class */ (function () {
454
+ function _PdfParser(lexicalOperator, xref, allowStreams, recoveryMode) {
455
+ if (allowStreams === void 0) { allowStreams = false; }
456
+ if (recoveryMode === void 0) { recoveryMode = false; }
457
+ this.lexicalOperator = lexicalOperator;
458
+ this.xref = xref;
459
+ this.allowStreams = allowStreams;
460
+ this.recoveryMode = recoveryMode;
461
+ this.imageCache = new Map();
462
+ this.refill();
463
+ }
464
+ _PdfParser.prototype.refill = function () {
465
+ this.first = this.lexicalOperator.getObject();
466
+ this.second = this.lexicalOperator.getObject();
467
+ };
468
+ _PdfParser.prototype.shift = function () {
469
+ if (this.second instanceof _PdfCommand && this.second.command === 'ID') {
470
+ this.first = this.second;
471
+ this.second = null;
472
+ }
473
+ else {
474
+ this.first = this.second;
475
+ this.second = this.lexicalOperator.getObject();
476
+ }
477
+ };
478
+ _PdfParser.prototype.tryShift = function () {
479
+ try {
480
+ this.shift();
481
+ return true;
482
+ }
483
+ catch (e) {
484
+ return false;
485
+ }
486
+ };
487
+ _PdfParser.prototype.getObject = function (cipherTransform) {
488
+ var first = this.first; // eslint-disable-line
489
+ this.shift();
490
+ if (first instanceof _PdfCommand) {
491
+ switch (first.command) {
492
+ case 'BI':
493
+ return this.makeInlineImage(cipherTransform);
494
+ case '[':
495
+ var array = []; // eslint-disable-line
496
+ while (!_isCommand(this.first, ']') && this.first !== endOfFile) {
497
+ array.push(this.getObject(cipherTransform));
498
+ }
499
+ if (this.first === endOfFile) {
500
+ if (this.recoveryMode) {
501
+ return array;
502
+ }
503
+ throw new ParserEndOfFileException('End of file inside array.');
504
+ }
505
+ this.shift();
506
+ return array;
507
+ case '<<':
508
+ var dictionary = new _PdfDictionary(this.xref); // eslint-disable-line
509
+ while (!_isCommand(this.first, '>>') && this.first !== endOfFile) {
510
+ if (!(this.first instanceof _PdfName)) {
511
+ this.shift();
512
+ continue;
513
+ }
514
+ var key = this.first.name;
515
+ this.shift();
516
+ var isEnd = this._checkEnd();
517
+ if (isEnd) {
518
+ break;
519
+ }
520
+ dictionary.set(key, this.getObject(cipherTransform));
521
+ }
522
+ if (this.first === endOfFile) {
523
+ if (this.recoveryMode) {
524
+ return dictionary;
525
+ }
526
+ throw new ParserEndOfFileException('End of file inside dictionary.');
527
+ }
528
+ if (_isCommand(this.second, 'stream')) {
529
+ if (this.allowStreams === true) {
530
+ return this.makeStream(dictionary, cipherTransform);
531
+ }
532
+ else {
533
+ return dictionary;
534
+ }
535
+ }
536
+ this.shift();
537
+ return dictionary;
538
+ default:
539
+ return first;
540
+ }
541
+ }
542
+ if (Number.isInteger(first)) {
543
+ if (Number.isInteger(this.first) && _isCommand(this.second, 'R')) {
544
+ var ref = _PdfReference.get(first, this.first);
545
+ this.shift();
546
+ this.shift();
547
+ return ref;
548
+ }
549
+ return first;
550
+ }
551
+ if (typeof first === 'string') {
552
+ if (cipherTransform) {
553
+ return cipherTransform.decryptString(first);
554
+ }
555
+ return first;
556
+ }
557
+ return first;
558
+ };
559
+ _PdfParser.prototype.findDiscreteDecodeInlineStreamEnd = function (stream) {
560
+ var startPos = stream.position;
561
+ var foundEnd = false;
562
+ var b;
563
+ var markerLength;
564
+ b = stream.getByte();
565
+ while (b !== -1) {
566
+ if (b !== 0xff) {
567
+ b = stream.getByte();
568
+ continue;
569
+ }
570
+ switch (stream.getByte()) {
571
+ case 0x00:
572
+ break;
573
+ case 0xff:
574
+ stream.skip(-1);
575
+ break;
576
+ case 0xd9:
577
+ foundEnd = true;
578
+ break;
579
+ case 0xc0:
580
+ case 0xc1:
581
+ case 0xc2:
582
+ case 0xc3:
583
+ case 0xc5:
584
+ case 0xc6:
585
+ case 0xc7:
586
+ case 0xc9:
587
+ case 0xca:
588
+ case 0xcb:
589
+ case 0xcd:
590
+ case 0xce:
591
+ case 0xcf:
592
+ case 0xc4:
593
+ case 0xcc:
594
+ case 0xda:
595
+ case 0xdb:
596
+ case 0xdc:
597
+ case 0xdd:
598
+ case 0xde:
599
+ case 0xdf:
600
+ case 0xe0:
601
+ case 0xe1:
602
+ case 0xe2:
603
+ case 0xe3:
604
+ case 0xe4:
605
+ case 0xe5:
606
+ case 0xe6:
607
+ case 0xe7:
608
+ case 0xe8:
609
+ case 0xe9:
610
+ case 0xea:
611
+ case 0xeb:
612
+ case 0xec:
613
+ case 0xed:
614
+ case 0xee:
615
+ case 0xef:
616
+ case 0xfe:
617
+ markerLength = stream.getUnsignedInteger16();
618
+ if (markerLength > 2) {
619
+ stream.skip(markerLength - 2);
620
+ }
621
+ else {
622
+ stream.skip(-2);
623
+ }
624
+ break;
625
+ }
626
+ if (foundEnd) {
627
+ break;
628
+ }
629
+ b = stream.getByte();
630
+ }
631
+ var length = stream.position - startPos;
632
+ if (b === -1) {
633
+ stream.skip(-length);
634
+ return this.findDefaultInlineStreamEnd(stream);
635
+ }
636
+ this.inlineStreamSkipEI(stream);
637
+ return length;
638
+ };
639
+ _PdfParser.prototype.findDecodeInlineStreamEnd = function (stream) {
640
+ var startPos = stream.position;
641
+ var ch;
642
+ while ((ch = stream.getByte()) !== -1) { // eslint-disable-line
643
+ if (ch === 0x7e) {
644
+ var tildePos = stream.position;
645
+ ch = stream.peekByte();
646
+ while (_isWhiteSpace(ch)) {
647
+ stream.skip();
648
+ ch = stream.peekByte();
649
+ }
650
+ if (ch === 0x3e) {
651
+ stream.skip();
652
+ break;
653
+ }
654
+ if (stream.position > tildePos) {
655
+ var maybeEI = stream.peekBytes(2);
656
+ if (maybeEI[0] === 0x45 && maybeEI[1] === 0x49) {
657
+ break;
658
+ }
659
+ }
660
+ }
661
+ }
662
+ var length = stream.position - startPos;
663
+ if (ch === -1) {
664
+ stream.skip(-length);
665
+ return this.findDefaultInlineStreamEnd(stream);
666
+ }
667
+ this.inlineStreamSkipEI(stream);
668
+ return length;
669
+ };
670
+ _PdfParser.prototype.findHexDecodeInlineStreamEnd = function (stream) {
671
+ var startPos = stream.position;
672
+ var ch;
673
+ ch = stream.getByte();
674
+ while (ch !== -1) {
675
+ if (ch === 0x3e) {
676
+ break;
677
+ }
678
+ ch = stream.getByte();
679
+ }
680
+ var length = stream.position - startPos;
681
+ if (ch === -1) {
682
+ stream.skip(-length);
683
+ return this.findDefaultInlineStreamEnd(stream);
684
+ }
685
+ this.inlineStreamSkipEI(stream);
686
+ return length;
687
+ };
688
+ _PdfParser.prototype.inlineStreamSkipEI = function (stream) {
689
+ var state = 0;
690
+ var ch;
691
+ ch = stream.getByte();
692
+ while (ch !== -1) {
693
+ if (state === 0) {
694
+ state = ch === 0x45 ? 1 : 0;
695
+ }
696
+ else if (state === 1) {
697
+ state = ch === 0x49 ? 2 : 0;
698
+ }
699
+ else if (state === 2) {
700
+ break;
701
+ }
702
+ ch = stream.getByte();
703
+ }
704
+ };
705
+ _PdfParser.prototype.makeInlineImage = function (cipherTransform) {
706
+ var lexicalOperator = this.lexicalOperator;
707
+ var stream = lexicalOperator.stream;
708
+ var dictionary = new _PdfDictionary(this.xref);
709
+ var dictLength;
710
+ while (!_isCommand(this.first, 'ID') && this.first !== endOfFile) {
711
+ if (!(this.first instanceof _PdfName)) {
712
+ throw new FormatError('Dictionary key must be a name object');
713
+ }
714
+ var key = this.first.name;
715
+ this.shift();
716
+ if (this.first.name === endOfFile) {
717
+ break;
718
+ }
719
+ dictionary.set(key, this.getObject(cipherTransform));
720
+ }
721
+ if (lexicalOperator.beginInlineImagePosition !== -1) {
722
+ dictLength = stream.position - lexicalOperator.beginInlineImagePosition;
723
+ }
724
+ var filter = dictionary.get('F', 'Filter'); // eslint-disable-line
725
+ var filterName;
726
+ if (filter instanceof _PdfName) {
727
+ filterName = filter.name;
728
+ }
729
+ else if (Array.isArray(filter)) {
730
+ var reference = filter[0]; // eslint-disable-line
731
+ var filterZero = (reference !== null && typeof reference !== 'undefined' && reference instanceof _PdfReference) ?
732
+ this.xref._fetch(reference) :
733
+ reference;
734
+ if (filterZero) {
735
+ filterName = filterZero.name;
736
+ }
737
+ }
738
+ var startPos = stream.position;
739
+ var length;
740
+ switch (filterName) {
741
+ case 'DCT':
742
+ case 'DCTDecode':
743
+ length = this.findDiscreteDecodeInlineStreamEnd(stream);
744
+ break;
745
+ case 'A85':
746
+ case 'ASCII85Decode':
747
+ length = this.findDecodeInlineStreamEnd(stream);
748
+ break;
749
+ case 'AHx':
750
+ case 'ASCIIHexDecode':
751
+ length = this.findHexDecodeInlineStreamEnd(stream);
752
+ break;
753
+ default:
754
+ length = this.findDefaultInlineStreamEnd(stream);
755
+ }
756
+ var imageStream = stream.makeSubStream(startPos, length, dictionary); // eslint-disable-line
757
+ var cacheKey;
758
+ if (length < maxCacheLength && dictLength < maxNumberLength) {
759
+ var imageBytes = imageStream.getBytes();
760
+ imageStream.reset();
761
+ var initialStreamPos = stream.position;
762
+ stream.position = lexicalOperator.beginInlineImagePosition;
763
+ var dictBytes = stream.getBytes(dictLength);
764
+ stream.position = initialStreamPos;
765
+ cacheKey = this._computeMaxNumber(imageBytes) + '_' + this._computeMaxNumber(dictBytes);
766
+ var cacheEntry = this.imageCache[cacheKey]; // eslint-disable-line
767
+ if (cacheEntry !== undefined) {
768
+ this.second = _PdfCommand.get('EI');
769
+ this.shift();
770
+ cacheEntry.reset();
771
+ return cacheEntry;
772
+ }
773
+ }
774
+ if (cipherTransform) {
775
+ imageStream = cipherTransform.createStream(imageStream, length);
776
+ }
777
+ imageStream = this.filter(imageStream, dictionary, length);
778
+ imageStream.dictionary = dictionary;
779
+ if (cacheKey !== undefined) {
780
+ this.imageCache[cacheKey] = imageStream; // eslint-disable-line
781
+ }
782
+ this.second = _PdfCommand.get('EI');
783
+ this.shift();
784
+ return imageStream;
785
+ };
786
+ _PdfParser.prototype._computeMaxNumber = function (bytes) {
787
+ var bytesLength = bytes.length;
788
+ var a = 1;
789
+ var b = 0;
790
+ for (var i = 0; i < bytesLength; ++i) {
791
+ a += bytes[i] & 0xff; // eslint-disable-line
792
+ b += a;
793
+ }
794
+ return (b % 65521 << 16) | a % 65521;
795
+ };
796
+ _PdfParser.prototype.makeStream = function (dictionary, cipherTransform) {
797
+ var lexicalOperator = this.lexicalOperator;
798
+ var stream = lexicalOperator.stream; // eslint-disable-line
799
+ lexicalOperator.skipToNextLine();
800
+ var startPosition = stream.position - 1;
801
+ var length = dictionary.get('Length');
802
+ if (!Number.isInteger(length)) {
803
+ length = 0;
804
+ }
805
+ stream.position = startPosition + length;
806
+ lexicalOperator.nextChar();
807
+ if (this.tryShift() && _isCommand(this.second, 'endstream')) {
808
+ this.shift();
809
+ }
810
+ else {
811
+ var endStreamSignature = new Uint8Array([0x65, 0x6e, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d]);
812
+ var actualLength = this._findStreamLength(startPosition, endStreamSignature);
813
+ if (actualLength < 0) {
814
+ var end = endStreamSignature.length - 1;
815
+ var truncatedSignature = endStreamSignature.slice(0, end);
816
+ var maybeLength = this._findStreamLength(startPosition, truncatedSignature);
817
+ if (maybeLength >= 0) {
818
+ var lastByte = stream.peekBytes(end + 1)[end]; // eslint-disable-line
819
+ if (_isWhiteSpace(lastByte)) {
820
+ actualLength = maybeLength;
821
+ }
822
+ }
823
+ if (actualLength < 0) {
824
+ throw new FormatError('Missing endstream command.');
825
+ }
826
+ }
827
+ length = actualLength;
828
+ lexicalOperator.nextChar();
829
+ this.shift();
830
+ this.shift();
831
+ }
832
+ this.shift();
833
+ stream = stream.makeSubStream(startPosition, length, dictionary);
834
+ if (cipherTransform) {
835
+ stream = cipherTransform.createStream(stream, length);
836
+ }
837
+ stream = this.filter(stream, dictionary, length);
838
+ stream.dictionary = dictionary;
839
+ return stream;
840
+ };
841
+ _PdfParser.prototype.filter = function (stream, dictionary, length) {
842
+ var filter = dictionary.get('F', 'Filter'); // eslint-disable-line
843
+ var params = dictionary.get('DP', 'DecodeParms'); // eslint-disable-line
844
+ if (filter instanceof _PdfName) {
845
+ return this.makeFilter(stream, filter.name, length, params);
846
+ }
847
+ var maybeLength = length;
848
+ if (Array.isArray(filter)) {
849
+ var filterArray = filter; // eslint-disable-line
850
+ var paramsArray = params; // eslint-disable-line
851
+ for (var i = 0; i < filterArray.length; ++i) {
852
+ var reference = filterArray[Number.parseInt(i.toString(), 10)]; // eslint-disable-line
853
+ filter = reference instanceof _PdfReference ? this.xref._fetch(reference) : reference;
854
+ if (!(filter instanceof _PdfName)) {
855
+ throw new FormatError("Bad filter name '" + filter + "'");
856
+ }
857
+ params = null;
858
+ if (Array.isArray(paramsArray) && i in paramsArray) {
859
+ var ref = paramsArray[Number.parseInt(i.toString(), 10)]; // eslint-disable-line
860
+ params = ref instanceof _PdfReference ? this.xref._fetch(ref) : ref;
861
+ }
862
+ stream = this.makeFilter(stream, filter.name, maybeLength, params);
863
+ maybeLength = null;
864
+ }
865
+ }
866
+ return stream;
867
+ };
868
+ _PdfParser.prototype.makeFilter = function (stream, name, maybeLength, params) {
869
+ if (maybeLength === 0) {
870
+ return new _PdfNullStream();
871
+ }
872
+ try {
873
+ if (name === 'Fl' || name === 'FlateDecode') {
874
+ if (params) {
875
+ return new PdfPredictorStream(new _PdfFlateStream(stream, maybeLength), maybeLength, params);
876
+ }
877
+ return new _PdfFlateStream(stream, maybeLength);
878
+ }
879
+ return stream;
880
+ }
881
+ catch (ex) {
882
+ return new _PdfNullStream();
883
+ }
884
+ };
885
+ _PdfParser.prototype._findStreamLength = function (startPosition, signature) {
886
+ var stream = this.lexicalOperator.stream;
887
+ stream.position = startPosition;
888
+ var length = 2048;
889
+ var signatureLength = signature.length;
890
+ while (stream.position < stream.end) {
891
+ var scanBytes = stream.peekBytes(length);
892
+ var scanLength = scanBytes.length - signatureLength;
893
+ if (scanLength <= 0) {
894
+ break;
895
+ }
896
+ var position = 0;
897
+ while (position < scanLength) {
898
+ var j = 0;
899
+ while (j < signatureLength && scanBytes[position + j] === signature[j]) { // eslint-disable-line
900
+ j++;
901
+ }
902
+ if (j >= signatureLength) {
903
+ stream.position += position;
904
+ return stream.position - startPosition;
905
+ }
906
+ position++;
907
+ }
908
+ stream.position += scanLength;
909
+ }
910
+ return -1;
911
+ };
912
+ _PdfParser.prototype.findDefaultInlineStreamEnd = function (stream) {
913
+ var startPosition = stream.position;
914
+ var n = 10;
915
+ var state = 0;
916
+ var ch;
917
+ var endImagePosition;
918
+ ch = stream.getByte();
919
+ while (ch !== -1) {
920
+ if (state === 0) {
921
+ state = ch === 0x45 ? 1 : 0;
922
+ }
923
+ else if (state === 1) {
924
+ state = ch === 0x49 ? 2 : 0;
925
+ }
926
+ else {
927
+ if (state !== 2) {
928
+ throw new Error('findDefaultInlineStreamEnd - invalid state.');
929
+ }
930
+ if (ch === 0x20 || ch === 0xa || ch === 0xd) {
931
+ endImagePosition = stream.position;
932
+ var followingBytes = stream.peekBytes(n);
933
+ for (var i = 0, ii = followingBytes.length; i < ii; i++) {
934
+ ch = followingBytes[i]; // eslint-disable-line
935
+ if (ch === 0x0 && followingBytes[i + 1] !== 0x0) {
936
+ continue;
937
+ }
938
+ if (ch !== 0xa && ch !== 0xd && (ch < 0x20 || ch > 0x7f)) {
939
+ state = 0;
940
+ break;
941
+ }
942
+ }
943
+ if (state !== 2) {
944
+ ch = stream.getByte();
945
+ continue;
946
+ }
947
+ if (state === 2) {
948
+ break;
949
+ }
950
+ }
951
+ else {
952
+ state = 0;
953
+ }
954
+ }
955
+ ch = stream.getByte();
956
+ }
957
+ if (ch === -1) {
958
+ if (typeof endImagePosition !== 'undefined') {
959
+ stream.skip(-(stream.position - endImagePosition));
960
+ }
961
+ }
962
+ var endOffset = 4;
963
+ stream.skip(-endOffset);
964
+ ch = stream.peekByte();
965
+ stream.skip(endOffset);
966
+ if (!_isWhiteSpace(ch)) {
967
+ endOffset--;
968
+ }
969
+ return stream.position - endOffset - startPosition;
970
+ };
971
+ _PdfParser.prototype._checkEnd = function () {
972
+ if (this.first === endOfFile) {
973
+ return true;
974
+ }
975
+ else {
976
+ return false;
977
+ }
978
+ };
979
+ return _PdfParser;
980
+ }());
981
+ export { _PdfParser };
982
+ /* eslint-disable */
983
+ var _Linearization = /** @class */ (function () {
984
+ function _Linearization(stream) {
985
+ this.isValid = false;
986
+ var parser = new _PdfParser(new _PdfLexicalOperator(stream), null);
987
+ var obj1 = parser.getObject();
988
+ var obj2 = parser.getObject();
989
+ var obj3 = parser.getObject();
990
+ var dictionary = parser.getObject();
991
+ this.isValid = Number.isInteger(obj1) && Number.isInteger(obj2) && _isCommand(obj3, 'obj') && typeof dictionary !== 'undefined';
992
+ if (this.isValid) {
993
+ var obj = dictionary.get('Linearized');
994
+ this.isValid = typeof obj !== 'undefined' && obj > 0;
995
+ }
996
+ if (this.isValid) {
997
+ var length_1 = this.getInt(dictionary, 'L');
998
+ if (length_1 !== stream.length) {
999
+ throw new Error('The L parameter in the linearization dictionary ' + 'does not equal the stream length.');
1000
+ }
1001
+ this.length = length_1;
1002
+ this.hints = this.getHints(dictionary);
1003
+ this.objectNumberFirst = this.getInt(dictionary, 'O');
1004
+ this.endFirst = this.getInt(dictionary, 'E');
1005
+ this.pageCount = this.getInt(dictionary, 'N');
1006
+ this.mainXRefEntriesOffset = this.getInt(dictionary, 'T');
1007
+ this.pageFirst = dictionary.has('P') ? this.getInt(dictionary, 'P', true) : 0;
1008
+ }
1009
+ }
1010
+ _Linearization.prototype.getInt = function (dictionary, name, allowZeroValue) {
1011
+ if (allowZeroValue === void 0) { allowZeroValue = false; }
1012
+ var obj = dictionary.get(name);
1013
+ if (typeof obj !== 'undefined' && Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
1014
+ return obj;
1015
+ }
1016
+ throw new Error("The '" + name + "' parameter in the linearization " + 'dictionary is invalid.');
1017
+ };
1018
+ _Linearization.prototype.getHints = function (dictionary) {
1019
+ var hints = dictionary.getArray('H');
1020
+ var hintsLength = hints.length;
1021
+ if (hints && (hintsLength === 2 || hintsLength === 4)) {
1022
+ for (var index = 0; index < hintsLength; index++) {
1023
+ var hint = hints[index];
1024
+ if (!(Number.isInteger(hint) && hint > 0)) {
1025
+ throw new Error("Hint (" + index + ") in the linearization dictionary is invalid.");
1026
+ }
1027
+ }
1028
+ return hints;
1029
+ }
1030
+ throw new Error('Hint array in the linearization dictionary is invalid.');
1031
+ };
1032
+ return _Linearization;
1033
+ }());
1034
+ export { _Linearization };
1035
+ /* eslint-enable */