@syncfusion/ej2-pdf-export 26.2.10 → 26.2.11

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 (364) hide show
  1. package/dist/ej2-pdf-export.min.js +10 -0
  2. package/dist/ej2-pdf-export.umd.min.js +2 -2
  3. package/dist/ej2-pdf-export.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-pdf-export.es2015.js +18 -1
  5. package/dist/es6/ej2-pdf-export.es2015.js.map +1 -1
  6. package/dist/es6/ej2-pdf-export.es5.js +18 -1
  7. package/dist/es6/ej2-pdf-export.es5.js.map +1 -1
  8. package/dist/global/ej2-pdf-export.min.js +2 -2
  9. package/dist/global/ej2-pdf-export.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +5 -5
  12. package/src/implementation/structured-elements/grid/layout/grid-layouter.js +12 -1
  13. package/src/implementation/structured-elements/grid/styles/style.d.ts +4 -0
  14. package/src/implementation/structured-elements/grid/styles/style.js +6 -0
  15. package/dist/ts/implementation/actions/action.d.ts +0 -50
  16. package/dist/ts/implementation/actions/action.ts +0 -76
  17. package/dist/ts/implementation/actions/index.d.ts +0 -6
  18. package/dist/ts/implementation/actions/index.ts +0 -6
  19. package/dist/ts/implementation/actions/uri-action.d.ts +0 -33
  20. package/dist/ts/implementation/actions/uri-action.ts +0 -52
  21. package/dist/ts/implementation/annotations/action-link-annotation.d.ts +0 -30
  22. package/dist/ts/implementation/annotations/action-link-annotation.ts +0 -43
  23. package/dist/ts/implementation/annotations/annotation-collection.d.ts +0 -77
  24. package/dist/ts/implementation/annotations/annotation-collection.ts +0 -159
  25. package/dist/ts/implementation/annotations/annotation.d.ts +0 -152
  26. package/dist/ts/implementation/annotations/annotation.ts +0 -241
  27. package/dist/ts/implementation/annotations/document-link-annotation.d.ts +0 -89
  28. package/dist/ts/implementation/annotations/document-link-annotation.ts +0 -118
  29. package/dist/ts/implementation/annotations/index.d.ts +0 -11
  30. package/dist/ts/implementation/annotations/index.ts +0 -11
  31. package/dist/ts/implementation/annotations/link-annotation.d.ts +0 -23
  32. package/dist/ts/implementation/annotations/link-annotation.ts +0 -32
  33. package/dist/ts/implementation/annotations/pdf-text-web-link.d.ts +0 -118
  34. package/dist/ts/implementation/annotations/pdf-text-web-link.ts +0 -265
  35. package/dist/ts/implementation/annotations/uri-annotation.d.ts +0 -48
  36. package/dist/ts/implementation/annotations/uri-annotation.ts +0 -86
  37. package/dist/ts/implementation/collections/dictionary.d.ts +0 -76
  38. package/dist/ts/implementation/collections/dictionary.ts +0 -150
  39. package/dist/ts/implementation/collections/index.d.ts +0 -7
  40. package/dist/ts/implementation/collections/index.ts +0 -7
  41. package/dist/ts/implementation/collections/object-object-pair/dictionary.d.ts +0 -62
  42. package/dist/ts/implementation/collections/object-object-pair/dictionary.ts +0 -125
  43. package/dist/ts/implementation/collections/object-object-pair/index.d.ts +0 -5
  44. package/dist/ts/implementation/collections/object-object-pair/index.ts +0 -5
  45. package/dist/ts/implementation/collections/utils.d.ts +0 -27
  46. package/dist/ts/implementation/collections/utils.ts +0 -38
  47. package/dist/ts/implementation/document/automatic-fields/automatic-field-info-collection.d.ts +0 -31
  48. package/dist/ts/implementation/document/automatic-fields/automatic-field-info-collection.ts +0 -39
  49. package/dist/ts/implementation/document/automatic-fields/automatic-field-info.d.ts +0 -67
  50. package/dist/ts/implementation/document/automatic-fields/automatic-field-info.ts +0 -108
  51. package/dist/ts/implementation/document/automatic-fields/automatic-field.d.ts +0 -41
  52. package/dist/ts/implementation/document/automatic-fields/automatic-field.ts +0 -127
  53. package/dist/ts/implementation/document/automatic-fields/composite-field.d.ts +0 -46
  54. package/dist/ts/implementation/document/automatic-fields/composite-field.ts +0 -76
  55. package/dist/ts/implementation/document/automatic-fields/index.d.ts +0 -11
  56. package/dist/ts/implementation/document/automatic-fields/index.ts +0 -11
  57. package/dist/ts/implementation/document/automatic-fields/multiple-value-field.d.ts +0 -18
  58. package/dist/ts/implementation/document/automatic-fields/multiple-value-field.ts +0 -37
  59. package/dist/ts/implementation/document/automatic-fields/page-count-field.d.ts +0 -44
  60. package/dist/ts/implementation/document/automatic-fields/page-count-field.ts +0 -75
  61. package/dist/ts/implementation/document/automatic-fields/pdf-numbers-convertor.d.ts +0 -53
  62. package/dist/ts/implementation/document/automatic-fields/pdf-numbers-convertor.ts +0 -157
  63. package/dist/ts/implementation/document/automatic-fields/pdf-page-number-field.d.ts +0 -51
  64. package/dist/ts/implementation/document/automatic-fields/pdf-page-number-field.ts +0 -82
  65. package/dist/ts/implementation/document/automatic-fields/pdf-template-value-pair.d.ts +0 -38
  66. package/dist/ts/implementation/document/automatic-fields/pdf-template-value-pair.ts +0 -60
  67. package/dist/ts/implementation/document/automatic-fields/single-value-field.d.ts +0 -15
  68. package/dist/ts/implementation/document/automatic-fields/single-value-field.ts +0 -48
  69. package/dist/ts/implementation/document/index.d.ts +0 -16
  70. package/dist/ts/implementation/document/index.ts +0 -16
  71. package/dist/ts/implementation/document/pdf-catalog.d.ts +0 -39
  72. package/dist/ts/implementation/document/pdf-catalog.ts +0 -65
  73. package/dist/ts/implementation/document/pdf-document-base.d.ts +0 -132
  74. package/dist/ts/implementation/document/pdf-document-base.ts +0 -180
  75. package/dist/ts/implementation/document/pdf-document-template.d.ts +0 -166
  76. package/dist/ts/implementation/document/pdf-document-template.ts +0 -310
  77. package/dist/ts/implementation/document/pdf-document.d.ts +0 -221
  78. package/dist/ts/implementation/document/pdf-document.ts +0 -342
  79. package/dist/ts/implementation/document/pdf-viewer-preferences.d.ts +0 -467
  80. package/dist/ts/implementation/document/pdf-viewer-preferences.ts +0 -578
  81. package/dist/ts/implementation/drawing/index.d.ts +0 -5
  82. package/dist/ts/implementation/drawing/index.ts +0 -5
  83. package/dist/ts/implementation/drawing/pdf-drawing.d.ts +0 -141
  84. package/dist/ts/implementation/drawing/pdf-drawing.ts +0 -218
  85. package/dist/ts/implementation/general/enum.d.ts +0 -21
  86. package/dist/ts/implementation/general/enum.ts +0 -21
  87. package/dist/ts/implementation/general/functions/index.d.ts +0 -6
  88. package/dist/ts/implementation/general/functions/index.ts +0 -6
  89. package/dist/ts/implementation/general/functions/pdf-function.d.ts +0 -44
  90. package/dist/ts/implementation/general/functions/pdf-function.ts +0 -66
  91. package/dist/ts/implementation/general/functions/pdf-sampled-function.d.ts +0 -25
  92. package/dist/ts/implementation/general/functions/pdf-sampled-function.ts +0 -63
  93. package/dist/ts/implementation/general/index.d.ts +0 -9
  94. package/dist/ts/implementation/general/index.ts +0 -9
  95. package/dist/ts/implementation/general/pdf-cache-collection.d.ts +0 -42
  96. package/dist/ts/implementation/general/pdf-cache-collection.ts +0 -97
  97. package/dist/ts/implementation/general/pdf-collection.d.ts +0 -26
  98. package/dist/ts/implementation/general/pdf-collection.ts +0 -41
  99. package/dist/ts/implementation/general/pdf-destination.d.ts +0 -103
  100. package/dist/ts/implementation/general/pdf-destination.ts +0 -170
  101. package/dist/ts/implementation/graphics/brushes/enum.d.ts +0 -236
  102. package/dist/ts/implementation/graphics/brushes/enum.ts +0 -237
  103. package/dist/ts/implementation/graphics/brushes/index.d.ts +0 -13
  104. package/dist/ts/implementation/graphics/brushes/index.ts +0 -13
  105. package/dist/ts/implementation/graphics/brushes/pdf-blend.d.ts +0 -105
  106. package/dist/ts/implementation/graphics/brushes/pdf-blend.ts +0 -294
  107. package/dist/ts/implementation/graphics/brushes/pdf-brush.d.ts +0 -57
  108. package/dist/ts/implementation/graphics/brushes/pdf-brush.ts +0 -68
  109. package/dist/ts/implementation/graphics/brushes/pdf-brushes.d.ts +0 -726
  110. package/dist/ts/implementation/graphics/brushes/pdf-brushes.ts +0 -2438
  111. package/dist/ts/implementation/graphics/brushes/pdf-color-blend.d.ts +0 -113
  112. package/dist/ts/implementation/graphics/brushes/pdf-color-blend.ts +0 -295
  113. package/dist/ts/implementation/graphics/brushes/pdf-gradient-brush.d.ts +0 -155
  114. package/dist/ts/implementation/graphics/brushes/pdf-gradient-brush.ts +0 -311
  115. package/dist/ts/implementation/graphics/brushes/pdf-linear-gradient-brush.d.ts +0 -147
  116. package/dist/ts/implementation/graphics/brushes/pdf-linear-gradient-brush.ts +0 -406
  117. package/dist/ts/implementation/graphics/brushes/pdf-radial-gradient-brush.d.ts +0 -122
  118. package/dist/ts/implementation/graphics/brushes/pdf-radial-gradient-brush.ts +0 -290
  119. package/dist/ts/implementation/graphics/brushes/pdf-solid-brush.d.ts +0 -77
  120. package/dist/ts/implementation/graphics/brushes/pdf-solid-brush.ts +0 -107
  121. package/dist/ts/implementation/graphics/brushes/pdf-tiling-brush.d.ts +0 -161
  122. package/dist/ts/implementation/graphics/brushes/pdf-tiling-brush.ts +0 -304
  123. package/dist/ts/implementation/graphics/constants.d.ts +0 -31
  124. package/dist/ts/implementation/graphics/constants.ts +0 -31
  125. package/dist/ts/implementation/graphics/enum.d.ts +0 -413
  126. package/dist/ts/implementation/graphics/enum.ts +0 -413
  127. package/dist/ts/implementation/graphics/figures/arc.d.ts +0 -87
  128. package/dist/ts/implementation/graphics/figures/arc.ts +0 -133
  129. package/dist/ts/implementation/graphics/figures/base/draw-element.d.ts +0 -30
  130. package/dist/ts/implementation/graphics/figures/base/draw-element.ts +0 -59
  131. package/dist/ts/implementation/graphics/figures/base/element-layouter.d.ts +0 -161
  132. package/dist/ts/implementation/graphics/figures/base/element-layouter.ts +0 -260
  133. package/dist/ts/implementation/graphics/figures/base/fill-element.d.ts +0 -46
  134. package/dist/ts/implementation/graphics/figures/base/fill-element.ts +0 -72
  135. package/dist/ts/implementation/graphics/figures/base/graphics-element.d.ts +0 -16
  136. package/dist/ts/implementation/graphics/figures/base/graphics-element.ts +0 -34
  137. package/dist/ts/implementation/graphics/figures/base/index.d.ts +0 -9
  138. package/dist/ts/implementation/graphics/figures/base/index.ts +0 -9
  139. package/dist/ts/implementation/graphics/figures/base/pdf-shape-element.d.ts +0 -40
  140. package/dist/ts/implementation/graphics/figures/base/pdf-shape-element.ts +0 -69
  141. package/dist/ts/implementation/graphics/figures/base/shape-layouter.d.ts +0 -131
  142. package/dist/ts/implementation/graphics/figures/base/shape-layouter.ts +0 -276
  143. package/dist/ts/implementation/graphics/figures/base/text-layouter.d.ts +0 -107
  144. package/dist/ts/implementation/graphics/figures/base/text-layouter.ts +0 -205
  145. package/dist/ts/implementation/graphics/figures/ellipse-part.d.ts +0 -48
  146. package/dist/ts/implementation/graphics/figures/ellipse-part.ts +0 -76
  147. package/dist/ts/implementation/graphics/figures/enum.d.ts +0 -79
  148. package/dist/ts/implementation/graphics/figures/enum.ts +0 -80
  149. package/dist/ts/implementation/graphics/figures/index.d.ts +0 -13
  150. package/dist/ts/implementation/graphics/figures/index.ts +0 -13
  151. package/dist/ts/implementation/graphics/figures/layout-element.d.ts +0 -73
  152. package/dist/ts/implementation/graphics/figures/layout-element.ts +0 -132
  153. package/dist/ts/implementation/graphics/figures/path.d.ts +0 -319
  154. package/dist/ts/implementation/graphics/figures/path.ts +0 -646
  155. package/dist/ts/implementation/graphics/figures/pdf-template.d.ts +0 -113
  156. package/dist/ts/implementation/graphics/figures/pdf-template.ts +0 -205
  157. package/dist/ts/implementation/graphics/figures/rectangle-area.d.ts +0 -64
  158. package/dist/ts/implementation/graphics/figures/rectangle-area.ts +0 -108
  159. package/dist/ts/implementation/graphics/figures/text-element.d.ts +0 -213
  160. package/dist/ts/implementation/graphics/figures/text-element.ts +0 -445
  161. package/dist/ts/implementation/graphics/fonts/enum.d.ts +0 -385
  162. package/dist/ts/implementation/graphics/fonts/enum.ts +0 -385
  163. package/dist/ts/implementation/graphics/fonts/index.d.ts +0 -16
  164. package/dist/ts/implementation/graphics/fonts/index.ts +0 -16
  165. package/dist/ts/implementation/graphics/fonts/pdf-font-metrics.d.ts +0 -164
  166. package/dist/ts/implementation/graphics/fonts/pdf-font-metrics.ts +0 -248
  167. package/dist/ts/implementation/graphics/fonts/pdf-font.d.ts +0 -187
  168. package/dist/ts/implementation/graphics/fonts/pdf-font.ts +0 -316
  169. package/dist/ts/implementation/graphics/fonts/pdf-standard-font-metrics-factory.d.ts +0 -301
  170. package/dist/ts/implementation/graphics/fonts/pdf-standard-font-metrics-factory.ts +0 -606
  171. package/dist/ts/implementation/graphics/fonts/pdf-standard-font.d.ts +0 -143
  172. package/dist/ts/implementation/graphics/fonts/pdf-standard-font.ts +0 -243
  173. package/dist/ts/implementation/graphics/fonts/pdf-string-format.d.ts +0 -321
  174. package/dist/ts/implementation/graphics/fonts/pdf-string-format.ts +0 -474
  175. package/dist/ts/implementation/graphics/fonts/pdf-true-type-font.d.ts +0 -49
  176. package/dist/ts/implementation/graphics/fonts/pdf-true-type-font.ts +0 -165
  177. package/dist/ts/implementation/graphics/fonts/rtl/index.d.ts +0 -6
  178. package/dist/ts/implementation/graphics/fonts/rtl/index.ts +0 -6
  179. package/dist/ts/implementation/graphics/fonts/rtl/rtl-bidirectional.d.ts +0 -62
  180. package/dist/ts/implementation/graphics/fonts/rtl/rtl-bidirectional.ts +0 -958
  181. package/dist/ts/implementation/graphics/fonts/rtl/rtl-text-shape.d.ts +0 -68
  182. package/dist/ts/implementation/graphics/fonts/rtl/rtl-text-shape.ts +0 -374
  183. package/dist/ts/implementation/graphics/fonts/rtl-renderer.d.ts +0 -23
  184. package/dist/ts/implementation/graphics/fonts/rtl-renderer.ts +0 -255
  185. package/dist/ts/implementation/graphics/fonts/string-layouter.d.ts +0 -254
  186. package/dist/ts/implementation/graphics/fonts/string-layouter.ts +0 -617
  187. package/dist/ts/implementation/graphics/fonts/string-tokenizer.d.ts +0 -109
  188. package/dist/ts/implementation/graphics/fonts/string-tokenizer.ts +0 -275
  189. package/dist/ts/implementation/graphics/fonts/ttf-OS2-Table.d.ts +0 -204
  190. package/dist/ts/implementation/graphics/fonts/ttf-OS2-Table.ts +0 -206
  191. package/dist/ts/implementation/graphics/fonts/ttf-apple-cmap-sub-table.d.ts +0 -17
  192. package/dist/ts/implementation/graphics/fonts/ttf-apple-cmap-sub-table.ts +0 -18
  193. package/dist/ts/implementation/graphics/fonts/ttf-cmap-sub-table.d.ts +0 -17
  194. package/dist/ts/implementation/graphics/fonts/ttf-cmap-sub-table.ts +0 -18
  195. package/dist/ts/implementation/graphics/fonts/ttf-cmap-table.d.ts +0 -13
  196. package/dist/ts/implementation/graphics/fonts/ttf-cmap-table.ts +0 -14
  197. package/dist/ts/implementation/graphics/fonts/ttf-glyph-header.d.ts +0 -25
  198. package/dist/ts/implementation/graphics/fonts/ttf-glyph-header.ts +0 -26
  199. package/dist/ts/implementation/graphics/fonts/ttf-glyph-info.d.ts +0 -25
  200. package/dist/ts/implementation/graphics/fonts/ttf-glyph-info.ts +0 -35
  201. package/dist/ts/implementation/graphics/fonts/ttf-head-table.d.ts +0 -94
  202. package/dist/ts/implementation/graphics/fonts/ttf-head-table.ts +0 -94
  203. package/dist/ts/implementation/graphics/fonts/ttf-horizontal-header-table.d.ts +0 -55
  204. package/dist/ts/implementation/graphics/fonts/ttf-horizontal-header-table.ts +0 -56
  205. package/dist/ts/implementation/graphics/fonts/ttf-loca-table.d.ts +0 -9
  206. package/dist/ts/implementation/graphics/fonts/ttf-loca-table.ts +0 -10
  207. package/dist/ts/implementation/graphics/fonts/ttf-long-hor-metric.d.ts +0 -13
  208. package/dist/ts/implementation/graphics/fonts/ttf-long-hor-metric.ts +0 -14
  209. package/dist/ts/implementation/graphics/fonts/ttf-metrics.d.ts +0 -101
  210. package/dist/ts/implementation/graphics/fonts/ttf-metrics.ts +0 -106
  211. package/dist/ts/implementation/graphics/fonts/ttf-microsoft-cmap-sub-table.d.ts +0 -57
  212. package/dist/ts/implementation/graphics/fonts/ttf-microsoft-cmap-sub-table.ts +0 -58
  213. package/dist/ts/implementation/graphics/fonts/ttf-name-record.d.ts +0 -33
  214. package/dist/ts/implementation/graphics/fonts/ttf-name-record.ts +0 -33
  215. package/dist/ts/implementation/graphics/fonts/ttf-name-table.d.ts +0 -22
  216. package/dist/ts/implementation/graphics/fonts/ttf-name-table.ts +0 -22
  217. package/dist/ts/implementation/graphics/fonts/ttf-post-table.d.ts +0 -41
  218. package/dist/ts/implementation/graphics/fonts/ttf-post-table.ts +0 -42
  219. package/dist/ts/implementation/graphics/fonts/ttf-reader.d.ts +0 -225
  220. package/dist/ts/implementation/graphics/fonts/ttf-reader.ts +0 -1254
  221. package/dist/ts/implementation/graphics/fonts/ttf-table-info.d.ts +0 -22
  222. package/dist/ts/implementation/graphics/fonts/ttf-table-info.ts +0 -26
  223. package/dist/ts/implementation/graphics/fonts/ttf-trimmed-cmap-sub-table.d.ts +0 -25
  224. package/dist/ts/implementation/graphics/fonts/ttf-trimmed-cmap-sub-table.ts +0 -26
  225. package/dist/ts/implementation/graphics/fonts/unicode-true-type-font.d.ts +0 -213
  226. package/dist/ts/implementation/graphics/fonts/unicode-true-type-font.ts +0 -577
  227. package/dist/ts/implementation/graphics/images/byte-array.d.ts +0 -74
  228. package/dist/ts/implementation/graphics/images/byte-array.ts +0 -137
  229. package/dist/ts/implementation/graphics/images/image-decoder.d.ts +0 -274
  230. package/dist/ts/implementation/graphics/images/image-decoder.ts +0 -439
  231. package/dist/ts/implementation/graphics/images/index.d.ts +0 -8
  232. package/dist/ts/implementation/graphics/images/index.ts +0 -8
  233. package/dist/ts/implementation/graphics/images/pdf-bitmap.d.ts +0 -90
  234. package/dist/ts/implementation/graphics/images/pdf-bitmap.ts +0 -110
  235. package/dist/ts/implementation/graphics/images/pdf-image.d.ts +0 -88
  236. package/dist/ts/implementation/graphics/images/pdf-image.ts +0 -132
  237. package/dist/ts/implementation/graphics/index.d.ts +0 -35
  238. package/dist/ts/implementation/graphics/index.ts +0 -46
  239. package/dist/ts/implementation/graphics/pdf-color.d.ts +0 -206
  240. package/dist/ts/implementation/graphics/pdf-color.ts +0 -478
  241. package/dist/ts/implementation/graphics/pdf-graphics.d.ts +0 -1210
  242. package/dist/ts/implementation/graphics/pdf-graphics.ts +0 -2554
  243. package/dist/ts/implementation/graphics/pdf-margins.d.ts +0 -82
  244. package/dist/ts/implementation/graphics/pdf-margins.ts +0 -124
  245. package/dist/ts/implementation/graphics/pdf-pen.d.ts +0 -237
  246. package/dist/ts/implementation/graphics/pdf-pen.ts +0 -370
  247. package/dist/ts/implementation/graphics/pdf-resources.d.ts +0 -122
  248. package/dist/ts/implementation/graphics/pdf-resources.ts +0 -300
  249. package/dist/ts/implementation/graphics/pdf-transformation-matrix.d.ts +0 -143
  250. package/dist/ts/implementation/graphics/pdf-transformation-matrix.ts +0 -246
  251. package/dist/ts/implementation/graphics/pdf-transparency.d.ts +0 -34
  252. package/dist/ts/implementation/graphics/pdf-transparency.ts +0 -93
  253. package/dist/ts/implementation/graphics/unit-convertor.d.ts +0 -72
  254. package/dist/ts/implementation/graphics/unit-convertor.ts +0 -96
  255. package/dist/ts/implementation/index.d.ts +0 -103
  256. package/dist/ts/implementation/index.ts +0 -103
  257. package/dist/ts/implementation/input-output/big-endian-writer.d.ts +0 -59
  258. package/dist/ts/implementation/input-output/big-endian-writer.ts +0 -121
  259. package/dist/ts/implementation/input-output/cross-table.d.ts +0 -21
  260. package/dist/ts/implementation/input-output/cross-table.ts +0 -21
  261. package/dist/ts/implementation/input-output/enum.d.ts +0 -16
  262. package/dist/ts/implementation/input-output/enum.ts +0 -16
  263. package/dist/ts/implementation/input-output/index.d.ts +0 -12
  264. package/dist/ts/implementation/input-output/index.ts +0 -12
  265. package/dist/ts/implementation/input-output/pdf-cross-table.d.ts +0 -249
  266. package/dist/ts/implementation/input-output/pdf-cross-table.ts +0 -524
  267. package/dist/ts/implementation/input-output/pdf-dictionary-properties.d.ts +0 -568
  268. package/dist/ts/implementation/input-output/pdf-dictionary-properties.ts +0 -571
  269. package/dist/ts/implementation/input-output/pdf-main-object-collection.d.ts +0 -120
  270. package/dist/ts/implementation/input-output/pdf-main-object-collection.ts +0 -194
  271. package/dist/ts/implementation/input-output/pdf-operators.d.ts +0 -361
  272. package/dist/ts/implementation/input-output/pdf-operators.ts +0 -363
  273. package/dist/ts/implementation/input-output/pdf-stream-writer.d.ts +0 -311
  274. package/dist/ts/implementation/input-output/pdf-stream-writer.ts +0 -681
  275. package/dist/ts/implementation/input-output/pdf-writer.d.ts +0 -68
  276. package/dist/ts/implementation/input-output/pdf-writer.ts +0 -88
  277. package/dist/ts/implementation/pages/enum.d.ts +0 -201
  278. package/dist/ts/implementation/pages/enum.ts +0 -201
  279. package/dist/ts/implementation/pages/index.d.ts +0 -17
  280. package/dist/ts/implementation/pages/index.ts +0 -17
  281. package/dist/ts/implementation/pages/page-added-event-arguments.d.ts +0 -30
  282. package/dist/ts/implementation/pages/page-added-event-arguments.ts +0 -39
  283. package/dist/ts/implementation/pages/pdf-document-page-collection.d.ts +0 -86
  284. package/dist/ts/implementation/pages/pdf-document-page-collection.ts +0 -180
  285. package/dist/ts/implementation/pages/pdf-page-base.d.ts +0 -121
  286. package/dist/ts/implementation/pages/pdf-page-base.ts +0 -181
  287. package/dist/ts/implementation/pages/pdf-page-layer-collection.d.ts +0 -99
  288. package/dist/ts/implementation/pages/pdf-page-layer-collection.ts +0 -348
  289. package/dist/ts/implementation/pages/pdf-page-layer.d.ts +0 -160
  290. package/dist/ts/implementation/pages/pdf-page-layer.ts +0 -271
  291. package/dist/ts/implementation/pages/pdf-page-settings.d.ts +0 -111
  292. package/dist/ts/implementation/pages/pdf-page-settings.ts +0 -192
  293. package/dist/ts/implementation/pages/pdf-page-size.d.ts +0 -159
  294. package/dist/ts/implementation/pages/pdf-page-size.ts +0 -162
  295. package/dist/ts/implementation/pages/pdf-page-template-element.d.ts +0 -240
  296. package/dist/ts/implementation/pages/pdf-page-template-element.ts +0 -663
  297. package/dist/ts/implementation/pages/pdf-page.d.ts +0 -153
  298. package/dist/ts/implementation/pages/pdf-page.ts +0 -235
  299. package/dist/ts/implementation/pages/pdf-section-collection.d.ts +0 -109
  300. package/dist/ts/implementation/pages/pdf-section-collection.ts +0 -187
  301. package/dist/ts/implementation/pages/pdf-section-page-collection.d.ts +0 -41
  302. package/dist/ts/implementation/pages/pdf-section-page-collection.ts +0 -61
  303. package/dist/ts/implementation/pages/pdf-section-templates.d.ts +0 -64
  304. package/dist/ts/implementation/pages/pdf-section-templates.ts +0 -96
  305. package/dist/ts/implementation/pages/pdf-section.d.ts +0 -327
  306. package/dist/ts/implementation/pages/pdf-section.ts +0 -644
  307. package/dist/ts/implementation/primitives/index.d.ts +0 -12
  308. package/dist/ts/implementation/primitives/index.ts +0 -12
  309. package/dist/ts/implementation/primitives/pdf-array.d.ts +0 -192
  310. package/dist/ts/implementation/primitives/pdf-array.ts +0 -386
  311. package/dist/ts/implementation/primitives/pdf-boolean.d.ts +0 -84
  312. package/dist/ts/implementation/primitives/pdf-boolean.ts +0 -119
  313. package/dist/ts/implementation/primitives/pdf-dictionary.d.ts +0 -362
  314. package/dist/ts/implementation/primitives/pdf-dictionary.ts +0 -513
  315. package/dist/ts/implementation/primitives/pdf-name.d.ts +0 -121
  316. package/dist/ts/implementation/primitives/pdf-name.ts +0 -218
  317. package/dist/ts/implementation/primitives/pdf-number.d.ts +0 -104
  318. package/dist/ts/implementation/primitives/pdf-number.ts +0 -165
  319. package/dist/ts/implementation/primitives/pdf-reference.d.ts +0 -223
  320. package/dist/ts/implementation/primitives/pdf-reference.ts +0 -430
  321. package/dist/ts/implementation/primitives/pdf-stream.d.ts +0 -161
  322. package/dist/ts/implementation/primitives/pdf-stream.ts +0 -306
  323. package/dist/ts/implementation/primitives/pdf-string.d.ts +0 -235
  324. package/dist/ts/implementation/primitives/pdf-string.ts +0 -397
  325. package/dist/ts/implementation/structured-elements/grid/index.d.ts +0 -4
  326. package/dist/ts/implementation/structured-elements/grid/index.ts +0 -10
  327. package/dist/ts/implementation/structured-elements/grid/layout/grid-layouter.d.ts +0 -597
  328. package/dist/ts/implementation/structured-elements/grid/layout/grid-layouter.ts +0 -2029
  329. package/dist/ts/implementation/structured-elements/grid/pdf-grid-cell.d.ts +0 -288
  330. package/dist/ts/implementation/structured-elements/grid/pdf-grid-cell.ts +0 -1194
  331. package/dist/ts/implementation/structured-elements/grid/pdf-grid-column.d.ts +0 -108
  332. package/dist/ts/implementation/structured-elements/grid/pdf-grid-column.ts +0 -206
  333. package/dist/ts/implementation/structured-elements/grid/pdf-grid-row.d.ts +0 -261
  334. package/dist/ts/implementation/structured-elements/grid/pdf-grid-row.ts +0 -470
  335. package/dist/ts/implementation/structured-elements/grid/pdf-grid.d.ts +0 -292
  336. package/dist/ts/implementation/structured-elements/grid/pdf-grid.ts +0 -853
  337. package/dist/ts/implementation/structured-elements/grid/styles/index.d.ts +0 -5
  338. package/dist/ts/implementation/structured-elements/grid/styles/index.ts +0 -5
  339. package/dist/ts/implementation/structured-elements/grid/styles/pdf-borders.d.ts +0 -146
  340. package/dist/ts/implementation/structured-elements/grid/styles/pdf-borders.ts +0 -240
  341. package/dist/ts/implementation/structured-elements/grid/styles/style.d.ts +0 -272
  342. package/dist/ts/implementation/structured-elements/grid/styles/style.ts +0 -424
  343. package/dist/ts/implementation/structured-elements/index.d.ts +0 -4
  344. package/dist/ts/implementation/structured-elements/index.ts +0 -10
  345. package/dist/ts/implementation/structured-elements/tables/light-tables/enum.d.ts +0 -16
  346. package/dist/ts/implementation/structured-elements/tables/light-tables/enum.ts +0 -16
  347. package/dist/ts/index.d.ts +0 -116
  348. package/dist/ts/index.ts +0 -116
  349. package/dist/ts/interfaces/i-pdf-cache.d.ts +0 -23
  350. package/dist/ts/interfaces/i-pdf-cache.ts +0 -23
  351. package/dist/ts/interfaces/i-pdf-changable.d.ts +0 -17
  352. package/dist/ts/interfaces/i-pdf-changable.ts +0 -17
  353. package/dist/ts/interfaces/i-pdf-clonable.d.ts +0 -12
  354. package/dist/ts/interfaces/i-pdf-clonable.ts +0 -12
  355. package/dist/ts/interfaces/i-pdf-primitives.d.ts +0 -45
  356. package/dist/ts/interfaces/i-pdf-primitives.ts +0 -45
  357. package/dist/ts/interfaces/i-pdf-true-type-font.d.ts +0 -18
  358. package/dist/ts/interfaces/i-pdf-true-type-font.ts +0 -48
  359. package/dist/ts/interfaces/i-pdf-wrapper.d.ts +0 -13
  360. package/dist/ts/interfaces/i-pdf-wrapper.ts +0 -13
  361. package/dist/ts/interfaces/i-pdf-writer.d.ts +0 -29
  362. package/dist/ts/interfaces/i-pdf-writer.ts +0 -29
  363. package/dist/ts/interfaces/index.d.ts +0 -10
  364. package/dist/ts/interfaces/index.ts +0 -10
@@ -1,2554 +0,0 @@
1
- /**
2
- * PdfGraphics.ts class for EJ2-PDF
3
- */
4
- import { PdfColorSpace, TextRenderingMode, PdfFillMode, PdfTextAlignment } from './enum';
5
- import { PdfVerticalAlignment, PdfBlendMode } from './enum';
6
- import { PdfSubSuperScript } from './fonts/enum';
7
- import { PdfStreamWriter } from './../input-output/pdf-stream-writer';
8
- import { PdfPen } from './pdf-pen';
9
- import { PdfBrush } from './brushes/pdf-brush';
10
- import { PdfSolidBrush } from './brushes/pdf-solid-brush';
11
- import { PdfFont } from './fonts/pdf-font';
12
- import { PdfStandardFont } from './fonts/pdf-standard-font';
13
- import { PdfTransformationMatrix, Matrix } from './pdf-transformation-matrix';
14
- import { PointF, SizeF, RectangleF } from './../drawing/pdf-drawing';
15
- import { ProcedureSets } from './constants';
16
- import { PdfStream } from './../primitives/pdf-stream';
17
- import { PdfString } from './../primitives/pdf-string';
18
- import { PdfName } from './../primitives/pdf-name';
19
- import { PdfArray } from './../primitives/pdf-array';
20
- import { PdfStringFormat } from './fonts/pdf-string-format';
21
- import { TemporaryDictionary } from './../collections/object-object-pair/dictionary';
22
- import { PdfTransparency } from './pdf-transparency';
23
- import { PdfStringLayouter, PdfStringLayoutResult, LineType } from './fonts/string-layouter';
24
- import { PdfPageLayer } from './../pages/pdf-page-layer';
25
- import { PdfPageBase } from './../pages/pdf-page-base';
26
- import { PdfPage } from './../pages/pdf-page';
27
- import { DictionaryProperties } from './../input-output/pdf-dictionary-properties';
28
- import { StringTokenizer } from './fonts/string-tokenizer';
29
- import { PdfResources } from './pdf-resources';
30
- import { LineInfo } from './fonts/string-layouter';
31
- import { PdfImage } from './images/pdf-image';
32
- import { PdfAutomaticFieldInfoCollection } from './../document/automatic-fields/automatic-field-info-collection';
33
- import { PdfAutomaticFieldInfo } from './../document/automatic-fields/automatic-field-info';
34
- import { PdfTemplate } from './figures/pdf-template';
35
- import { PdfCrossTable } from './../input-output/pdf-cross-table';
36
- import { PdfSection } from './../pages/pdf-section';
37
- import { Operators } from './../input-output/pdf-operators';
38
- import { PdfTrueTypeFont } from './fonts/pdf-true-type-font';
39
- import { UnicodeTrueTypeFont } from './fonts/unicode-true-type-font';
40
- import { TtfReader } from './fonts/ttf-reader';
41
- import { InternalEnum } from './../primitives/pdf-string';
42
- import { RtlRenderer } from './fonts/rtl-renderer';
43
- import { PdfTextDirection } from './enum';
44
- import { PathPointType } from './figures/enum';
45
- import { PdfPath } from './figures/path';
46
- import { PdfGradientBrush } from './../../implementation/graphics/brushes/pdf-gradient-brush';
47
- import { PdfTilingBrush } from './brushes/pdf-tiling-brush';
48
- /**
49
- * `PdfGraphics` class represents a graphics context of the objects.
50
- * It's used for performing all the graphics operations.
51
- * ```typescript
52
- * // create a new PDF document
53
- * let document : PdfDocument = new PdfDocument();
54
- * // add a new page to the document
55
- * let page1 : PdfPage = document.pages.add();
56
- * // set the font
57
- * let font : PdfStandardFont = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
58
- * // create black brush
59
- * let blackBrush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(0, 0, 0));
60
- * //
61
- * //graphics of the page
62
- * let page1Graphics : PdfGraphics = page1.graphics;
63
- * // draw the text on the page1 graphics
64
- * page1Graphics.drawString('Hello World', font, blackBrush, new PointF(0, 0));
65
- * //
66
- * // save the document
67
- * document.save('output.pdf');
68
- * // destroy the document
69
- * document.destroy();
70
- * ```
71
- */
72
- export class PdfGraphics {
73
- /* tslint:disable */
74
- // Constants
75
- /**
76
- * Specifies the mask of `path type values`.
77
- * @private
78
- */
79
- private static readonly pathTypesValuesMask : number = 0xf;
80
- // Fields
81
- /**
82
- * Represents the `Stream writer` object.
83
- * @private
84
- */
85
- private pdfStreamWriter : PdfStreamWriter;
86
- /**
87
- * Represents the state, whether it `is saved or not`.
88
- * @private
89
- */
90
- private bStateSaved : boolean;
91
- /**
92
- * Represents the `Current pen`.
93
- * @private
94
- */
95
- private currentPen : PdfPen;
96
- /**
97
- * Represents the `Current brush`.
98
- * @private
99
- */
100
- private currentBrush : PdfBrush;
101
- /**
102
- * Represents the `Current font`.
103
- * @private
104
- */
105
- private currentFont : PdfFont;
106
- /**
107
- * Represents the `Current font`.
108
- * @private
109
- */
110
- public currentPage : PdfPage;
111
- /**
112
- * Represents the `Current color space`.
113
- * @private
114
- */
115
- private currentColorSpace : PdfColorSpace = PdfColorSpace.Rgb;
116
- /**
117
- * The `transformation matrix` monitoring all changes with CTM.
118
- * @private
119
- */
120
- private transformationMatrix : PdfTransformationMatrix;
121
- /**
122
- * Stores `previous rendering mode`.
123
- * @private
124
- */
125
- private previousTextRenderingMode : TextRenderingMode = TextRenderingMode.Fill;
126
- /**
127
- * Previous `character spacing` value or 0.
128
- * @private
129
- */
130
- private previousCharacterSpacing : number = 0.0;
131
- /**
132
- * Previous `word spacing` value or 0.
133
- * @private
134
- */
135
- private previousWordSpacing : number = 0.0;
136
- /**
137
- * The `previously used text scaling` value.
138
- * @private
139
- */
140
- private previousTextScaling : number = 100.0;
141
- /**
142
- * Event handler object to store instance of `PdfResources` class.
143
- * @private
144
- */
145
- private getResources : GetResourceEventHandler;
146
- /**
147
- * Indicates whether `color space was initialized`.
148
- * @private
149
- */
150
- private bCSInitialized : boolean;
151
- /**
152
- * Represents the `Size of the canvas`.
153
- * @private
154
- */
155
- private canvasSize : SizeF;
156
- /**
157
- * Represents the size of the canvas reduced by `margins and templates`.
158
- * @private
159
- */
160
- public clipBounds : RectangleF;
161
- // private trasparencies : Dictionary<TransparencyData, PdfTransparency>;
162
- /**
163
- * Current `string format`.
164
- * @private
165
- */
166
- private currentStringFormat : PdfStringFormat;
167
- /**
168
- * Instance of `ProcedureSets` class.
169
- * @private
170
- */
171
- private procedureSets : ProcedureSets = new ProcedureSets();
172
- /**
173
- * To check wihether it is a `direct text rendering`.
174
- * @default true
175
- * @private
176
- */
177
- private isNormalRender : boolean = true;
178
- /**
179
- * check whether to `use font size` to calculate the shift.
180
- * @default false
181
- * @private
182
- */
183
- private isUseFontSize : boolean = false;
184
- /**
185
- * check whether the font is in `italic type`.
186
- * @default false
187
- * @private
188
- */
189
- private isItalic : boolean = false;
190
- /**
191
- * Check whether it is an `emf Text Matrix`.
192
- * @default false
193
- * @private
194
- */
195
- public isEmfTextScaled : boolean = false;
196
- /**
197
- * Check whether it is an `emf` call.
198
- * @default false
199
- * @private
200
- */
201
- public isEmf : boolean = false;
202
- /**
203
- * Check whether it is an `emf plus` call.
204
- * @default false
205
- * @private
206
- */
207
- public isEmfPlus : boolean = false;
208
- /**
209
- * Check whether it is in `base line format`.
210
- * @default true
211
- * @private
212
- */
213
- public isBaselineFormat : boolean = true;
214
- /**
215
- * Emf Text `Scaling Factor`.
216
- * @private
217
- */
218
- public emfScalingFactor : SizeF = new SizeF(0, 0);
219
- /**
220
- * Internal variable to store `layout result` after drawing string.
221
- * @private
222
- */
223
- private pdfStringLayoutResult : PdfStringLayoutResult;
224
- /**
225
- * Internal variable to store `layer` on which this graphics lays.
226
- * @private
227
- */
228
- private pageLayer : PdfPageLayer;
229
- /**
230
- * To check whether the `last color space` of document and garphics is saved.
231
- * @private
232
- */
233
- private colorSpaceChanged : boolean = false;
234
- /**
235
- * Media box upper right `bound`.
236
- * @hidden
237
- * @private
238
- */
239
- private internalMediaBoxUpperRightBound : number;
240
- /**
241
- * Holds instance of PdfArray as `cropBox`.
242
- * @private
243
- */
244
- public cropBox : PdfArray;
245
- /**
246
- * Checks whether the object is `transparencyObject`.
247
- * @hidden
248
- * @private
249
- */
250
- private static transparencyObject : boolean = false;
251
- /**
252
- * Stores an instance of `DictionaryProperties`.
253
- * @private
254
- */
255
- private dictionaryProperties : DictionaryProperties = new DictionaryProperties();
256
- /**
257
- * `last document colorspace`.
258
- * @hidden
259
- * @private
260
- */
261
- private lastDocumentCS : PdfColorSpace;
262
- /**
263
- * `last graphics's colorspace`.
264
- * @hidden
265
- * @private
266
- */
267
- private lastGraphicsCS : PdfColorSpace;
268
- /**
269
- * Checks whether the x co-ordinate is need to set as client size or not.
270
- * @hidden
271
- * @private
272
- */
273
- private isOverloadWithPosition : boolean = false;
274
- /**
275
- * Checks whether the x co-ordinate is need to set as client size or not.
276
- * @hidden
277
- * @private
278
- */
279
- private isPointOverload : boolean = false;
280
- /**
281
- * Current colorspaces.
282
- * @hidden
283
- * @private
284
- */
285
- private currentColorSpaces : string[] = ['RGB', 'CMYK', 'GrayScale', 'Indexed'];
286
- /**
287
- * Checks the current image `is optimized` or not.
288
- * @default false.
289
- * @private
290
- */
291
- public isImageOptimized : boolean = false;
292
- /**
293
- * Returns the `current graphics state`.
294
- * @private
295
- */
296
- private gState : PdfGraphicsState;
297
- /**
298
- * Stores the `graphics states`.
299
- * @private
300
- */
301
- private graphicsState : PdfGraphicsState[] = [];
302
- /**
303
- * Stores the `trasparencies`.
304
- * @private
305
- */
306
- private trasparencies : TemporaryDictionary<TransparencyData, PdfTransparency>;
307
- /**
308
- * Indicates whether the object `had trasparency`.
309
- * @default false
310
- * @private
311
- */
312
- private istransparencySet : boolean = false;
313
- /**
314
- * Stores the instance of `PdfAutomaticFieldInfoCollection` class .
315
- * @default null
316
- * @private
317
- */
318
- private internalAutomaticFields : PdfAutomaticFieldInfoCollection = null;
319
- /**
320
- * Stores shift value for draw string with `PointF` overload.
321
- * @private
322
- * @hidden
323
- */
324
- private shift : number;
325
- /**
326
- * Stores the index of the start line that should draw with in the next page.
327
- * @private
328
- */
329
- private startCutIndex : number = -1;
330
- private _pathPoints : PointF[];
331
- private _pathTypes : number[];
332
- // Properties
333
- /**
334
- * Returns the `result` after drawing string.
335
- * @private
336
- */
337
- public get stringLayoutResult() : PdfStringLayoutResult {
338
- return this.pdfStringLayoutResult;
339
- }
340
- /**
341
- * Gets the `size` of the canvas.
342
- * @private
343
- */
344
- public get size() : SizeF {
345
- return this.canvasSize;
346
- }
347
- /**
348
- * Gets and Sets the value of `MediaBox upper right bound`.
349
- * @private
350
- */
351
- public get mediaBoxUpperRightBound() : number {
352
- if (typeof this.internalMediaBoxUpperRightBound === 'undefined') {
353
- this.internalMediaBoxUpperRightBound = 0;
354
- }
355
- return this.internalMediaBoxUpperRightBound;
356
- }
357
- public set mediaBoxUpperRightBound(value : number) {
358
- this.internalMediaBoxUpperRightBound = value;
359
- }
360
- /**
361
- * Gets the `size` of the canvas reduced by margins and page templates.
362
- * @private
363
- */
364
- public get clientSize() : SizeF {
365
- return new SizeF(this.clipBounds.width, this.clipBounds.height);
366
- }
367
- /**
368
- * Gets or sets the current `color space` of the document
369
- * @private
370
- */
371
- public get colorSpace() : PdfColorSpace {
372
- return this.currentColorSpace;
373
- }
374
- public set colorSpace(value : PdfColorSpace) {
375
- this.currentColorSpace = value;
376
- }
377
- /**
378
- * Gets the `stream writer`.
379
- * @private
380
- */
381
- public get streamWriter() : PdfStreamWriter {
382
- return this.pdfStreamWriter;
383
- }
384
- /**
385
- * Gets the `transformation matrix` reflecting current transformation.
386
- * @private
387
- */
388
- public get matrix() : PdfTransformationMatrix {
389
- if (this.transformationMatrix == null) {
390
- this.transformationMatrix = new PdfTransformationMatrix();
391
- }
392
- return this.transformationMatrix;
393
- }
394
- /**
395
- * Gets the `layer` for the graphics, if exists.
396
- * @private
397
- */
398
- public get layer() : PdfPageLayer {
399
- return this.pageLayer;
400
- }
401
- /**
402
- * Gets the `page` for this graphics, if exists.
403
- * @private
404
- */
405
- public get page() : PdfPageBase {
406
- return this.pageLayer.page;
407
- }
408
- public get automaticFields() : PdfAutomaticFieldInfoCollection {
409
- if (this.internalAutomaticFields == null || typeof this.internalAutomaticFields === 'undefined') {
410
- this.internalAutomaticFields = new PdfAutomaticFieldInfoCollection();
411
- }
412
- return this.internalAutomaticFields;
413
- }
414
- /**
415
- * Initializes a new instance of the `PdfGraphics` class.
416
- * @private
417
- */
418
- public constructor(size : SizeF, resources : GetResourceEventHandler, writer : PdfStreamWriter)
419
- /**
420
- * Initializes a new instance of the `PdfGraphics` class.
421
- * @private
422
- */
423
- public constructor(size : SizeF, resources : GetResourceEventHandler, stream : PdfStream)
424
- public constructor(arg1 : SizeF, arg2 : GetResourceEventHandler, arg3 : PdfStream | PdfStreamWriter) {
425
- this.getResources = arg2 as GetResourceEventHandler;
426
- this.canvasSize = arg1;
427
- if (arg3 instanceof PdfStreamWriter) {
428
- this.pdfStreamWriter = arg3;
429
- } else {
430
- this.pdfStreamWriter = new PdfStreamWriter(arg3);
431
- }
432
- this.initialize();
433
- }
434
- //Implementation
435
- /**
436
- * `Initializes` this instance.
437
- * @private
438
- */
439
- public initialize() : void {
440
- this.bStateSaved = false;
441
- this.currentPen = null;
442
- this.currentBrush = null;
443
- this.currentFont = null;
444
- this.currentColorSpace = PdfColorSpace.Rgb;
445
- this.bCSInitialized = false;
446
- this.transformationMatrix = null;
447
- this.previousTextRenderingMode = <TextRenderingMode>(-1); //.Fill;
448
- this.previousCharacterSpacing = -1.0;
449
- this.previousWordSpacing = -1.0;
450
- this.previousTextScaling = -100.0;
451
- // this.m_trasparencies = null;
452
- this.currentStringFormat = null;
453
- this.clipBounds = new RectangleF(new PointF(0, 0), this.size);
454
- this.getResources.getResources().requireProcedureSet(this.procedureSets.pdf);
455
- }
456
- // Public methods
457
- /**
458
- * `Draw the template`.
459
- * @private
460
- */
461
- public drawPdfTemplate(template : PdfTemplate, location : PointF) : void
462
- public drawPdfTemplate(template : PdfTemplate, location : PointF, size : SizeF) : void
463
- public drawPdfTemplate(template : PdfTemplate, location : PointF, size ?: SizeF) : void {
464
- if (typeof size === 'undefined') {
465
- if (template == null) {
466
- throw Error('ArgumentNullException-template');
467
- }
468
- this.drawPdfTemplate(template, location, template.size);
469
- } else {
470
- // let crossTable : PdfCrossTable = null;
471
- // if (this.pageLayer != null) {
472
- // crossTable = (this.page as PdfPage).section.parentDocument.crossTable;
473
- // }
474
- if (template == null) {
475
- throw Error('ArgumentNullException-template');
476
- }
477
-
478
- let scaleX : number = (template.width > 0) ? size.width / template.width : 1;
479
- let scaleY : number = (template.height > 0) ? size.height / template.height : 1;
480
- let bNeedScale : boolean = !(scaleX === 1 && scaleY === 1);
481
- // Save state.
482
- let state : PdfGraphicsState = this.save();
483
- // Take into consideration that rect location is bottom/left.
484
- let matrix : PdfTransformationMatrix = new PdfTransformationMatrix();
485
- if (this.pageLayer != null) {
486
- this.getTranslateTransform(location.x, location.y + size.height, matrix);
487
- }
488
- if (bNeedScale) {
489
- this.getScaleTransform(scaleX, scaleY, matrix);
490
- }
491
- this.pdfStreamWriter.modifyCtm(matrix);
492
- // Output template.
493
- let resources : PdfResources = this.getResources.getResources();
494
- let name : PdfName = resources.getName(template);
495
- this.pdfStreamWriter.executeObject(name);
496
- // Restore state.
497
- this.restore(state);
498
- //Transfer automatic fields from template.
499
- let g : PdfGraphics = template.graphics;
500
- if (g != null) {
501
- for (let index : number = 0; index < g.automaticFields.automaticFields.length; index++) {
502
- let fieldInfo : PdfAutomaticFieldInfo = g.automaticFields.automaticFields[index] as PdfAutomaticFieldInfo;
503
- let newLocation : PointF = new PointF(fieldInfo.location.x + location.x, fieldInfo.location.y + location.y);
504
- let scalingX : number = template.size.width == 0 ? 0 : size.width / template.size.width;
505
- let scalingY : number = template.size.height == 0 ? 0 : size.height / template.size.height;
506
- this.automaticFields.add(new PdfAutomaticFieldInfo(fieldInfo.field, newLocation, scalingX, scalingY));
507
- this.page.dictionary.modify();
508
- }
509
- }
510
- this.getResources.getResources().requireProcedureSet(this.procedureSets.imageB);
511
- this.getResources.getResources().requireProcedureSet(this.procedureSets.imageC);
512
- this.getResources.getResources().requireProcedureSet(this.procedureSets.imageI);
513
- this.getResources.getResources().requireProcedureSet(this.procedureSets.text);
514
- }
515
- }
516
- // DrawString overloads
517
- /**
518
- * `Draws the specified text` at the specified location and size with string format.
519
- * ```typescript
520
- * // create a new PDF document
521
- * let document : PdfDocument = new PdfDocument();
522
- * // add a pages to the document
523
- * let page1 : PdfPage = document.pages.add();
524
- * // set font
525
- * let font : PdfStandardFont = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
526
- * // set pen
527
- * let pen : PdfPen = new PdfPen(new PdfColor(255, 0, 0));
528
- * // set brush
529
- * let brush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(0, 0, 0));
530
- * // set rectangle bounds
531
- * let rectangle : RectangleF = new RectangleF({x : 10, y : 10}, {width : 200, height : 200});
532
- * // set the format for string
533
- * let stringFormat : PdfStringFormat = new PdfStringFormat();
534
- * // set the text alignment
535
- * stringFormat.alignment = PdfTextAlignment.Center;
536
- * // set the vertical alignment
537
- * stringFormat.lineAlignment = PdfVerticalAlignment.Middle;
538
- * //
539
- * // draw the text
540
- * page1.graphics.drawString('Hello World', font, pen, brush, rectangle, stringFormat);
541
- * //
542
- * // save the document
543
- * document.save('output.pdf');
544
- * // destroy the document
545
- * document.destroy();
546
- * ```
547
- * @param s Input text.
548
- * @param font Font of the text.
549
- * @param pen Color of the text.
550
- * @param brush Color of the text.
551
- * @param layoutRectangle RectangleF structure that specifies the bounds of the drawn text.
552
- * @param format String formatting information.
553
- */
554
- public drawString(s : string, font : PdfFont, pen : PdfPen, brush : PdfBrush, x : number, y : number, format : PdfStringFormat) : void
555
- public drawString(s : string, font : PdfFont, pen : PdfPen, brush : PdfBrush, x : number, y : number, width : number, height : number, format : PdfStringFormat) : void
556
- /**
557
- * @public
558
- */
559
- public drawString(arg1 : string, arg2 : PdfFont, arg3 : PdfPen, arg4 : PdfBrush, arg5 : number, arg6 : number, arg7 : number|PdfStringFormat, arg8 ?: number, arg9 ?: PdfStringFormat) : void {
560
- if (typeof arg1 === 'string' && arg2 instanceof PdfFont && (arg3 instanceof PdfPen || arg3 === null) && (arg4 instanceof PdfBrush || arg4 === null) && typeof arg5 === 'number' && typeof arg6 === 'number' && (arg7 instanceof PdfStringFormat || arg7 === null) && typeof arg8 === 'undefined') {
561
- this.isOverloadWithPosition = true;
562
- this.drawString(arg1, arg2, arg3, arg4, arg5, arg6, (this.clientSize.width - arg5), 0, arg7 as PdfStringFormat);
563
- } else {
564
- let temparg3 : PdfPen = arg3 as PdfPen;
565
- let temparg4 : PdfBrush = arg4 as PdfBrush;
566
- let temparg5 : number = arg5 as number;
567
- let temparg6 : number = arg6 as number;
568
- let temparg7 : number = arg7 as number;
569
- let temparg8 : number = arg8 as number;
570
- let temparg9 : PdfStringFormat = arg9 as PdfStringFormat;
571
- let layouter : PdfStringLayouter = new PdfStringLayouter();
572
- let result : PdfStringLayoutResult = layouter.layout(arg1, arg2, temparg9, new SizeF(temparg7, temparg8), this.isOverloadWithPosition, this.clientSize);
573
- if (!result.empty) {
574
- let rect : RectangleF = this.checkCorrectLayoutRectangle(result.actualSize, temparg5, temparg6, temparg9);
575
- if (temparg7 <= 0) {
576
- temparg5 = rect.x;
577
- temparg7 = rect.width;
578
- }
579
- if (temparg8 <= 0) {
580
- temparg6 = rect.y;
581
- temparg8 = rect.height;
582
- }
583
- this.drawStringLayoutResult(result, arg2, temparg3, temparg4, new RectangleF(temparg5, temparg6, temparg7, temparg8), temparg9);
584
- this.isEmfTextScaled = false;
585
- this.emfScalingFactor = new SizeF(0, 0);
586
- }
587
- this.getResources.getResources().requireProcedureSet(this.procedureSets.text);
588
- this.isNormalRender = true;
589
- this.pdfStringLayoutResult = result;
590
- this.isUseFontSize = false;
591
- }
592
- }
593
- //DrawLine overloads
594
- /**
595
- * `Draws a line` connecting the two points specified by the coordinate pairs.
596
- * ```typescript
597
- * // create a new PDF document
598
- * let document : PdfDocument = new PdfDocument();
599
- * // create a new page
600
- * let page1 : PdfPage = document.pages.add();
601
- * //
602
- * // draw the line
603
- * page1.graphics.drawLine(new PdfPen(new PdfColor(0, 0, 255)), new PointF(10, 20), new PointF(100, 200));
604
- * //
605
- * // save the document.
606
- * document.save('output.pdf');
607
- * // destroy the document
608
- * document.destroy();
609
- * ```
610
- * @param pen Color of the line.
611
- * @param point1 PointF structure that represents the first point to connect.
612
- * @param point2 PointF structure that represents the second point to connect.
613
- */
614
- public drawLine(pen : PdfPen, point1 : PointF, point2 : PointF) : void
615
- /**
616
- * `Draws a line` connecting the two points specified by the coordinate pairs.
617
- * ```typescript
618
- * // create a new PDF document
619
- * let document : PdfDocument = new PdfDocument();
620
- * // create a new page
621
- * let page1 : PdfPage = document.pages.add();
622
- * //
623
- * // draw the line
624
- * page1.graphics.drawLine(new PdfPen(new PdfColor(0, 0, 255)), 10, 20, 100, 200);
625
- * //
626
- * // save the document.
627
- * document.save('output.pdf');
628
- * // destroy the document
629
- * document.destroy();
630
- * ```
631
- * @param pen Color of the line.
632
- * @param x1 The x-coordinate of the first point.
633
- * @param y1 The y-coordinate of the first point.
634
- * @param x2 The x-coordinate of the second point.
635
- * @param y2 The y-coordinate of the second point.
636
- */
637
- public drawLine(pen : PdfPen, x1 : number, y1 : number, x2 : number, y2 : number) : void
638
- public drawLine(arg1 : PdfPen, arg2 : number | PointF, arg3 : number | PointF, arg4 ?: number, arg5 ?: number) : void {
639
- if (arg2 instanceof PointF) {
640
- let temparg2 : PointF = arg2 as PointF;
641
- let temparg3 : PointF = arg3 as PointF;
642
- this.drawLine(arg1, temparg2.x, temparg2.y, temparg3.x, temparg3.y);
643
- } else {
644
- let temparg2 : number = arg2 as number;
645
- let temparg3 : number = arg3 as number;
646
- let temparg4 : number = arg4 as number;
647
- let temparg5 : number = arg5 as number;
648
- this.stateControl(arg1, null, null);
649
- let sw : PdfStreamWriter = this.streamWriter;
650
- sw.beginPath(temparg2, temparg3);
651
- sw.appendLineSegment(temparg4, temparg5);
652
- sw.strokePath();
653
- this.getResources.getResources().requireProcedureSet(this.procedureSets.pdf);
654
- }
655
- }
656
-
657
- // DrawRectangle overloads
658
- /**
659
- * `Draws a rectangle` specified by a pen, a coordinate pair, a width, and a height.
660
- * ```typescript
661
- * // create a new PDF document.
662
- * let document : PdfDocument = new PdfDocument();
663
- * // create a new page
664
- * let page1 : PdfPage = document.pages.add();
665
- * // create pen for draw rectangle
666
- * let pen : PdfPen = new PdfPen(new PdfColor(238, 130, 238));
667
- * //
668
- * // draw rectangle
669
- * page1.graphics.drawRectangle(pen, 10, 10, 50, 100);
670
- * //
671
- * // save the document
672
- * document.save('output.pdf');
673
- * // destroy the document
674
- * document.destroy();
675
- * ```
676
- * @param pen Color of the rectangle.
677
- * @param x The x-coordinate of the upper-left corner of the rectangle to draw.
678
- * @param y The y-coordinate of the upper-left corner of the rectangle to draw.
679
- * @param width Width of the rectangle to draw.
680
- * @param height Height of the rectangle to draw.
681
- */
682
- public drawRectangle(pen : PdfPen, x : number, y : number, width : number, height : number) : void
683
- /**
684
- * `Draws a rectangle` specified by a brush, coordinate pair, a width, and a height.
685
- * ```typescript
686
- * // create a new PDF document.
687
- * let document : PdfDocument = new PdfDocument();
688
- * // create a new page
689
- * let page1 : PdfPage = document.pages.add();
690
- * // create brush for draw rectangle
691
- * let brush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(238, 130, 238));
692
- * //
693
- * // draw rectangle
694
- * page1.graphics.drawRectangle(brush, 10, 10, 50, 100);
695
- * //
696
- * // save the document
697
- * document.save('output.pdf');
698
- * // destroy the document
699
- * document.destroy();
700
- * ```
701
- * @param brush Color of the rectangle.
702
- * @param x The x-coordinate of the upper-left corner of the rectangle to draw.
703
- * @param y The y-coordinate of the upper-left corner of the rectangle to draw.
704
- * @param width Width of the rectangle to draw.
705
- * @param height Height of the rectangle to draw.
706
- */
707
- public drawRectangle(brush : PdfBrush, x : number, y : number, width : number, height : number) : void
708
- /**
709
- * `Draws a rectangle` specified by a pen, a coordinate pair, a width, and a height.
710
- * ```typescript
711
- * // create a new PDF document.
712
- * let document : PdfDocument = new PdfDocument();
713
- * // create a new page
714
- * let page1 : PdfPage = document.pages.add();
715
- * // create brush for draw rectangle
716
- * let brush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(238, 130, 238));
717
- * // set pen
718
- * let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
719
- * //
720
- * // draw rectangle
721
- * page1.graphics.drawRectangle(pen, brush, 10, 10, 50, 100);
722
- * //
723
- * // save the document
724
- * document.save('output.pdf');
725
- * // destroy the document
726
- * document.destroy();
727
- * ```
728
- * @param pen A Pen that determines the color, width, and style of the rectangle.
729
- * @param brush Color of the rectangle.
730
- * @param x The x-coordinate of the upper-left corner of the rectangle to draw.
731
- * @param y The y-coordinate of the upper-left corner of the rectangle to draw.
732
- * @param width Width of the rectangle to draw.
733
- * @param height Height of the rectangle to draw.
734
- */
735
- public drawRectangle(pen : PdfPen, brush : PdfBrush, x : number, y : number, width : number, height : number) : void
736
- public drawRectangle(arg1 : PdfPen|PdfBrush, arg2 : PdfBrush|number, arg3 : number, arg4 : number, arg5 : number, arg6 ?: number) : void {
737
- if ( arg1 instanceof PdfPen && typeof arg2 === 'number' ) {
738
- let temparg3 : number = arg3 as number;
739
- this.drawRectangle(arg1, null, arg2, temparg3, arg4, arg5);
740
- } else if ( arg1 instanceof PdfBrush && typeof arg2 === 'number' ) {
741
- let temparg3 : number = arg3 as number;
742
- this.drawRectangle(null, arg1, arg2, temparg3, arg4, arg5);
743
- } else {
744
- let temparg3 : number = arg3 as number;
745
- let temparg4 : number = arg4 as number;
746
- let temparg5 : number = arg5 as number;
747
- let temparg6 : number = arg6 as number;
748
- if ((arg2 instanceof PdfTilingBrush)) {
749
- this.bCSInitialized = false;
750
- let xOffset: number = (this.matrix.matrix.offsetX + temparg3);
751
- let yOffset: number;
752
- if (((this.layer != null) && (this.layer.page != null))) {
753
- yOffset = ((this.layer.page.size.height - this.matrix.matrix.offsetY) + temparg4);
754
- } else {
755
- yOffset = ((this.clientSize.height - this.matrix.matrix.offsetY) + temparg4);
756
- }
757
- (<PdfTilingBrush>(arg2)).location = new PointF(xOffset, yOffset);
758
- (<PdfTilingBrush>(arg2)).graphics.colorSpace = this.colorSpace;
759
- } else if ((arg2 instanceof PdfGradientBrush)) {
760
- (arg2 as PdfGradientBrush).colorSpace = this.colorSpace;
761
- }
762
- if (arg2 instanceof PdfSolidBrush && (<PdfSolidBrush>arg2).color.isEmpty) {
763
- arg2 = null;
764
- }
765
- let temparg1 : PdfPen = <PdfPen>arg1;
766
- let temparg2 : PdfBrush = <PdfBrush>arg2;
767
- this.stateControl(temparg1, temparg2, null);
768
- this.streamWriter.appendRectangle(temparg3, temparg4, temparg5, temparg6);
769
- this.drawPathHelper(temparg1, temparg2, false);
770
- }
771
- }
772
- /**
773
- * Draw rounded rectangle specified by a brush, pen, coordinate pair, a width, a height and a radius.
774
- * ```typescript
775
- * // Create a new PDF document.
776
- * let document : PdfDocument = new PdfDocument();
777
- * // Create a new page
778
- * let page : PdfPage = document.pages.add();
779
- * // Create brush for draw rectangle
780
- * let brush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(238, 130, 238));
781
- * // Create a new PDF pen
782
- * let pen: PdfPen = new PdfPen(new PdfColor(255, 0, 0), 1);
783
- * // Draw rounded rectangle
784
- * page.graphics.drawRoundedRectangle(pen, brush, 20, 20, 100, 50, 5);
785
- * // save the document
786
- * document.save('output.pdf');
787
- * // destroy the document
788
- * document.destroy();
789
- * ```
790
- * @param pen Stoke color of the rectangle.
791
- * @param brush Fill color of the rectangle.
792
- * @param x The x-coordinate of the upper-left corner of the rectangle to draw.
793
- * @param y The y-coordinate of the upper-left corner of the rectangle to draw.
794
- * @param width Width of the rectangle to draw.
795
- * @param height Height of the rectangle to draw.
796
- * @param radius Radius of the arcs to draw.
797
- */
798
- drawRoundedRectangle(pen: PdfPen, brush: PdfBrush, x: number, y: number, width: number, height: number, radius: number): void {
799
- if (pen === null) {
800
- throw new Error('pen');
801
- }
802
- if (brush === null) {
803
- throw new Error('brush');
804
- }
805
- if (radius === 0) {
806
- this.drawRectangle(pen, brush, x, y, width, height);
807
- } else {
808
- const bounds: number[] = [x, y, width, height];
809
- const diameter: number = radius * 2;
810
- const size: number[] = [diameter, diameter];
811
- const arc: number[] = [bounds[0], bounds[1], size[0], size[1]];
812
- this._pathPoints = [];
813
- this._pathTypes = [];
814
- let startFigure: boolean = true;
815
- startFigure = this._addArc(arc[0], arc[1], arc[2], arc[3], 180, 90, startFigure);
816
- arc[0] = (bounds[0] + bounds[2]) - diameter;
817
- startFigure = this._addArc(arc[0], arc[1], arc[2], arc[3], 270, 90, startFigure);
818
- arc[1] = (bounds[1] + bounds[3]) - diameter;
819
- startFigure = this._addArc(arc[0], arc[1], arc[2], arc[3], 0, 90, startFigure);
820
- arc[0] = bounds[0];
821
- startFigure = this._addArc(arc[0], arc[1], arc[2], arc[3], 90, 90, startFigure);
822
- const index: number = this._pathPoints.length - 1;
823
- let type: PathPointType = (<PathPointType>((<number>(this._pathTypes[index]))));
824
- type = (type | PathPointType.CloseSubpath);
825
- this._pathTypes[index] = (<number>(type));
826
- this._drawPath(pen, brush, this._pathPoints, this._pathTypes, PdfFillMode.Alternate);
827
- this._pathPoints = [];
828
- this._pathTypes = [];
829
- }
830
- }
831
- private _addArc(x: number, y: number, width: number, height: number, startAngle: number, sweepAngle: number, startFigure: boolean): boolean {
832
- let points: number[] = this._getBezierArcPoints(x, y, (x + width), (y + height), startAngle, sweepAngle);
833
- for (let i : number = 0 ; i < points.length ; i = i + 8 ) {
834
- let point : number[] = [ points[i], points[i + 1], points[i + 2], points[i + 3], points[i + 4], points[i + 5], points[i + 6], points[i + 7]];
835
- startFigure = this._addArcPoints(point, PathPointType.Bezier3, startFigure);
836
- }
837
- return startFigure;
838
- }
839
- private _addArcPoints(points: number[], pointType: PathPointType, startFigure: boolean): boolean {
840
- for (let i: number = 0; i < points.length; i++) {
841
- let point: PointF = new PointF(points[i], points[(i + 1)]);
842
- if (i === 0) {
843
- if (this._pathPoints.length === 0 || startFigure) {
844
- this._addPoint(point, PathPointType.Start);
845
- startFigure = false;
846
- } else if (point.x !== this._getLastPoint().x || point.y !== this._getLastPoint().y) {
847
- this._addPoint(point, PathPointType.Line);
848
- }
849
- } else {
850
- this._addPoint(point, pointType);
851
- }
852
- i++;
853
- }
854
- return startFigure;
855
- }
856
- private _getLastPoint(): PointF {
857
- let lastPoint: PointF = new PointF(0, 0);
858
- const count: number = this._pathPoints.length;
859
- if (count > 0) {
860
- lastPoint.x = this._pathPoints[(count - 1)].x;
861
- lastPoint.y = this._pathPoints[(count - 1)].y;
862
- }
863
- return lastPoint;
864
- }
865
- private _addPoint(point: PointF, type: PathPointType): void {
866
- this._pathPoints.push(point);
867
- this._pathTypes.push(<number>type);
868
- }
869
- private _getBezierArcPoints(x1: number, y1: number, x2: number, y2: number, s1: number, e1: number): number[] {
870
- if ((x1 > x2)) {
871
- let tmp: number;
872
- tmp = x1;
873
- x1 = x2;
874
- x2 = tmp;
875
- }
876
- if ((y2 > y1)) {
877
- let tmp: number;
878
- tmp = y1;
879
- y1 = y2;
880
- y2 = tmp;
881
- }
882
- let fragAngle: number;
883
- let numFragments: number;
884
- if ((Math.abs(e1) <= 90)) {
885
- fragAngle = e1;
886
- numFragments = 1;
887
- } else {
888
- numFragments = (<number>(Math.ceil((Math.abs(e1) / 90))));
889
- fragAngle = (e1 / numFragments);
890
- }
891
- let xcen: number = ((x1 + x2) / 2);
892
- let ycen: number = ((y1 + y2) / 2);
893
- let rx: number = ((x2 - x1) / 2);
894
- let ry: number = ((y2 - y1) / 2);
895
- let halfAng: number = (<number>((fragAngle * (Math.PI / 360))));
896
- let kappa: number = (<number>(Math.abs(4.0 / 3.0 * (1.0 - Math.cos(halfAng)) / Math.sin(halfAng))));
897
- let pointList: number[] = [];
898
- for (let i: number = 0; (i < numFragments); i++) {
899
- let theta0: number = (<number>(((s1 + (i * fragAngle)) * (Math.PI / 180))));
900
- let theta1: number = (<number>(((s1 + ((i + 1) * fragAngle)) * (Math.PI / 180))));
901
- let cos0: number = (<number>(Math.cos(theta0)));
902
- let cos1: number = (<number>(Math.cos(theta1)));
903
- let sin0: number = (<number>(Math.sin(theta0)));
904
- let sin1: number = (<number>(Math.sin(theta1)));
905
- if ((fragAngle > 0)) {
906
- pointList.push((xcen + (rx * cos0)), (ycen - (ry * sin0)), (xcen + (rx * (cos0 - (kappa * sin0)))), (ycen - (ry * (sin0 + (kappa * cos0)))), (xcen + (rx * (cos1 + (kappa * sin1)))), (ycen - (ry * (sin1 - (kappa * cos1)))), (xcen + (rx * cos1)), (ycen - (ry * sin1)));
907
- } else {
908
- pointList.push((xcen + (rx * cos0)), (ycen - (ry * sin0)), (xcen + (rx * (cos0 + (kappa * sin0)))), (ycen - (ry * (sin0 - (kappa * cos0)))), (xcen + (rx * (cos1 - (kappa * sin1)))), (ycen - (ry * (sin1 + (kappa * cos1)))), (xcen + (rx * cos1)), (ycen - (ry * sin1)));
909
- }
910
- }
911
- return pointList;
912
- }
913
- /**
914
- * `Draws the path`.
915
- * @private
916
- */
917
- private drawPathHelper(pen : PdfPen, brush : PdfBrush, needClosing : boolean) : void
918
- /**
919
- * `Draws the path`.
920
- * @private
921
- */
922
- private drawPathHelper(pen : PdfPen, brush : PdfBrush, fillMode : PdfFillMode, needClosing : boolean) : void
923
- private drawPathHelper(arg1 : PdfPen, arg2 : PdfBrush, arg3 : PdfFillMode|boolean, arg4 ?: boolean) : void {
924
- if (typeof arg3 === 'boolean') {
925
- let temparg3 : boolean = arg3 as boolean;
926
- this.drawPathHelper(arg1, arg2, PdfFillMode.Winding, temparg3);
927
- } else {
928
- let temparg3 : PdfFillMode = arg3 as PdfFillMode;
929
- let temparg4 : boolean = arg4 as boolean;
930
- let isPen : boolean = arg1 != null;
931
- let isBrush : boolean = arg2 != null;
932
- let isEvenOdd : boolean = (temparg3 === PdfFillMode.Alternate);
933
- if (isPen && isBrush) {
934
- this.streamWriter.fillStrokePath(isEvenOdd);
935
- } else if (!isPen && !isBrush) {
936
- this.streamWriter.endPath();
937
- } else if (isPen) {
938
- this.streamWriter.strokePath();
939
- } else {
940
- this.streamWriter.fillPath(isEvenOdd);
941
- }
942
- }
943
- }
944
- //DrawImage overloads
945
- /**
946
- * `Draws the specified image`, using its original physical size, at the location specified by a coordinate pair.
947
- * ```typescript
948
- * // create a new PDF document.
949
- * let document : PdfDocument = new PdfDocument();
950
- * // add a page to the document.
951
- * let page1 : PdfPage = document.pages.add();
952
- * // base64 string of an image
953
- * let imageString : string = '/9j/3+2w7em7HzY/KiijFw … 1OEYRUYrQ45yc5OUtz/9k=';
954
- * // load the image from the base64 string of original image.
955
- * let image : PdfBitmap = new PdfBitmap(imageString);
956
- * //
957
- * // draw the image
958
- * page1.graphics.drawImage(image, 10, 10);
959
- * //
960
- * // save the document.
961
- * document.save('output.pdf');
962
- * // destroy the document
963
- * document.destroy();
964
- * ```
965
- * @param image PdfImage to draw.
966
- * @param x The x-coordinate of the upper-left corner of the drawn image.
967
- * @param y The y-coordinate of the upper-left corner of the drawn image.
968
- */
969
- public drawImage(image : PdfImage, x : number, y : number) : void
970
- /**
971
- * `Draws the specified image`, using its original physical size, at the location specified by a coordinate pair.
972
- * ```typescript
973
- * // create a new PDF document.
974
- * let document : PdfDocument = new PdfDocument();
975
- * // add a page to the document.
976
- * let page1 : PdfPage = document.pages.add();
977
- * // base64 string of an image
978
- * let imageString : string = '/9j/3+2w7em7HzY/KiijFw … 1OEYRUYrQ45yc5OUtz/9k=';
979
- * // load the image from the base64 string of original image.
980
- * let image : PdfBitmap = new PdfBitmap(imageString);
981
- * //
982
- * // draw the image
983
- * page1.graphics.drawImage(image, 0, 0, 100, 100);
984
- * //
985
- * // save the document.
986
- * document.save('output.pdf');
987
- * // destroy the document
988
- * document.destroy();
989
- * ```
990
- * @param image PdfImage to draw.
991
- * @param x The x-coordinate of the upper-left corner of the drawn image.
992
- * @param y The y-coordinate of the upper-left corner of the drawn image.
993
- * @param width Width of the drawn image.
994
- * @param height Height of the drawn image.
995
- */
996
- public drawImage(image : PdfImage, x : number, y : number, width : number, height : number) : void
997
- public drawImage(arg1 : PdfImage, arg2 : number, arg3 : number, arg4 ?: number, arg5 ?: number) : void {
998
- if (typeof arg2 === 'number' && typeof arg3 === 'number' && typeof arg4 === 'undefined') {
999
- let size : SizeF = arg1.physicalDimension;
1000
- this.drawImage(arg1, arg2, arg3, size.width, size.height);
1001
- } else {
1002
- let temparg2 : number = arg2 as number;
1003
- let temparg3 : number = arg3 as number;
1004
- let temparg4 : number = arg4 as number;
1005
- let temparg5 : number = arg5 as number;
1006
- arg1.save();
1007
- let matrix : PdfTransformationMatrix = new PdfTransformationMatrix();
1008
- this.getTranslateTransform(temparg2, (temparg3 + temparg5), matrix);
1009
- this.getScaleTransform(arg4, arg5, matrix);
1010
- this.pdfStreamWriter.write('q');
1011
- this.pdfStreamWriter.modifyCtm(matrix);
1012
- // Output template.
1013
- let resources : PdfResources = this.getResources.getResources();
1014
- if (typeof this.pageLayer !== 'undefined' && (this.page as PdfPage) != null) {
1015
- resources.document = (this.page as PdfPage).document;
1016
- }
1017
- let name : PdfName = resources.getName(arg1);
1018
- if (typeof this.pageLayer !== 'undefined') {
1019
- this.page.setResources(resources);
1020
- }
1021
- this.pdfStreamWriter.executeObject(name);
1022
- this.pdfStreamWriter.write(Operators.restoreState);
1023
- this.pdfStreamWriter.write(Operators.newLine);
1024
- let resource : PdfResources = this.getResources.getResources();
1025
- resource.requireProcedureSet(this.procedureSets.imageB);
1026
- resource.requireProcedureSet(this.procedureSets.imageC);
1027
- resource.requireProcedureSet(this.procedureSets.imageI);
1028
- resource.requireProcedureSet(this.procedureSets.text);
1029
- }
1030
- }
1031
- //Implementation
1032
- /**
1033
- * Returns `bounds` of the line info.
1034
- * @private
1035
- */
1036
- public getLineBounds(lineIndex : number, result : PdfStringLayoutResult, font : PdfFont, layoutRectangle : RectangleF, format : PdfStringFormat) : RectangleF {
1037
- let bounds : RectangleF;
1038
- if (!result.empty && lineIndex < result.lineCount && lineIndex >= 0) {
1039
- let line : LineInfo = result.lines[lineIndex];
1040
- let vShift : number = this.getTextVerticalAlignShift(result.actualSize.height, layoutRectangle.height, format);
1041
- let y : number = vShift + layoutRectangle.y + (result.lineHeight * lineIndex);
1042
- let lineWidth : number = line.width;
1043
- let hShift : number = this.getHorizontalAlignShift(lineWidth, layoutRectangle.width, format);
1044
- let lineIndent : number = this.getLineIndent(line, format, layoutRectangle, (lineIndex === 0));
1045
- hShift += (!this.rightToLeft(format)) ? lineIndent : 0;
1046
- let x : number = layoutRectangle.x + hShift;
1047
- let width : number = (!this.shouldJustify(line, layoutRectangle.width, format)) ? lineWidth - lineIndent : layoutRectangle.width - lineIndent;
1048
- let height : number = result.lineHeight;
1049
- bounds = new RectangleF(x, y, width, height);
1050
- } else {
1051
- bounds = new RectangleF(0, 0, 0, 0);
1052
- }
1053
- return bounds;
1054
- }
1055
- /**
1056
- * Creates `lay outed rectangle` depending on the text settings.
1057
- * @private
1058
- */
1059
- public checkCorrectLayoutRectangle(textSize : SizeF, x : number, y : number, format : PdfStringFormat) : RectangleF {
1060
- let layoutedRectangle : RectangleF = new RectangleF(x, y, textSize.width, textSize.width);
1061
- if (format != null) {
1062
- switch (format.alignment) {
1063
- case PdfTextAlignment.Center:
1064
- layoutedRectangle.x -= layoutedRectangle.width / 2;
1065
- break;
1066
- case PdfTextAlignment.Right:
1067
- layoutedRectangle.x -= layoutedRectangle.width;
1068
- break;
1069
- }
1070
- switch (format.lineAlignment) {
1071
- case PdfVerticalAlignment.Middle:
1072
- layoutedRectangle.y -= layoutedRectangle.height / 2;
1073
- break;
1074
- case PdfVerticalAlignment.Bottom:
1075
- layoutedRectangle.y -= layoutedRectangle.height;
1076
- break;
1077
- }
1078
- }
1079
- return layoutedRectangle;
1080
- }
1081
- /**
1082
- * Sets the `layer` for the graphics.
1083
- * @private
1084
- */
1085
- public setLayer(layer : PdfPageLayer) : void {
1086
- this.pageLayer = layer;
1087
- let page : PdfPage = layer.page as PdfPage;
1088
- if (page != null && typeof page !== 'undefined') {
1089
- page.beginSave = this.pageSave;
1090
- }
1091
- }
1092
- /**
1093
- * Adding page number field before page saving.
1094
- * @private
1095
- */
1096
- public pageSave(page : PdfPage) : void {
1097
- if (page.graphics.automaticFields != null) {
1098
- for (let i : number = 0; i < page.graphics.automaticFields.automaticFields.length; i++) {
1099
- let fieldInfo : PdfAutomaticFieldInfo = page.graphics.automaticFields.automaticFields[i] as PdfAutomaticFieldInfo;
1100
- fieldInfo.field.performDraw(page.graphics, fieldInfo.location, fieldInfo.scalingX, fieldInfo.scalingY);
1101
- }
1102
- }
1103
- }
1104
- /**
1105
- * `Draws a layout result`.
1106
- * @private
1107
- */
1108
- public drawStringLayoutResult(result : PdfStringLayoutResult, font : PdfFont, pen : PdfPen, brush : PdfBrush, layoutRectangle : RectangleF, format : PdfStringFormat) : void {
1109
- if (!result.empty) {
1110
- this.applyStringSettings(font, pen, brush, format, layoutRectangle);
1111
- // Set text scaling
1112
- let textScaling : number = (format != null) ? format.horizontalScalingFactor : 100.0;
1113
- if (textScaling !== this.previousTextScaling && !this.isEmfTextScaled) {
1114
- this.pdfStreamWriter.setTextScaling(textScaling);
1115
- this.previousTextScaling = textScaling;
1116
- }
1117
- let height : number = (format == null || format.lineSpacing === 0) ? font.height : format.lineSpacing + font.height;
1118
- let subScript : boolean = (format != null && format.subSuperScript === PdfSubSuperScript.SubScript);
1119
- let shift : number = 0;
1120
- shift = (subScript) ? height - (font.height + font.metrics.getDescent(format)) : (height - font.metrics.getAscent(format));
1121
- this.shift = shift;
1122
- this.pdfStreamWriter.startNextLine(layoutRectangle.x, layoutRectangle.y - shift);
1123
- this.pdfStreamWriter.setLeading(+height);
1124
- let resultHeight : number = 0;
1125
- let remainingString : string = '';
1126
- for (let i : number = 0; i < result.lines.length; i++) {
1127
- resultHeight += result.lineHeight;
1128
- if ((layoutRectangle.y + resultHeight) > this.clientSize.height) {
1129
- this.startCutIndex = i;
1130
- break;
1131
- }
1132
- }
1133
- for (let j : number = this.startCutIndex; (j < result.lines.length && j >= 0); j++) {
1134
- remainingString += result.lines[j].text;
1135
- }
1136
- let bounds : RectangleF = new RectangleF(layoutRectangle.x, layoutRectangle.y, layoutRectangle.width, layoutRectangle.height);
1137
- this.drawLayoutResult(result, font, format, layoutRectangle);
1138
- this.underlineStrikeoutText(pen, brush, result, font, bounds, format);
1139
- this.isEmfPlus = false;
1140
- this.isUseFontSize = false;
1141
- if (this.startCutIndex !== -1) {
1142
- let page : PdfPage = this.getNextPage();
1143
- page.graphics.drawString(remainingString, font, pen, brush, layoutRectangle.x, 0, layoutRectangle.width, 0, format);
1144
- }
1145
- } else {
1146
- throw new Error('ArgumentNullException:result');
1147
- }
1148
- }
1149
- /**
1150
- * Gets the `next page`.
1151
- * @private
1152
- */
1153
- public getNextPage() : PdfPage {
1154
- let section : PdfSection = this.currentPage.section;
1155
- let nextPage : PdfPage = null;
1156
- let index : number = section.indexOf(this.currentPage);
1157
- if (index === section.count - 1) {
1158
- nextPage = (section.add() as PdfPage);
1159
- } else {
1160
- nextPage = (section.getPages()[index + 1] as PdfPage);
1161
- }
1162
- return nextPage;
1163
- }
1164
- /**
1165
- * `Sets the clipping` region of this Graphics to the rectangle specified by a RectangleF structure.
1166
- * ```typescript
1167
- * // create a new PDF document
1168
- * let document : PdfDocument = new PdfDocument();
1169
- * // create a new page
1170
- * let page1 : PdfPage = document.pages.add();
1171
- * // create PDF graphics for the page
1172
- * let graphics : PdfGraphics = page1.graphics;
1173
- * // set the font
1174
- * let font : PdfFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 20);
1175
- * // create black brush
1176
- * let blackBrush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(0, 0, 0));
1177
- * //
1178
- * // set clipping with rectangle bounds
1179
- * graphics.setClip(new RectangleF({x : 10, y : 80}, {width : 150 , height : 15}));
1180
- * //
1181
- * // draw the text after clipping
1182
- * graphics.drawString('Text after clipping', font, blackBrush, new PointF(10, 80));
1183
- * // save the document.
1184
- * document.save('output.pdf');
1185
- * // destroy the document
1186
- * document.destroy();
1187
- * ```
1188
- * @param rectangle RectangleF structure that represents the new clip region.
1189
- */
1190
- public setClip(rectangle : RectangleF) : void
1191
- /**
1192
- * `Sets the clipping` region of this Graphics to the result of the specified operation combining the current clip region and the rectangle specified by a RectangleF structure.
1193
- * @private
1194
- */
1195
- public setClip(rectangle : RectangleF, mode : PdfFillMode) : void
1196
- public setClip(rectangle : RectangleF, mode ?: PdfFillMode) : void {
1197
- if (typeof mode === 'undefined') {
1198
- this.setClip(rectangle, PdfFillMode.Winding);
1199
- } else {
1200
- this.pdfStreamWriter.appendRectangle(rectangle);
1201
- this.pdfStreamWriter.clipPath((mode === PdfFillMode.Alternate));
1202
- }
1203
- }
1204
- /**
1205
- * Applies all the `text settings`.
1206
- * @private
1207
- */
1208
- private applyStringSettings(font : PdfFont, pen : PdfPen, brush : PdfBrush, format : PdfStringFormat, bounds : RectangleF) : void {
1209
- if ( brush instanceof PdfTilingBrush) {
1210
- this.bCSInitialized = false;
1211
- (<PdfTilingBrush>brush).graphics.colorSpace = this.colorSpace;
1212
- } else if ((brush instanceof PdfGradientBrush)) {
1213
- this.bCSInitialized = false;
1214
- (<PdfGradientBrush>brush).colorSpace = this.colorSpace;
1215
- }
1216
- let setLineWidth : boolean = false;
1217
- let tm : TextRenderingMode = this.getTextRenderingMode(pen, brush, format);
1218
- this.stateControl(pen, brush, font, format);
1219
- this.pdfStreamWriter.beginText();
1220
- if ((tm) !== this.previousTextRenderingMode) {
1221
- this.pdfStreamWriter.setTextRenderingMode(tm);
1222
- this.previousTextRenderingMode = tm;
1223
- }
1224
- // Set character spacing.
1225
- let cs : number = (format != null) ? format.characterSpacing : 0;
1226
- if (cs !== this.previousCharacterSpacing && !this.isEmfTextScaled) {
1227
- this.pdfStreamWriter.setCharacterSpacing(cs);
1228
- this.previousCharacterSpacing = cs;
1229
- }
1230
- // Set word spacing.
1231
- // NOTE: it works only if the space code is equal to 32 (0x20).
1232
- let ws : number = (format != null) ? format.wordSpacing : 0;
1233
- if (ws !== this.previousWordSpacing) {
1234
- this.pdfStreamWriter.setWordSpacing(ws);
1235
- this.previousWordSpacing = ws;
1236
- }
1237
- }
1238
- /**
1239
- * Calculates `shift value` if the text is vertically aligned.
1240
- * @private
1241
- */
1242
- public getTextVerticalAlignShift(textHeight : number, boundsHeight : number, format : PdfStringFormat) : number {
1243
- let shift : number = 0;
1244
- if (boundsHeight >= 0 && format != null && format.lineAlignment !== PdfVerticalAlignment.Top) {
1245
- switch (format.lineAlignment) {
1246
- case PdfVerticalAlignment.Middle:
1247
- shift = (boundsHeight - textHeight) / 2;
1248
- break;
1249
- case PdfVerticalAlignment.Bottom:
1250
- shift = boundsHeight - textHeight;
1251
- break;
1252
- }
1253
- }
1254
- return shift;
1255
- }
1256
- /**
1257
- * `Draws layout result`.
1258
- * @private
1259
- */
1260
- private drawLayoutResult(result : PdfStringLayoutResult, font : PdfFont, format : PdfStringFormat, layoutRectangle : RectangleF) : void {
1261
- let vAlignShift : number = this.getTextVerticalAlignShift(result.actualSize.height, layoutRectangle.height, format);
1262
- if (vAlignShift !== 0) {
1263
- this.pdfStreamWriter.startNextLine(0, vAlignShift);
1264
- }
1265
- let ttfFont : PdfTrueTypeFont = font as PdfTrueTypeFont;
1266
- let unicode : boolean = (ttfFont != null && ttfFont.isUnicode);
1267
- let embed : boolean = (ttfFont != null && ttfFont.isEmbedFont);
1268
- let lines : LineInfo[] = result.lines;
1269
- for (let i : number = 0, len : number = lines.length; (i < len && i !== this.startCutIndex); i++) {
1270
- let lineInfo : LineInfo = lines[i];
1271
- let line : string = lineInfo.text;
1272
- let lineWidth : number = lineInfo.width;
1273
- let hAlignShift : number = this.getHorizontalAlignShift(lineWidth, layoutRectangle.width, format);
1274
- let lineIndent : number = this.getLineIndent(lineInfo, format, layoutRectangle, (i === 0));
1275
- hAlignShift += (!this.rightToLeft(format)) ? lineIndent : 0;
1276
- if (hAlignShift !== 0 && !this.isEmfTextScaled) {
1277
- this.pdfStreamWriter.startNextLine(hAlignShift, 0);
1278
- }
1279
- if (unicode) {
1280
- this.drawUnicodeLine(lineInfo, layoutRectangle, font, format);
1281
- } else {
1282
- this.drawAsciiLine(lineInfo, layoutRectangle, font, format);
1283
- }
1284
- if (hAlignShift !== 0 && !this.isEmfTextScaled) {
1285
- this.pdfStreamWriter.startNextLine(-hAlignShift, 0);
1286
- }
1287
- if (this.isOverloadWithPosition && lines.length > 1) {
1288
- this.pdfStreamWriter.startNextLine(-(layoutRectangle.x), 0);
1289
- layoutRectangle.x = 0;
1290
- layoutRectangle.width = this.clientSize.width;
1291
- this.isOverloadWithPosition = false;
1292
- this.isPointOverload = true;
1293
- }
1294
- }
1295
- this.getResources.getResources().requireProcedureSet(this.procedureSets.text);
1296
- if (vAlignShift !== 0) {
1297
- this.pdfStreamWriter.startNextLine(0, -(vAlignShift - result.lineHeight));
1298
- }
1299
- this.pdfStreamWriter.endText();
1300
-
1301
- }
1302
- /**
1303
- * `Draws Ascii line`.
1304
- * @private
1305
- */
1306
- private drawAsciiLine(lineInfo : LineInfo, layoutRectangle : RectangleF, font : PdfFont, format : PdfStringFormat) : void {
1307
- this.justifyLine(lineInfo, layoutRectangle.width, format);
1308
- let value : string = '';
1309
- if (lineInfo.text.indexOf('(') !== -1 || lineInfo.text.indexOf(')') !== -1) {
1310
- for (let i : number = 0; i < lineInfo.text.length; i ++) {
1311
- if (lineInfo.text[i] === '(') {
1312
- value += '\\\(';
1313
- } else if (lineInfo.text[i] === ')') {
1314
- value += '\\\)';
1315
- } else {
1316
- value += lineInfo.text[i];
1317
- }
1318
- }
1319
- }
1320
- if (value === '') {
1321
- value = lineInfo.text;
1322
- }
1323
- let line : string = '(' + value + ')';
1324
- this.pdfStreamWriter.showNextLineText(new PdfString(line));
1325
- }
1326
- /**
1327
- * Draws unicode line.
1328
- * @private
1329
- */
1330
- private drawUnicodeLine(lineInfo : LineInfo, layoutRectangle : RectangleF, font : PdfFont, format : PdfStringFormat) : void {
1331
- let line : string = lineInfo.text;
1332
- let lineWidth : number = lineInfo.width;
1333
- let rtl : boolean = (format !== null && typeof format !== 'undefined' && format.rightToLeft);
1334
- let useWordSpace : boolean = (format !== null && typeof format !== 'undefined' && (format.wordSpacing !== 0 || format.alignment === PdfTextAlignment.Justify));
1335
- let ttfFont : PdfTrueTypeFont = font as PdfTrueTypeFont;
1336
- let wordSpacing : number = this.justifyLine(lineInfo, layoutRectangle.width, format);
1337
- let rtlRender : RtlRenderer = new RtlRenderer();
1338
- if (rtl || (format !== null && typeof format !== 'undefined' && format.textDirection !== PdfTextDirection.None)) {
1339
- let blocks : string[] = null;
1340
- let rightAlign : boolean = (format !== null && typeof format !== 'undefined' && format.alignment === PdfTextAlignment.Right);
1341
- if (format !== null && typeof format !== 'undefined' && format.textDirection !== PdfTextDirection.None) {
1342
- /* tslint:disable-next-line:max-line-length */
1343
- blocks = rtlRender.layout(line, ttfFont, (format.textDirection === PdfTextDirection.RightToLeft) ? true : false, useWordSpace, format);
1344
- } else {
1345
- blocks = rtlRender.layout(line, ttfFont, rightAlign, useWordSpace, format);
1346
- }
1347
- let words : string[] = null;
1348
- if (blocks.length > 1) {
1349
- if (format !== null && typeof format !== 'undefined' && format.textDirection !== PdfTextDirection.None) {
1350
- /* tslint:disable-next-line:max-line-length */
1351
- words = rtlRender.splitLayout(line, ttfFont, (format.textDirection === PdfTextDirection.RightToLeft) ? true : false, useWordSpace, format);
1352
- } else {
1353
- words = rtlRender.splitLayout(line, ttfFont, rightAlign, useWordSpace, format);
1354
- }
1355
- } else {
1356
- words = [line] ;
1357
- }
1358
- this.drawUnicodeBlocks(blocks, words, ttfFont, format, wordSpacing);
1359
- } else {
1360
- if (useWordSpace) {
1361
- let result : { tokens : string[], words : string[] } = this.breakUnicodeLine(line, ttfFont, null);
1362
- let blocks : string[] = result.tokens;
1363
- let words : string[] = result.words;
1364
- this.drawUnicodeBlocks(blocks, words, ttfFont, format, wordSpacing);
1365
- } else {
1366
- let token : string = this.convertToUnicode(line, ttfFont);
1367
- let value : PdfString = this.getUnicodeString(token);
1368
- this.streamWriter.showNextLineText(value);
1369
- }
1370
- }
1371
- }
1372
- /**
1373
- * Draws array of unicode tokens.
1374
- */
1375
- private drawUnicodeBlocks(blocks : string[], words : string[], font : PdfTrueTypeFont, format : PdfStringFormat, wordSpacing : number) : void {
1376
- if (blocks == null) {
1377
- throw new Error('Argument Null Exception : blocks');
1378
- }
1379
- if (words == null) {
1380
- throw new Error('Argument Null Exception : words');
1381
- }
1382
- if (font == null) {
1383
- throw new Error('Argument Null Exception : font');
1384
- }
1385
- this.streamWriter.startNextLine();
1386
- let x : number = 0;
1387
- let xShift : number = 0;
1388
- let firstLineIndent : number = 0;
1389
- let paragraphIndent : number = 0;
1390
- try {
1391
- if (format !== null && typeof format !== 'undefined') {
1392
- firstLineIndent = format.firstLineIndent;
1393
- paragraphIndent = format.paragraphIndent;
1394
- format.firstLineIndent = 0;
1395
- format.paragraphIndent = 0;
1396
- }
1397
- let spaceWidth : number = font.getCharWidth(StringTokenizer.whiteSpace, format) + wordSpacing;
1398
- let characterSpacing : number = (format != null) ? format.characterSpacing : 0;
1399
- let wordSpace : number = (format !== null && typeof format !== 'undefined' && wordSpacing === 0) ? format.wordSpacing : 0;
1400
- spaceWidth += characterSpacing + wordSpace;
1401
- for (let i : number = 0; i < blocks.length; i++) {
1402
- let token : string = blocks[i];
1403
- let word : string = words[i];
1404
- let tokenWidth : number = 0;
1405
- if (x !== 0) {
1406
- this.streamWriter.startNextLine(x, 0);
1407
- }
1408
- if (word.length > 0) {
1409
- tokenWidth += /*Utils.Round(*/ font.measureString(word, format).width /*)*/;
1410
- tokenWidth += characterSpacing;
1411
- let val : PdfString = this.getUnicodeString(token);
1412
- this.streamWriter.showText(val);
1413
- }
1414
- if (i !== blocks.length - 1) {
1415
- x = tokenWidth + spaceWidth;
1416
- xShift += x;
1417
- }
1418
- }
1419
- // Rolback current line position.
1420
- if (xShift > 0) {
1421
- this.streamWriter.startNextLine(-xShift, 0);
1422
- }
1423
- }
1424
- finally {
1425
- if (format !== null && typeof format !== 'undefined') {
1426
- format.firstLineIndent = firstLineIndent;
1427
- format.paragraphIndent = paragraphIndent;
1428
- }
1429
- }
1430
- }
1431
- /**
1432
- * Breakes the unicode line to the words and converts symbols to glyphs.
1433
- */
1434
- private breakUnicodeLine(line : string, ttfFont : PdfTrueTypeFont, words : string[]) : {tokens : string[], words : string[]} {
1435
- if (line === null) {
1436
- throw new Error('Argument Null Exception : line');
1437
- }
1438
- words = line.split(null);
1439
- let tokens : string[] = [];
1440
- for (let i : number = 0; i < words.length; i++) {
1441
- // Reconvert string according to unicode standard.
1442
- let word : string = words[i];
1443
- let token : string = this.convertToUnicode(word, ttfFont);
1444
- tokens[i] = token;
1445
- }
1446
- return { tokens : tokens, words : words };
1447
- }
1448
- /**
1449
- * Creates PdfString from the unicode text.
1450
- */
1451
- private getUnicodeString(token : string) : PdfString {
1452
- if (token === null) {
1453
- throw new Error('Argument Null Exception : token');
1454
- }
1455
- let val : PdfString = new PdfString(token);
1456
- val.converted = true;
1457
- val.encode = InternalEnum.ForceEncoding.Ascii;
1458
- return val;
1459
- }
1460
- /**
1461
- * Converts to unicode format.
1462
- */
1463
- private convertToUnicode(text : string, ttfFont : PdfTrueTypeFont) : string {
1464
- let token : string = null;
1465
- if (text == null) {
1466
- throw new Error('Argument Null Exception : text');
1467
- }
1468
- if (ttfFont == null) {
1469
- throw new Error('Argument Null Exception : ttfFont');
1470
- }
1471
- if (ttfFont.fontInternal instanceof UnicodeTrueTypeFont) {
1472
- let ttfReader : TtfReader = (ttfFont.fontInternal as UnicodeTrueTypeFont).ttfReader;
1473
- ttfFont.setSymbols(text);
1474
- token = ttfReader.convertString(text);
1475
- let bytes : number[] = PdfString.toUnicodeArray(token, false);
1476
- token = PdfString.byteToString(bytes);
1477
- }
1478
- return token;
1479
- }
1480
- /**
1481
- * `Justifies` the line if needed.
1482
- * @private
1483
- */
1484
- private justifyLine(lineInfo : LineInfo, boundsWidth : number, format : PdfStringFormat) : number {
1485
- let line : string = lineInfo.text;
1486
- let lineWidth : number = lineInfo.width;
1487
- let shouldJustify : boolean = this.shouldJustify(lineInfo, boundsWidth, format);
1488
- let hasWordSpacing : boolean = (format != null && format.wordSpacing !== 0);
1489
- let symbols : string[] = StringTokenizer.spaces;
1490
- let whitespacesCount : number = StringTokenizer.getCharsCount(line, symbols);
1491
- let wordSpace : number = 0;
1492
- if (shouldJustify) {
1493
- // Correct line width.
1494
- if (hasWordSpacing) {
1495
- lineWidth -= (whitespacesCount * format.wordSpacing);
1496
- }
1497
- let difference : number = boundsWidth - lineWidth;
1498
- wordSpace = difference / whitespacesCount;
1499
- this.pdfStreamWriter.setWordSpacing(wordSpace);
1500
- } else {
1501
- // If there is justifying, but the line shouldn't be justified, restore default word spacing.
1502
- if (hasWordSpacing) {
1503
- this.pdfStreamWriter.setWordSpacing(format.wordSpacing);
1504
- } else {
1505
- this.pdfStreamWriter.setWordSpacing(0);
1506
- }
1507
- }
1508
- return wordSpace;
1509
- }
1510
- /**
1511
- * `Reset` or reinitialize the current graphic value.
1512
- * @private
1513
- */
1514
- public reset(size : SizeF) : void {
1515
- this.canvasSize = size;
1516
- this.streamWriter.clear();
1517
- this.initialize();
1518
- this.initializeCoordinates();
1519
- }
1520
- /**
1521
- * Checks whether the line should be `justified`.
1522
- * @private
1523
- */
1524
- private shouldJustify(lineInfo : LineInfo, boundsWidth : number, format : PdfStringFormat) : boolean {
1525
- let line : string = lineInfo.text;
1526
- let lineWidth : number = lineInfo.width;
1527
- let justifyStyle : boolean = (format != null && format.alignment === PdfTextAlignment.Justify);
1528
- let goodWidth : boolean = (boundsWidth >= 0 && lineWidth < boundsWidth);
1529
- let symbols : string[] = StringTokenizer.spaces;
1530
- let whitespacesCount : number = StringTokenizer.getCharsCount(line, symbols);
1531
- let hasSpaces : boolean = (whitespacesCount > 0 && line[0] !== StringTokenizer.whiteSpace);
1532
- let goodLineBreakStyle : boolean = ((lineInfo.lineType & LineType.LayoutBreak) > 0);
1533
- let shouldJustify : boolean = (justifyStyle && goodWidth && hasSpaces && (goodLineBreakStyle || format.alignment === PdfTextAlignment.Justify));
1534
- return shouldJustify;
1535
- }
1536
- /**
1537
- * Emulates `Underline, Strikeout` of the text if needed.
1538
- * @private
1539
- */
1540
- private underlineStrikeoutText(pen : PdfPen, brush : PdfBrush, result : PdfStringLayoutResult, font : PdfFont, layoutRectangle : RectangleF, format : PdfStringFormat) : void {
1541
- if (font.underline || font.strikeout) {
1542
- // Calculate line width.
1543
- let linePen : PdfPen = this.createUnderlineStikeoutPen(pen, brush, font, format);
1544
- if (linePen != null) {
1545
- // Approximate line positions.
1546
- let vShift : number = this.getTextVerticalAlignShift(result.actualSize.height, layoutRectangle.height, format);
1547
- let underlineYOffset : number = 0;
1548
- underlineYOffset = layoutRectangle.y + vShift + font.metrics.getAscent(format) + 1.5 * linePen.width;
1549
- let strikeoutYOffset : number = layoutRectangle.y + vShift + font.metrics.getHeight(format) / 2 + 1.5 * linePen.width;
1550
- let lines : LineInfo[] = result.lines;
1551
- // Run through the text and draw lines.
1552
- for (let i : number = 0, len : number = result.lineCount; i < len; i++) {
1553
- let lineInfo : LineInfo = lines[i];
1554
- let line : string = lineInfo.text;
1555
- let lineWidth : number = lineInfo.width;
1556
- let hShift : number = this.getHorizontalAlignShift(lineWidth, layoutRectangle.width, format);
1557
- let lineIndent : number = this.getLineIndent(lineInfo, format, layoutRectangle, (i === 0));
1558
- hShift += (!this.rightToLeft(format)) ? lineIndent : 0;
1559
- let x1 : number = layoutRectangle.x + hShift;
1560
- let x2 : number = (!this.shouldJustify(lineInfo, layoutRectangle.width, format)) ? x1 + lineWidth - lineIndent : x1 + layoutRectangle.width - lineIndent;
1561
-
1562
- if (font.underline) {
1563
- let y : number = underlineYOffset;
1564
- this.drawLine(linePen, x1, y, x2, y);
1565
- underlineYOffset += result.lineHeight;
1566
- }
1567
- if (font.strikeout) {
1568
- let y : number = strikeoutYOffset;
1569
- this.drawLine(linePen, x1, y, x2, y);
1570
- strikeoutYOffset += result.lineHeight;
1571
- }
1572
- if (this.isPointOverload && lines.length > 1) {
1573
- layoutRectangle.x = 0;
1574
- layoutRectangle.width = this.clientSize.width;
1575
- }
1576
- }
1577
- this.isPointOverload = false;
1578
- }
1579
- }
1580
- }
1581
- /**
1582
- * `Creates a pen` for drawing lines in the text.
1583
- * @private
1584
- */
1585
- private createUnderlineStikeoutPen(pen : PdfPen, brush : PdfBrush, font : PdfFont, format : PdfStringFormat) : PdfPen {
1586
- // Calculate line width.
1587
- let lineWidth : number = font.metrics.getSize(format) / 20;
1588
- let linePen : PdfPen = null;
1589
- // Create a pen fo the lines.
1590
- if (pen != null) {
1591
- linePen = new PdfPen(pen.color, lineWidth);
1592
- } else if (brush != null) {
1593
- linePen = new PdfPen(brush, lineWidth);
1594
- }
1595
- return linePen;
1596
- }
1597
- /**
1598
- * Return `text rendering mode`.
1599
- * @private
1600
- */
1601
- private getTextRenderingMode(pen : PdfPen, brush : PdfBrush, format : PdfStringFormat) : TextRenderingMode {
1602
- let tm : TextRenderingMode = TextRenderingMode.None;
1603
- if (pen != null && brush != null) {
1604
- tm = TextRenderingMode.FillStroke;
1605
- } else if (pen != null) {
1606
- tm = TextRenderingMode.Stroke;
1607
- } else {
1608
- tm = TextRenderingMode.Fill;
1609
- }
1610
- if (format != null && format.clipPath) {
1611
- tm |= TextRenderingMode.ClipFlag;
1612
- }
1613
- return tm;
1614
- }
1615
- /**
1616
- * Returns `line indent` for the line.
1617
- * @private
1618
- */
1619
- private getLineIndent(lineInfo : LineInfo, format : PdfStringFormat, layoutBounds : RectangleF, firstLine : boolean) : number {
1620
- let lineIndent : number = 0;
1621
- let firstParagraphLine : boolean = ((lineInfo.lineType & LineType.FirstParagraphLine) > 0);
1622
- if (format != null && firstParagraphLine) {
1623
- lineIndent = (firstLine) ? format.firstLineIndent : format.paragraphIndent;
1624
- lineIndent = (layoutBounds.width > 0) ? Math.min(layoutBounds.width, lineIndent) : lineIndent;
1625
- }
1626
- return lineIndent;
1627
- }
1628
- /**
1629
- * Calculates shift value if the line is `horizontaly aligned`.
1630
- * @private
1631
- */
1632
- private getHorizontalAlignShift(lineWidth : number, boundsWidth : number, format : PdfStringFormat) : number {
1633
- let shift : number = 0;
1634
- if (boundsWidth >= 0 && format != null && format.alignment !== PdfTextAlignment.Left) {
1635
- switch (format.alignment) {
1636
- case PdfTextAlignment.Center:
1637
- shift = (boundsWidth - lineWidth) / 2;
1638
- break;
1639
- case PdfTextAlignment.Right:
1640
- shift = boundsWidth - lineWidth;
1641
- break;
1642
- }
1643
- }
1644
- return shift;
1645
- }
1646
- /**
1647
- * Gets or sets the value that indicates `text direction` mode.
1648
- * @private
1649
- */
1650
- private rightToLeft(format : PdfStringFormat) : boolean {
1651
- let rtl : boolean = (format !== null && typeof format !== 'undefined' && format.rightToLeft);
1652
- if (format !== null && typeof format !== 'undefined') {
1653
- if (format.textDirection !== PdfTextDirection.None && typeof format.textDirection !== 'undefined') {
1654
- rtl = true;
1655
- }
1656
- }
1657
- return rtl;
1658
- }
1659
- /**
1660
- * Controls all `state modifications` and react repectively.
1661
- * @private
1662
- */
1663
- private stateControl(pen : PdfPen, brush : PdfBrush, font : PdfFont) : void
1664
- /**
1665
- * Controls all `state modifications` and react respectively.
1666
- * @private
1667
- */
1668
- private stateControl(pen : PdfPen, brush : PdfBrush, font : PdfFont, format : PdfStringFormat) : void
1669
- private stateControl(pen : PdfPen, brush : PdfBrush, font : PdfFont, format ?: PdfStringFormat) : void {
1670
- if (typeof format === 'undefined') {
1671
- this.stateControl(pen, brush, font, null);
1672
- } else {
1673
- if (brush instanceof PdfGradientBrush) {
1674
- this.bCSInitialized = false;
1675
- (<PdfGradientBrush>brush).colorSpace = this.colorSpace;
1676
- }
1677
- if (brush instanceof PdfTilingBrush) {
1678
- this.bCSInitialized = false;
1679
- (<PdfTilingBrush>brush).graphics.colorSpace = this.colorSpace;
1680
- }
1681
- let saveState : boolean = false;
1682
- if (brush !== null) {
1683
- let solidBrush : PdfSolidBrush = <PdfSolidBrush>brush;
1684
- if (typeof this.pageLayer !== 'undefined' && this.pageLayer != null) {
1685
- if (this.colorSpaceChanged === false) {
1686
- this.lastDocumentCS = (this.pageLayer.page as PdfPage).document.colorSpace;
1687
- this.lastGraphicsCS = (this.pageLayer.page as PdfPage).graphics.colorSpace;
1688
- this.colorSpace = (this.pageLayer.page as PdfPage).document.colorSpace;
1689
- this.currentColorSpace = (this.pageLayer.page as PdfPage).document.colorSpace;
1690
- this.colorSpaceChanged = true;
1691
- }
1692
- }
1693
- this.initCurrentColorSpace(this.currentColorSpace);
1694
- } else if (pen != null) {
1695
- let pdfPen : PdfPen = pen as PdfPen;
1696
- if (typeof this.pageLayer !== 'undefined' && this.pageLayer != null) {
1697
- this.colorSpace = (this.pageLayer.page as PdfPage).document.colorSpace;
1698
- this.currentColorSpace = (this.pageLayer.page as PdfPage).document.colorSpace;
1699
- }
1700
- this.initCurrentColorSpace(this.currentColorSpace);
1701
- }
1702
- this.penControl(pen, saveState);
1703
- this.brushControl(brush, saveState);
1704
- this.fontControl(font, format, saveState);
1705
- }
1706
- }
1707
- /**
1708
- * Initializes the `current color space`.
1709
- * @private
1710
- */
1711
- private initCurrentColorSpace(colorspace : PdfColorSpace) : void {
1712
- let re : PdfResources = this.getResources.getResources() as PdfResources;
1713
- if (!this.bCSInitialized) {
1714
- if (this.currentColorSpace != PdfColorSpace.GrayScale) {
1715
- this.pdfStreamWriter.setColorSpace('Device' + this.currentColorSpaces[this.currentColorSpace], true);
1716
- this.pdfStreamWriter.setColorSpace('Device' + this.currentColorSpaces[this.currentColorSpace], false);
1717
- this.bCSInitialized = true;
1718
- } else {
1719
- this.pdfStreamWriter.setColorSpace('DeviceGray' , true);
1720
- this.pdfStreamWriter.setColorSpace('DeviceGray' , false);
1721
- this.bCSInitialized = true;
1722
- }
1723
-
1724
- }
1725
- }
1726
- /**
1727
- * Controls the `pen state`.
1728
- * @private
1729
- */
1730
- private penControl(pen : PdfPen, saveState : boolean) : void {
1731
- if (pen != null) {
1732
- this.currentPen = pen;
1733
- pen.monitorChanges(this.currentPen, this.pdfStreamWriter, this.getResources, saveState, this.colorSpace, this.matrix.clone());
1734
- this.currentPen = pen.clone();
1735
- }
1736
- }
1737
- /**
1738
- * Controls the `brush state`.
1739
- * @private
1740
- */
1741
- private brushControl(brush : PdfBrush, saveState : boolean) : void {
1742
- if (brush != null && typeof brush !== 'undefined') {
1743
- let b : PdfBrush = brush.clone();
1744
- let lgb : PdfGradientBrush = <PdfGradientBrush>b;
1745
- if (lgb !== null && typeof lgb !== 'undefined' && !(brush instanceof PdfSolidBrush) && !(brush instanceof PdfTilingBrush)) {
1746
- let m: PdfTransformationMatrix = lgb.matrix;
1747
- let matrix: PdfTransformationMatrix = this.matrix.clone();
1748
- if ((m != null)) {
1749
- m.multiply(matrix);
1750
- matrix = m;
1751
- }
1752
- lgb.matrix = matrix;
1753
- }
1754
- this.currentBrush = lgb;
1755
- let br: PdfSolidBrush = (<PdfSolidBrush>(brush));
1756
- b.monitorChanges(this.currentBrush, this.pdfStreamWriter, this.getResources, saveState, this.colorSpace);
1757
- this.currentBrush = brush;
1758
- brush = null;
1759
- }
1760
- }
1761
- /**
1762
- * Saves the font and other `font settings`.
1763
- * @private
1764
- */
1765
- private fontControl(font : PdfFont, format : PdfStringFormat, saveState : boolean) : void {
1766
- if (font != null) {
1767
- let curSubSuper : PdfSubSuperScript = (format != null) ? format.subSuperScript : PdfSubSuperScript.None;
1768
- let prevSubSuper : PdfSubSuperScript = (this.currentStringFormat != null) ? this.currentStringFormat.subSuperScript : PdfSubSuperScript.None;
1769
- if (saveState || font !== this.currentFont || curSubSuper !== prevSubSuper) {
1770
- let resources : PdfResources = this.getResources.getResources();
1771
- this.currentFont = font;
1772
- this.currentStringFormat = format;
1773
- let size : number = font.metrics.getSize(format);
1774
- this.isEmfTextScaled = false;
1775
- let fontName : PdfName = resources.getName(font);
1776
- this.pdfStreamWriter.setFont(font, fontName, size);
1777
- }
1778
- }
1779
- }
1780
- /**
1781
- * `Sets the transparency` of this Graphics with the specified value for pen.
1782
- * ```typescript
1783
- * // create a new PDF document
1784
- * let document : PdfDocument = new PdfDocument();
1785
- * // create a new page
1786
- * let page1 : PdfPage = document.pages.add();
1787
- * // create pen
1788
- * let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
1789
- * //
1790
- * // set transparency
1791
- * page1.graphics.setTransparency(0.5);
1792
- * //
1793
- * // draw the rectangle after applying transparency
1794
- * page1.graphics.drawRectangle(pen, new RectangleF({x : 0, y : 0}, {width : 100, height : 50}));
1795
- * // save the document.
1796
- * document.save('output.pdf');
1797
- * // destroy the document
1798
- * document.destroy();
1799
- * ```
1800
- * @param alpha The alpha value for both pen and brush.
1801
- */
1802
- public setTransparency(alpha : number) : void
1803
- /**
1804
- * `Sets the transparency` of this Graphics with the specified value for pen and brush.
1805
- * ```typescript
1806
- * // create a new PDF document
1807
- * let document : PdfDocument = new PdfDocument();
1808
- * // create a new page
1809
- * let page1 : PdfPage = document.pages.add();
1810
- * // create pen
1811
- * let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
1812
- * // set brush
1813
- * let brush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(0, 0, 0));
1814
- * //
1815
- * // set transparency
1816
- * page1.graphics.setTransparency(0.8, 0.2);
1817
- * //
1818
- * // draw the rectangle after applying transparency
1819
- * page1.graphics.drawRectangle(pen, brush, new RectangleF({x : 0, y : 0}, {width : 100, height : 50}));
1820
- * // save the document.
1821
- * document.save('output.pdf');
1822
- * // destroy the document
1823
- * document.destroy();
1824
- * ```
1825
- * @param alphaPen The alpha value for pen.
1826
- * @param alphaBrush The alpha value for brush.
1827
- */
1828
- public setTransparency(alphaPen : number, alphaBrush : number) : void
1829
- /**
1830
- * `Sets the transparency` of this Graphics with the specified PdfBlendMode.
1831
- * @private
1832
- */
1833
- public setTransparency(alphaPen : number, alphaBrush : number, blendMode : PdfBlendMode) : void
1834
- public setTransparency(arg1 : number, arg2 ?: number, arg3 ?: PdfBlendMode) : void {
1835
- if (typeof arg2 === 'undefined') {
1836
- this.istransparencySet = true;
1837
- this.setTransparency(arg1, arg1, PdfBlendMode.Normal);
1838
- } else if (typeof arg2 === 'number' && typeof arg3 === 'undefined') {
1839
- this.setTransparency(arg1, arg2, PdfBlendMode.Normal);
1840
- } else {
1841
- if (this.trasparencies == null) {
1842
- this.trasparencies = new TemporaryDictionary<TransparencyData, PdfTransparency>();
1843
- }
1844
- let transp : PdfTransparency = null;
1845
- let td : TransparencyData = new TransparencyData(arg1, arg2, arg3);
1846
- if (this.trasparencies.containsKey(td)) {
1847
- transp = this.trasparencies.getValue(td) as PdfTransparency;
1848
- }
1849
- if (transp == null) {
1850
- transp = new PdfTransparency(arg1, arg2, arg3);
1851
- this.trasparencies.setValue(td, transp);
1852
- }
1853
- let resources : PdfResources = this.getResources.getResources();
1854
- let name : PdfName = resources.getName(transp);
1855
- let sw : PdfStreamWriter = this.streamWriter;
1856
- sw.setGraphicsState(name);
1857
- }
1858
- }
1859
- /**
1860
- * Sets the `drawing area and translates origin`.
1861
- * @private
1862
- */
1863
- public clipTranslateMargins(clipBounds : RectangleF) : void
1864
- public clipTranslateMargins(x : number, y : number, left : number, top : number, right : number, bottom : number) : void
1865
- public clipTranslateMargins(x : number | RectangleF, y ?: number, left ?: number, top ?: number, right ?: number, bottom ?: number) : void {
1866
- if (x instanceof RectangleF && typeof y === 'undefined') {
1867
- this.clipBounds = x as RectangleF;
1868
- this.pdfStreamWriter.writeComment('Clip margins.');
1869
- this.pdfStreamWriter.appendRectangle(x as RectangleF);
1870
- this.pdfStreamWriter.closePath();
1871
- this.pdfStreamWriter.clipPath(false);
1872
- this.pdfStreamWriter.writeComment('Translate co-ordinate system.');
1873
- this.translateTransform((x as RectangleF).x, (x as RectangleF).y);
1874
- } else if (typeof x === 'number') {
1875
- let clipArea : RectangleF = new RectangleF(left, top, this.size.width-left-right, this.size.height-top-bottom);
1876
- this.clipBounds = clipArea;
1877
- this.pdfStreamWriter.writeComment("Clip margins.");
1878
- this.pdfStreamWriter.appendRectangle(clipArea);
1879
- this.pdfStreamWriter.closePath();
1880
- this.pdfStreamWriter.clipPath(false);
1881
- this.pdfStreamWriter.writeComment("Translate co-ordinate system.");
1882
- this.translateTransform(x, y);
1883
- }
1884
- }
1885
- /**
1886
- * `Updates y` co-ordinate.
1887
- * @private
1888
- */
1889
- public updateY(y : number) : number {
1890
- return -y;
1891
- }
1892
- /**
1893
- * Used to `translate the transformation`.
1894
- * ```typescript
1895
- * // create a new PDF document
1896
- * let document : PdfDocument = new PdfDocument();
1897
- * // create a new page
1898
- * let page1 : PdfPage = document.pages.add();
1899
- * // set pen
1900
- * let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
1901
- * //
1902
- * // set translate transform
1903
- * page1.graphics.translateTransform(100, 100);
1904
- * //
1905
- * // draw the rectangle after applying translate transform
1906
- * page1.graphics.drawRectangle(pen, new RectangleF({x : 0, y : 0}, {width : 100, height : 50}));
1907
- * // save the document.
1908
- * document.save('output.pdf');
1909
- * // destroy the document
1910
- * document.destroy();
1911
- * ```
1912
- * @param offsetX The x-coordinate of the translation.
1913
- * @param offsetY The y-coordinate of the translation.
1914
- */
1915
- public translateTransform(offsetX : number, offsetY : number) : void {
1916
- let matrix : PdfTransformationMatrix = new PdfTransformationMatrix();
1917
- this.getTranslateTransform(offsetX, offsetY, matrix);
1918
- this.pdfStreamWriter.modifyCtm(matrix);
1919
- this.matrix.multiply(matrix);
1920
- }
1921
- /**
1922
- * `Translates` coordinates of the input matrix.
1923
- * @private
1924
- */
1925
- private getTranslateTransform(x : number, y : number, input : PdfTransformationMatrix) : PdfTransformationMatrix {
1926
- input.translate(x, this.updateY(y));
1927
- return input;
1928
- }
1929
- /**
1930
- * Applies the specified `scaling operation` to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.
1931
- * ```typescript
1932
- * // create a new PDF document
1933
- * let document : PdfDocument = new PdfDocument();
1934
- * // create a new page
1935
- * let page1 : PdfPage = document.pages.add();
1936
- * // create pen
1937
- * let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
1938
- * //
1939
- * // apply scaling trasformation
1940
- * page1.graphics.scaleTransform(1.5, 2);
1941
- * //
1942
- * // draw the rectangle after applying scaling transform
1943
- * page1.graphics.drawRectangle(pen, new RectangleF({x : 100, y : 100}, {width : 100, height : 50}));
1944
- * // save the document.
1945
- * document.save('output.pdf');
1946
- * // destroy the document
1947
- * document.destroy();
1948
- * ```
1949
- * @param scaleX Scale factor in the x direction.
1950
- * @param scaleY Scale factor in the y direction.
1951
- */
1952
-
1953
- public scaleTransform(scaleX : number, scaleY : number) : void {
1954
- let matrix : PdfTransformationMatrix = new PdfTransformationMatrix();
1955
- this.getScaleTransform(scaleX, scaleY, matrix);
1956
- this.pdfStreamWriter.modifyCtm(matrix);
1957
- this.matrix.multiply(matrix);
1958
- }
1959
- /**
1960
- * `Scales` coordinates of the input matrix.
1961
- * @private
1962
- */
1963
- private getScaleTransform(x : number, y : number, input : PdfTransformationMatrix) : PdfTransformationMatrix {
1964
- if (input == null) {
1965
- input = new PdfTransformationMatrix();
1966
- }
1967
- input.scale(x, y);
1968
- return input;
1969
- }
1970
- /**
1971
- * Applies the specified `rotation` to the transformation matrix of this Graphics.
1972
- * ```typescript
1973
- * // create a new PDF document
1974
- * let document : PdfDocument = new PdfDocument();
1975
- * // create a new page
1976
- * let page1 : PdfPage = document.pages.add();
1977
- * // create pen
1978
- * let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
1979
- * //
1980
- * // set RotateTransform with 25 degree of angle
1981
- * page1.graphics.rotateTransform(25);
1982
- * //
1983
- * // draw the rectangle after RotateTransformation
1984
- * page1.graphics.drawRectangle(pen, new RectangleF({x : 100, y : 100}, {width : 100, height : 50}));
1985
- * // save the document.
1986
- * document.save('output.pdf');
1987
- * // destroy the document
1988
- * document.destroy();
1989
- * ```
1990
- * @param angle Angle of rotation in degrees.
1991
- */
1992
- public rotateTransform(angle : number) : void {
1993
- let matrix : PdfTransformationMatrix = new PdfTransformationMatrix();
1994
- this.getRotateTransform(angle, matrix);
1995
- this.pdfStreamWriter.modifyCtm(matrix);
1996
- this.matrix.multiply(matrix);
1997
- }
1998
- /**
1999
- * `Initializes coordinate system`.
2000
- * @private
2001
- */
2002
- public initializeCoordinates() : void {
2003
- // Matrix equation: TM(T-1)=M', where T=[1 0 0 -1 0 h]
2004
- this.pdfStreamWriter.writeComment('Change co-ordinate system to left/top.');
2005
- // Translate co-ordinates only, don't flip.
2006
- if (this.mediaBoxUpperRightBound !== -(this.size.height)) {
2007
- if (this.cropBox == null) {
2008
- if (this.mediaBoxUpperRightBound === this.size.height || this.mediaBoxUpperRightBound === 0) {
2009
- this.translateTransform(0, this.updateY(this.size.height));
2010
- } else {
2011
- this.translateTransform(0, this.updateY(this.mediaBoxUpperRightBound));
2012
- }
2013
- }
2014
- }
2015
- }
2016
- /**
2017
- * `Rotates` coordinates of the input matrix.
2018
- * @private
2019
- */
2020
- private getRotateTransform(angle : number, input : PdfTransformationMatrix) : PdfTransformationMatrix {
2021
- if (input == null || typeof input === 'undefined') {
2022
- input = new PdfTransformationMatrix();
2023
- }
2024
- input.rotate(this.updateY(angle));
2025
- return input;
2026
- }
2027
- /**
2028
- * `Saves` the current state of this Graphics and identifies the saved state with a GraphicsState.
2029
- * ```typescript
2030
- * // create a new PDF document
2031
- * let document : PdfDocument = new PdfDocument();
2032
- * // create a new page
2033
- * let page1 : PdfPage = document.pages.add();
2034
- * // create pen
2035
- * let pen : PdfPen = new PdfPen(new PdfColor(0, 0, 0));
2036
- * //
2037
- * // save the graphics state
2038
- * let state1 : PdfGraphicsState = page1.graphics.save();
2039
- * //
2040
- * page1.graphics.scaleTransform(1.5, 2);
2041
- * // draw the rectangle
2042
- * page1.graphics.drawRectangle(pen, new RectangleF({x : 100, y : 100}, {width : 100, height : 50}));
2043
- * // restore the graphics state
2044
- * page1.graphics.restore(state1);
2045
- * // save the document.
2046
- * document.save('output.pdf');
2047
- * // destroy the document
2048
- * document.destroy();
2049
- * ```
2050
- */
2051
- public save() : PdfGraphicsState {
2052
- let state : PdfGraphicsState = new PdfGraphicsState(this, this.matrix.clone());
2053
- state.brush = this.currentBrush;
2054
- state.pen = this.currentPen;
2055
- state.font = this.currentFont;
2056
- state.colorSpace = this.currentColorSpace;
2057
- state.characterSpacing = this.previousCharacterSpacing;
2058
- state.wordSpacing = this.previousWordSpacing;
2059
- state.textScaling = this.previousTextScaling;
2060
- state.textRenderingMode = this.previousTextRenderingMode;
2061
- this.graphicsState.push(state);
2062
- this.pdfStreamWriter.saveGraphicsState();
2063
- return state;
2064
- }
2065
- /**
2066
- * `Restores the state` of this Graphics to the state represented by a GraphicsState.
2067
- * @private
2068
- */
2069
- public restore() : void
2070
- /**
2071
- * `Restores the state` of this Graphics to the state represented by a GraphicsState.
2072
- * @private
2073
- */
2074
- public restore(state : PdfGraphicsState) : void
2075
- public restore(state ?: PdfGraphicsState) : void {
2076
- if (typeof state === 'undefined') {
2077
- if (this.graphicsState.length > 0) {
2078
- this.doRestoreState();
2079
- }
2080
- } else {
2081
- if (this.graphicsState.indexOf(state) !== -1) {
2082
- for ( ; ; ) {
2083
- if (this.graphicsState.length === 0) {
2084
- break;
2085
- }
2086
- let popState : PdfGraphicsState = this.doRestoreState();
2087
- if (popState === state) {
2088
- break;
2089
- }
2090
- }
2091
- }
2092
- }
2093
- }
2094
- /**
2095
- * `Restores graphics state`.
2096
- * @private
2097
- */
2098
- private doRestoreState() : PdfGraphicsState {
2099
- let state : PdfGraphicsState = this.graphicsState.pop();
2100
- this.transformationMatrix = state.matrix;
2101
- this.currentBrush = state.brush;
2102
- this.currentPen = state.pen;
2103
- this.currentFont = state.font;
2104
- this.currentColorSpace = state.colorSpace;
2105
- this.previousCharacterSpacing = state.characterSpacing;
2106
- this.previousWordSpacing = state.wordSpacing;
2107
- this.previousTextScaling = state.textScaling;
2108
- this.previousTextRenderingMode = state.textRenderingMode;
2109
- this.pdfStreamWriter.restoreGraphicsState();
2110
- return state;
2111
- }
2112
-
2113
- /**
2114
- * `Draws the specified path`, using its original physical size, at the location specified by a coordinate pair.
2115
- * ```typescript
2116
- * // create a new PDF document.
2117
- * let document : PdfDocument = new PdfDocument();
2118
- * // add a page to the document.
2119
- * let page1 : PdfPage = document.pages.add();
2120
- * //Create new PDF path.
2121
- * let path : PdfPath = new PdfPath();
2122
- * //Add line path points.
2123
- * path.addLine(new PointF(10, 100), new PointF(10, 200));
2124
- * path.addLine(new PointF(100, 100), new PointF(100, 200));
2125
- * path.addLine(new PointF(100, 200), new PointF(55, 150));
2126
- * // set pen
2127
- * let pen : PdfPen = new PdfPen(new PdfColor(255, 0, 0));
2128
- * // set brush
2129
- * let brush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(0, 0, 0));
2130
- * // draw the path
2131
- * page1.graphics.drawPath(pen, brush, path);
2132
- * //
2133
- * // save the document.
2134
- * document.save('output.pdf');
2135
- * // destroy the document
2136
- * document.destroy();
2137
- * ```
2138
- * @param pen Color of the text.
2139
- * @param brush Color of the text.
2140
- * @param path Draw path.
2141
- */
2142
- public drawPath(pen: PdfPen, brush: PdfBrush, path: PdfPath) : void {
2143
- this._drawPath(pen, brush, path.pathPoints, path.pathTypes, path.fillMode);
2144
- }
2145
- private _drawPath(pen: PdfPen, brush: PdfBrush, pathPoints: PointF[], pathTypes: number[], fillMode: PdfFillMode) : void {
2146
- if (brush instanceof PdfTilingBrush) {
2147
- this.bCSInitialized = false;
2148
- (<PdfTilingBrush>brush).graphics.colorSpace = this.colorSpace;
2149
- } else if (brush instanceof PdfGradientBrush) {
2150
- this.bCSInitialized = false;
2151
- (<PdfGradientBrush>brush).colorSpace = this.colorSpace;
2152
- }
2153
- this.stateControl(pen, brush, null);
2154
- this.buildUpPath(pathPoints, pathTypes);
2155
- this.drawPathHelper(pen, brush, fillMode, false);
2156
- }
2157
-
2158
- //drawArc overloads
2159
- /**
2160
- * `Draws the specified arc`, using its original physical size, at the location specified by a coordinate pair.
2161
- * ```typescript
2162
- * // create a new PDF document.
2163
- * let document : PdfDocument = new PdfDocument();
2164
- * // add a page to the document.
2165
- * let page1 : PdfPage = document.pages.add();
2166
- * let pen : PdfPen = new PdfPen(new PdfColor(255, 0, 0));
2167
- * // draw the path
2168
- * page1.graphics.drawArc(pen, 10, 10, 100, 200, 90, 270);
2169
- * // save the document.
2170
- * document.save('output.pdf');
2171
- * // destroy the document
2172
- * document.destroy();
2173
- * ```
2174
- * @param name Pen that determines the color, width, and style of the arc.
2175
- * @param rectangle RectangleF structure that defines the boundaries of the ellipse.
2176
- * @param startAngle Angle in degrees measured clockwise from the x-axis to the starting point of the arc.
2177
- * @param sweepAngle Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.
2178
- */
2179
- public drawArc(pen: PdfPen, rectangle: RectangleF, startAngle: number, sweepAngle: number) : void
2180
- public drawArc(pen: PdfPen, x: number, y: number, width: number, height: number, startAngle: number, sweepAngle: number) : void
2181
- /* tslint:disable-next-line:max-line-length */
2182
- public drawArc(arg1 : PdfPen, arg2 : number|RectangleF, arg3 ?: number, arg4 ?: number, arg5 ?: number, arg6 ?: number, arg7 ?: number) : void {
2183
- if (arg2 instanceof RectangleF) {
2184
- this.drawArc(arg1, arg2.x, arg2.y, arg2.width, arg2.height, arg3, arg4);
2185
- } else {
2186
- if ((arg7 !== 0)) {
2187
- this.stateControl(arg1, null, null);
2188
- this.constructArcPath(arg2, arg3, (arg2 + arg4), (arg3 + arg5), arg6, arg7);
2189
- this.drawPathHelper(arg1, null, false);
2190
- }
2191
- }
2192
- }
2193
- /**
2194
- * Builds up the path.
2195
- * @private
2196
- */
2197
- private buildUpPath(arg1 : PointF[], arg2 : number[]) : void {
2198
- let cnt : number = arg1.length;
2199
- for (let i : number = 0 ; i < cnt; ++i) {
2200
- let typeValue: number = 0;
2201
- let point: PointF = arg1[i];
2202
- switch ((<PathPointType>((arg2[i] & (<number>(PdfGraphics.pathTypesValuesMask)))))) {
2203
- case PathPointType.Start:
2204
- this.pdfStreamWriter.beginPath(point.x, point.y);
2205
- break;
2206
- case PathPointType.Bezier3:
2207
- let p2 : PointF = new PointF(0, 0);
2208
- let p3 : PointF = new PointF(0, 0);
2209
- let result1 : { i: number, p2 : PointF, p3 : PointF } = this.getBezierPoints(arg1, arg2, i, p2, p3);
2210
- this.pdfStreamWriter.appendBezierSegment(point, result1.p2, result1.p3);
2211
- i = result1.i;
2212
- break;
2213
- case PathPointType.Line:
2214
- this.pdfStreamWriter.appendLineSegment(point);
2215
- break;
2216
- default:
2217
- throw new Error('ArithmeticException - Incorrect path formation.');
2218
- }
2219
- typeValue = arg2[i];
2220
- this.checkFlags(typeValue);
2221
- }
2222
- }
2223
- /**
2224
- * Gets the bezier points from respective arrays.
2225
- * @private
2226
- */
2227
- /* tslint:disable-next-line:max-line-length */
2228
- private getBezierPoints(points: PointF[], types: number[], i: number, p2: PointF, p3: PointF) : { i : number, p2 : PointF, p3 : PointF } {
2229
- let errorMsg: string = 'Malforming path.';
2230
- ++i;
2231
- if (((<PathPointType>((types[i] & PdfGraphics.pathTypesValuesMask))) === PathPointType.Bezier3)) {
2232
- p2 = points[i];
2233
- ++i;
2234
- if (((<PathPointType>((types[i] & PdfGraphics.pathTypesValuesMask))) === PathPointType.Bezier3)) {
2235
- p3 = points[i];
2236
- } else {
2237
- throw new Error ('ArgumentException : errorMsg');
2238
- }
2239
- } else {
2240
- throw new Error ('ArgumentException : errorMsg');
2241
- }
2242
- return { i : i, p2 : p2, p3 : p3 };
2243
- }
2244
-
2245
- /**
2246
- * Checks path point type flags.
2247
- * @private
2248
- */
2249
- private checkFlags(type : number) : void {
2250
- if (((<PathPointType>((type & (<number>(PathPointType.CloseSubpath))))) === PathPointType.CloseSubpath)) {
2251
- this.pdfStreamWriter.closePath();
2252
- }
2253
- }
2254
- /**
2255
- * Constructs the arc path using Bezier curves.
2256
- * @private
2257
- */
2258
- private constructArcPath(x1: number, y1: number, x2: number, y2: number, startAng: number, sweepAngle: number) : void {
2259
- let points: number[] = this.getBezierArc(x1, y1, x2, y2, startAng, sweepAngle);
2260
- if ((points.length === 0)) {
2261
- return;
2262
- }
2263
- let pt: number[] = [points[0], points[1], points[2], points[3], points[4], points[5], points[6], points[7]];
2264
- this.pdfStreamWriter.beginPath(pt[0], pt[1]);
2265
- let i: number = 0;
2266
- for (i = 0 ; i < points.length; i = i + 8) {
2267
- pt = [ points[i], points[i + 1], points[i + 2], points[i + 3], points[i + 4], points[i + 5], points[i + 6], points[i + 7]];
2268
- this.pdfStreamWriter.appendBezierSegment(pt[2], pt[3], pt[4], pt[5], pt[6], pt[7]);
2269
- }
2270
- }
2271
- /**
2272
- * Gets the bezier points for arc constructing.
2273
- * @private
2274
- */
2275
- private getBezierArc(numX1: number, numY1: number, numX2: number, numY2: number, s1: number, e1: number): number[] {
2276
- if ((numX1 > numX2)) {
2277
- let tmp: number;
2278
- tmp = numX1;
2279
- numX1 = numX2;
2280
- numX2 = tmp;
2281
- }
2282
- if ((numY2 > numY1)) {
2283
- let tmp: number;
2284
- tmp = numY1;
2285
- numY1 = numY2;
2286
- numY2 = tmp;
2287
- }
2288
- let fragAngle1: number;
2289
- let numFragments: number;
2290
- if ((Math.abs(e1) <= 90)) {
2291
- fragAngle1 = e1;
2292
- numFragments = 1;
2293
- } else {
2294
- numFragments = (<number>(Math.ceil((Math.abs(e1) / 90))));
2295
- fragAngle1 = (e1 / numFragments);
2296
- }
2297
- let xcen: number = ((numX1 + numX2) / 2);
2298
- let ycen: number = ((numY1 + numY2) / 2);
2299
- let rx: number = ((numX2 - numX1) / 2);
2300
- let ry: number = ((numY2 - numY1) / 2);
2301
- let halfAng: number = (<number>((fragAngle1 * (Math.PI / 360))));
2302
- let kappa: number = (<number>(Math.abs(4.0 / 3.0 * (1.0 - Math.cos(halfAng)) / Math.sin(halfAng))));
2303
- let pointsList: number[] = [];
2304
- for (let i: number = 0; (i < numFragments); i++) {
2305
- let thetaValue0: number = (<number>(((s1 + (i * fragAngle1)) * (Math.PI / 180))));
2306
- let thetaValue1: number = (<number>(((s1 + ((i + 1) * fragAngle1)) * (Math.PI / 180))));
2307
- let cos0: number = (<number>(Math.cos(thetaValue0)));
2308
- let cos1: number = (<number>(Math.cos(thetaValue1)));
2309
- let sin0: number = (<number>(Math.sin(thetaValue0)));
2310
- let sin1: number = (<number>(Math.sin(thetaValue1)));
2311
- if ((fragAngle1 > 0)) {
2312
- /* tslint:disable-next-line:max-line-length */
2313
- pointsList.push((xcen + (rx * cos0)), (ycen - (ry * sin0)), (xcen + (rx * (cos0 - (kappa * sin0)))), (ycen - (ry * (sin0 + (kappa * cos0)))), (xcen + (rx * (cos1 + (kappa * sin1)))), (ycen - (ry * (sin1 - (kappa * cos1)))), (xcen + (rx * cos1)), (ycen - (ry * sin1)));
2314
- } else {
2315
- /* tslint:disable-next-line:max-line-length */
2316
- pointsList.push((xcen + (rx * cos0)), (ycen - (ry * sin0)), (xcen + (rx * (cos0 + (kappa * sin0)))), (ycen - (ry * (sin0 - (kappa * cos0)))), (xcen + (rx * (cos1 - (kappa * sin1)))), (ycen - (ry * (sin1 + (kappa * cos1)))), (xcen + (rx * cos1)), (ycen - (ry * sin1)));
2317
- }
2318
- }
2319
- return pointsList;
2320
- }
2321
- }
2322
- /**
2323
- * `GetResourceEventHandler` class is alternate for event handlers and delegates.
2324
- * @private
2325
- * @hidden
2326
- */
2327
- export class GetResourceEventHandler {
2328
- /**
2329
- * Return the instance of `PdfResources` class.
2330
- * @private
2331
- */
2332
- public getResources() : PdfResources {
2333
- return this.sender.getResources();
2334
- }
2335
- /**
2336
- * Variable to store instance of `PdfPageBase as sender`.
2337
- * @hidden
2338
- * @private
2339
- */
2340
- public sender : PdfPageBase|PdfTemplate|PdfTilingBrush;
2341
- /**
2342
- * Initialize instance of `GetResourceEventHandler` class.
2343
- * Alternate for event handlers and delegates.
2344
- * @private
2345
- */
2346
- public constructor(sender : PdfPageBase|PdfTemplate|PdfTilingBrush) {
2347
- this.sender = sender;
2348
- }
2349
- }
2350
- export class PdfGraphicsState {
2351
- // Fields
2352
- /**
2353
- * `Parent graphics` object.
2354
- * @private
2355
- */
2356
- private pdfGraphics : PdfGraphics;
2357
- /**
2358
- * The current `transformation matrix`.
2359
- * @private
2360
- */
2361
- private transformationMatrix : PdfTransformationMatrix;
2362
- /**
2363
- * Stores `previous rendering mode`.
2364
- * @default TextRenderingMode.Fill
2365
- * @private
2366
- */
2367
- private internalTextRenderingMode : TextRenderingMode = TextRenderingMode.Fill;
2368
- /**
2369
- * `Previous character spacing` value or 0.
2370
- * @default 0.0
2371
- * @private
2372
- */
2373
- private internalCharacterSpacing : number = 0.0;
2374
- /**
2375
- * `Previous word spacing` value or 0.
2376
- * @default 0.0
2377
- * @private
2378
- */
2379
- private internalWordSpacing : number = 0.0;
2380
- /**
2381
- * The previously used `text scaling value`.
2382
- * @default 100.0
2383
- * @private
2384
- */
2385
- private internalTextScaling : number = 100.0;
2386
- /**
2387
- * `Current pen`.
2388
- * @private
2389
- */
2390
- private pdfPen : PdfPen;
2391
- /**
2392
- * `Current brush`.
2393
- * @private
2394
- */
2395
- private pdfBrush : PdfBrush;
2396
- /**
2397
- * `Current font`.
2398
- * @private
2399
- */
2400
- private pdfFont : PdfFont;
2401
- /**
2402
- * `Current color space`.
2403
- * @default PdfColorSpace.Rgb
2404
- * @private
2405
- */
2406
- private pdfColorSpace : PdfColorSpace = PdfColorSpace.Rgb;
2407
- // Properties
2408
- /**
2409
- * Gets the parent `graphics object`.
2410
- * @private
2411
- */
2412
- public get graphics() : PdfGraphics {
2413
- return this.pdfGraphics;
2414
- }
2415
- /**
2416
- * Gets the `current matrix`.
2417
- * @private
2418
- */
2419
- public get matrix() : PdfTransformationMatrix {
2420
- return this.transformationMatrix;
2421
- }
2422
- /**
2423
- * Gets or sets the `current character spacing`.
2424
- * @private
2425
- */
2426
- public get characterSpacing() : number {
2427
- return this.internalCharacterSpacing;
2428
- }
2429
- public set characterSpacing(value : number) {
2430
- this.internalCharacterSpacing = value;
2431
- }
2432
- /**
2433
- * Gets or sets the `word spacing` value.
2434
- * @private
2435
- */
2436
- public get wordSpacing() : number {
2437
- return this.internalWordSpacing;
2438
- }
2439
- public set wordSpacing(value : number) {
2440
- this.internalWordSpacing = value;
2441
- }
2442
- /**
2443
- * Gets or sets the `text scaling` value.
2444
- * @private
2445
- */
2446
- public get textScaling() : number {
2447
- return this.internalTextScaling;
2448
- }
2449
- public set textScaling(value : number) {
2450
- this.internalTextScaling = value;
2451
- }
2452
- /**
2453
- * Gets or sets the `current pen` object.
2454
- * @private
2455
- */
2456
- public get pen() : PdfPen {
2457
- return this.pdfPen;
2458
- }
2459
- public set pen(value : PdfPen) {
2460
- this.pdfPen = value;
2461
- }
2462
- /**
2463
- * Gets or sets the `brush`.
2464
- * @private
2465
- */
2466
- public get brush() : PdfBrush {
2467
- return this.pdfBrush;
2468
- }
2469
- public set brush(value : PdfBrush) {
2470
- this.pdfBrush = value;
2471
- }
2472
- /**
2473
- * Gets or sets the `current font` object.
2474
- * @private
2475
- */
2476
- public get font() : PdfFont {
2477
- return this.pdfFont;
2478
- }
2479
- public set font(value : PdfFont) {
2480
- this.pdfFont = value;
2481
- }
2482
- /**
2483
- * Gets or sets the `current color space` value.
2484
- * @private
2485
- */
2486
- public get colorSpace() : PdfColorSpace {
2487
- return this.pdfColorSpace;
2488
- }
2489
- public set colorSpace(value : PdfColorSpace) {
2490
- this.pdfColorSpace = value;
2491
- }
2492
- /**
2493
- * Gets or sets the `text rendering mode`.
2494
- * @private
2495
- */
2496
- public get textRenderingMode() : TextRenderingMode {
2497
- return this.internalTextRenderingMode;
2498
- }
2499
- public set textRenderingMode(value : TextRenderingMode) {
2500
- this.internalTextRenderingMode = value;
2501
- }
2502
-
2503
- // Constructors
2504
- /**
2505
- * `default constructor`.
2506
- * @private
2507
- */
2508
- public constructor()
2509
- /**
2510
- * Creates new object for `PdfGraphicsState`.
2511
- * @private
2512
- */
2513
- public constructor(graphics : PdfGraphics, matrix : PdfTransformationMatrix)
2514
- public constructor(graphics ?: PdfGraphics, matrix ?: PdfTransformationMatrix) {
2515
- if (typeof graphics !== 'undefined') {
2516
- this.pdfGraphics = graphics;
2517
- const elements: number[] = [];
2518
- graphics.matrix.matrix.elements.forEach((element: number) => {
2519
- elements.push(element);
2520
- });
2521
- this.transformationMatrix = new PdfTransformationMatrix();
2522
- this.transformationMatrix.matrix = new Matrix(elements);
2523
- }
2524
- }
2525
- }
2526
- class TransparencyData {
2527
- // Fields
2528
- /**
2529
- * Specifies the `Alpha pen`.
2530
- * @private
2531
- */
2532
- public alphaPen : number;
2533
- /**
2534
- * Specifies the `Alpha brush`.
2535
- * @private
2536
- */
2537
- public alphaBrush : number;
2538
- /**
2539
- * Specifies the `blend mode`.
2540
- * @private
2541
- */
2542
- public blendMode : PdfBlendMode;
2543
- // Constructors
2544
- /**
2545
- * Initializes a new instance of the `TransparencyData` class.
2546
- * @private
2547
- */
2548
- public constructor(alphaPen : number, alphaBrush : number, blendMode : PdfBlendMode) {
2549
- this.alphaPen = alphaPen;
2550
- this.alphaBrush = alphaBrush;
2551
- this.blendMode = blendMode;
2552
- }
2553
- }
2554
- /* tslint:enable */