@syncfusion/ej2-pdf-export 21.2.8 → 22.1.34

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 (163) hide show
  1. package/.eslintrc.json +1 -0
  2. package/CHANGELOG.md +8 -0
  3. package/dist/ej2-pdf-export.min.js +2 -2
  4. package/dist/ej2-pdf-export.umd.min.js +2 -2
  5. package/dist/ej2-pdf-export.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-pdf-export.es2015.js +14 -11
  7. package/dist/es6/ej2-pdf-export.es2015.js.map +1 -1
  8. package/dist/es6/ej2-pdf-export.es5.js +14 -11
  9. package/dist/es6/ej2-pdf-export.es5.js.map +1 -1
  10. package/dist/global/ej2-pdf-export.min.js +2 -2
  11. package/dist/global/ej2-pdf-export.min.js.map +1 -1
  12. package/dist/global/index.d.ts +1 -1
  13. package/dist/ts/implementation/actions/action.ts +76 -0
  14. package/dist/ts/implementation/actions/uri-action.ts +52 -0
  15. package/dist/ts/implementation/annotations/action-link-annotation.ts +43 -0
  16. package/dist/ts/implementation/annotations/annotation-collection.ts +159 -0
  17. package/dist/ts/implementation/annotations/annotation.ts +241 -0
  18. package/dist/ts/implementation/annotations/document-link-annotation.ts +118 -0
  19. package/dist/ts/implementation/annotations/link-annotation.ts +32 -0
  20. package/dist/ts/implementation/annotations/pdf-text-web-link.ts +265 -0
  21. package/dist/ts/implementation/annotations/uri-annotation.ts +86 -0
  22. package/dist/ts/implementation/collections/dictionary.ts +150 -0
  23. package/dist/ts/implementation/collections/object-object-pair/dictionary.ts +125 -0
  24. package/dist/ts/implementation/collections/utils.ts +38 -0
  25. package/dist/ts/implementation/document/automatic-fields/automatic-field-info-collection.ts +39 -0
  26. package/dist/ts/implementation/document/automatic-fields/automatic-field-info.ts +108 -0
  27. package/dist/ts/implementation/document/automatic-fields/automatic-field.ts +127 -0
  28. package/dist/ts/implementation/document/automatic-fields/composite-field.ts +76 -0
  29. package/dist/ts/implementation/document/automatic-fields/multiple-value-field.ts +37 -0
  30. package/dist/ts/implementation/document/automatic-fields/page-count-field.ts +75 -0
  31. package/dist/ts/implementation/document/automatic-fields/pdf-numbers-convertor.ts +157 -0
  32. package/dist/ts/implementation/document/automatic-fields/pdf-page-number-field.ts +82 -0
  33. package/dist/ts/implementation/document/automatic-fields/pdf-template-value-pair.ts +60 -0
  34. package/dist/ts/implementation/document/automatic-fields/single-value-field.ts +48 -0
  35. package/dist/ts/implementation/document/pdf-catalog.ts +52 -0
  36. package/dist/ts/implementation/document/pdf-document-base.ts +166 -0
  37. package/dist/ts/implementation/document/pdf-document-template.ts +310 -0
  38. package/dist/ts/implementation/document/pdf-document.ts +342 -0
  39. package/dist/ts/implementation/drawing/pdf-drawing.ts +218 -0
  40. package/dist/ts/implementation/general/enum.ts +21 -0
  41. package/dist/ts/implementation/general/functions/pdf-function.ts +66 -0
  42. package/dist/ts/implementation/general/functions/pdf-sampled-function.ts +62 -0
  43. package/dist/ts/implementation/general/pdf-cache-collection.ts +97 -0
  44. package/dist/ts/implementation/general/pdf-collection.ts +41 -0
  45. package/dist/ts/implementation/general/pdf-destination.ts +170 -0
  46. package/dist/ts/implementation/graphics/brushes/enum.ts +237 -0
  47. package/dist/ts/implementation/graphics/brushes/pdf-blend.ts +294 -0
  48. package/dist/ts/implementation/graphics/brushes/pdf-brush.ts +68 -0
  49. package/dist/ts/implementation/graphics/brushes/pdf-brushes.ts +2438 -0
  50. package/dist/ts/implementation/graphics/brushes/pdf-color-blend.ts +295 -0
  51. package/dist/ts/implementation/graphics/brushes/pdf-gradient-brush.ts +311 -0
  52. package/dist/ts/implementation/graphics/brushes/pdf-linear-gradient-brush.ts +406 -0
  53. package/dist/ts/implementation/graphics/brushes/pdf-radial-gradient-brush.ts +290 -0
  54. package/dist/ts/implementation/graphics/brushes/pdf-solid-brush.ts +107 -0
  55. package/dist/ts/implementation/graphics/brushes/pdf-tiling-brush.ts +304 -0
  56. package/dist/ts/implementation/graphics/constants.ts +31 -0
  57. package/dist/ts/implementation/graphics/enum.ts +413 -0
  58. package/dist/ts/implementation/graphics/figures/arc.ts +133 -0
  59. package/dist/ts/implementation/graphics/figures/base/draw-element.ts +59 -0
  60. package/dist/ts/implementation/graphics/figures/base/element-layouter.ts +260 -0
  61. package/dist/ts/implementation/graphics/figures/base/fill-element.ts +72 -0
  62. package/dist/ts/implementation/graphics/figures/base/graphics-element.ts +34 -0
  63. package/dist/ts/implementation/graphics/figures/base/pdf-shape-element.ts +69 -0
  64. package/dist/ts/implementation/graphics/figures/base/shape-layouter.ts +276 -0
  65. package/dist/ts/implementation/graphics/figures/base/text-layouter.ts +205 -0
  66. package/dist/ts/implementation/graphics/figures/ellipse-part.ts +76 -0
  67. package/dist/ts/implementation/graphics/figures/enum.ts +80 -0
  68. package/dist/ts/implementation/graphics/figures/layout-element.ts +132 -0
  69. package/dist/ts/implementation/graphics/figures/path.ts +646 -0
  70. package/dist/ts/implementation/graphics/figures/pdf-template.ts +205 -0
  71. package/dist/ts/implementation/graphics/figures/rectangle-area.ts +108 -0
  72. package/dist/ts/implementation/graphics/figures/text-element.ts +445 -0
  73. package/dist/ts/implementation/graphics/fonts/enum.ts +385 -0
  74. package/dist/ts/implementation/graphics/fonts/pdf-font-metrics.ts +248 -0
  75. package/dist/ts/implementation/graphics/fonts/pdf-font.ts +316 -0
  76. package/dist/ts/implementation/graphics/fonts/pdf-standard-font-metrics-factory.ts +606 -0
  77. package/dist/ts/implementation/graphics/fonts/pdf-standard-font.ts +243 -0
  78. package/dist/ts/implementation/graphics/fonts/pdf-string-format.ts +474 -0
  79. package/dist/ts/implementation/graphics/fonts/pdf-true-type-font.ts +165 -0
  80. package/dist/ts/implementation/graphics/fonts/rtl/rtl-bidirectional.ts +958 -0
  81. package/dist/ts/implementation/graphics/fonts/rtl/rtl-text-shape.ts +374 -0
  82. package/dist/ts/implementation/graphics/fonts/rtl-renderer.ts +255 -0
  83. package/dist/ts/implementation/graphics/fonts/string-layouter.ts +617 -0
  84. package/dist/ts/implementation/graphics/fonts/string-tokenizer.ts +275 -0
  85. package/dist/ts/implementation/graphics/fonts/ttf-OS2-Table.ts +206 -0
  86. package/dist/ts/implementation/graphics/fonts/ttf-apple-cmap-sub-table.ts +18 -0
  87. package/dist/ts/implementation/graphics/fonts/ttf-cmap-sub-table.ts +18 -0
  88. package/dist/ts/implementation/graphics/fonts/ttf-cmap-table.ts +14 -0
  89. package/dist/ts/implementation/graphics/fonts/ttf-glyph-header.ts +26 -0
  90. package/dist/ts/implementation/graphics/fonts/ttf-glyph-info.ts +35 -0
  91. package/dist/ts/implementation/graphics/fonts/ttf-head-table.ts +94 -0
  92. package/dist/ts/implementation/graphics/fonts/ttf-horizontal-header-table.ts +56 -0
  93. package/dist/ts/implementation/graphics/fonts/ttf-loca-table.ts +10 -0
  94. package/dist/ts/implementation/graphics/fonts/ttf-long-hor-metric.ts +14 -0
  95. package/dist/ts/implementation/graphics/fonts/ttf-metrics.ts +106 -0
  96. package/dist/ts/implementation/graphics/fonts/ttf-microsoft-cmap-sub-table.ts +58 -0
  97. package/dist/ts/implementation/graphics/fonts/ttf-name-record.ts +33 -0
  98. package/dist/ts/implementation/graphics/fonts/ttf-name-table.ts +22 -0
  99. package/dist/ts/implementation/graphics/fonts/ttf-post-table.ts +42 -0
  100. package/dist/ts/implementation/graphics/fonts/ttf-reader.ts +1254 -0
  101. package/dist/ts/implementation/graphics/fonts/ttf-table-info.ts +26 -0
  102. package/dist/ts/implementation/graphics/fonts/ttf-trimmed-cmap-sub-table.ts +26 -0
  103. package/dist/ts/implementation/graphics/fonts/unicode-true-type-font.ts +577 -0
  104. package/dist/ts/implementation/graphics/images/byte-array.ts +137 -0
  105. package/dist/ts/implementation/graphics/images/image-decoder.ts +439 -0
  106. package/dist/ts/implementation/graphics/images/pdf-bitmap.ts +110 -0
  107. package/dist/ts/implementation/graphics/images/pdf-image.ts +132 -0
  108. package/dist/ts/implementation/graphics/pdf-color.ts +478 -0
  109. package/dist/ts/implementation/graphics/pdf-graphics.ts +2424 -0
  110. package/dist/ts/implementation/graphics/pdf-margins.ts +124 -0
  111. package/dist/ts/implementation/graphics/pdf-pen.ts +370 -0
  112. package/dist/ts/implementation/graphics/pdf-resources.ts +300 -0
  113. package/dist/ts/implementation/graphics/pdf-transformation-matrix.ts +246 -0
  114. package/dist/ts/implementation/graphics/pdf-transparency.ts +93 -0
  115. package/dist/ts/implementation/graphics/unit-convertor.ts +96 -0
  116. package/dist/ts/implementation/input-output/big-endian-writer.ts +121 -0
  117. package/dist/ts/implementation/input-output/cross-table.ts +21 -0
  118. package/dist/ts/implementation/input-output/enum.ts +16 -0
  119. package/dist/ts/implementation/input-output/pdf-cross-table.ts +524 -0
  120. package/dist/ts/implementation/input-output/pdf-dictionary-properties.ts +515 -0
  121. package/dist/ts/implementation/input-output/pdf-main-object-collection.ts +194 -0
  122. package/dist/ts/implementation/input-output/pdf-operators.ts +363 -0
  123. package/dist/ts/implementation/input-output/pdf-stream-writer.ts +681 -0
  124. package/dist/ts/implementation/input-output/pdf-writer.ts +88 -0
  125. package/dist/ts/implementation/pages/enum.ts +201 -0
  126. package/dist/ts/implementation/pages/page-added-event-arguments.ts +39 -0
  127. package/dist/ts/implementation/pages/pdf-document-page-collection.ts +180 -0
  128. package/dist/ts/implementation/pages/pdf-page-base.ts +181 -0
  129. package/dist/ts/implementation/pages/pdf-page-layer-collection.ts +348 -0
  130. package/dist/ts/implementation/pages/pdf-page-layer.ts +271 -0
  131. package/dist/ts/implementation/pages/pdf-page-settings.ts +192 -0
  132. package/dist/ts/implementation/pages/pdf-page-size.ts +162 -0
  133. package/dist/ts/implementation/pages/pdf-page-template-element.ts +659 -0
  134. package/dist/ts/implementation/pages/pdf-page.ts +235 -0
  135. package/dist/ts/implementation/pages/pdf-section-collection.ts +187 -0
  136. package/dist/ts/implementation/pages/pdf-section-page-collection.ts +61 -0
  137. package/dist/ts/implementation/pages/pdf-section-templates.ts +96 -0
  138. package/dist/ts/implementation/pages/pdf-section.ts +644 -0
  139. package/dist/ts/implementation/primitives/pdf-array.ts +386 -0
  140. package/dist/ts/implementation/primitives/pdf-boolean.ts +119 -0
  141. package/dist/ts/implementation/primitives/pdf-dictionary.ts +513 -0
  142. package/dist/ts/implementation/primitives/pdf-name.ts +218 -0
  143. package/dist/ts/implementation/primitives/pdf-number.ts +165 -0
  144. package/dist/ts/implementation/primitives/pdf-reference.ts +430 -0
  145. package/dist/ts/implementation/primitives/pdf-stream.ts +336 -0
  146. package/dist/ts/implementation/primitives/pdf-string.ts +397 -0
  147. package/dist/ts/implementation/structured-elements/grid/layout/grid-layouter.ts +2027 -0
  148. package/dist/ts/implementation/structured-elements/grid/pdf-grid-cell.ts +1193 -0
  149. package/dist/ts/implementation/structured-elements/grid/pdf-grid-column.ts +206 -0
  150. package/dist/ts/implementation/structured-elements/grid/pdf-grid-row.ts +470 -0
  151. package/dist/ts/implementation/structured-elements/grid/pdf-grid.ts +853 -0
  152. package/dist/ts/implementation/structured-elements/grid/styles/pdf-borders.ts +240 -0
  153. package/dist/ts/implementation/structured-elements/grid/styles/style.ts +424 -0
  154. package/dist/ts/implementation/structured-elements/tables/light-tables/enum.ts +16 -0
  155. package/dist/ts/interfaces/i-pdf-cache.ts +23 -0
  156. package/dist/ts/interfaces/i-pdf-changable.ts +17 -0
  157. package/dist/ts/interfaces/i-pdf-clonable.ts +12 -0
  158. package/dist/ts/interfaces/i-pdf-primitives.ts +45 -0
  159. package/dist/ts/interfaces/i-pdf-true-type-font.ts +48 -0
  160. package/dist/ts/interfaces/i-pdf-wrapper.ts +13 -0
  161. package/dist/ts/interfaces/i-pdf-writer.ts +29 -0
  162. package/package.json +6 -6
  163. package/src/implementation/structured-elements/grid/layout/grid-layouter.js +14 -11
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Coordinates of Position for `PointF`.
3
+ * @private
4
+ */
5
+ export class PointF {
6
+ /**
7
+ * Value of `X`.
8
+ * @private
9
+ */
10
+ public x : number;
11
+ /**
12
+ * Value of `Y`.
13
+ * @private
14
+ */
15
+ public y : number;
16
+ //public static readonly empty : PointF = new PointF(0, 0);
17
+ /**
18
+ * Instance of `PointF` class.
19
+ * @private
20
+ */
21
+ constructor()
22
+ /**
23
+ * Instance of `PointF` class with X, Y co-ordinates.
24
+ * @private
25
+ */
26
+ constructor(x : number, y : number)
27
+ constructor(x? : number, y? : number) {
28
+ if (typeof x === 'undefined') {
29
+ this.x = 0;
30
+ this.y = 0;
31
+ } else {
32
+ if (x !== null) {
33
+ this.x = x;
34
+ } else {
35
+ this.x = 0;
36
+ }
37
+ if (y !== null) {
38
+ this.y = y;
39
+ } else {
40
+ this.y = 0;
41
+ }
42
+ }
43
+ }
44
+ }
45
+ /**
46
+ * Width and Height as `Size`.
47
+ * @private
48
+ */
49
+ export class SizeF {
50
+ /**
51
+ * Value of ``Height``.
52
+ * @private
53
+ */
54
+ public height : number;
55
+ /**
56
+ * Value of `Width`.
57
+ * @private
58
+ */
59
+ public width : number;
60
+ //public static readonly empty : SizeF = new SizeF(0, 0);
61
+ /**
62
+ * Instance of `SizeF` class.
63
+ * @private
64
+ */
65
+ constructor()
66
+ /**
67
+ * Instance of `SizeF` class with Width and Height.
68
+ * @private
69
+ */
70
+ constructor(width : number, height : number)
71
+ constructor(width? : number, height? : number) {
72
+ if (typeof height === 'undefined') {
73
+ this.height = 0;
74
+ this.width = 0;
75
+ } else {
76
+ if (height !== null) {
77
+ this.height = height;
78
+ } else {
79
+ this.height = 0;
80
+ }
81
+ if (width !== null) {
82
+ this.width = width;
83
+ } else {
84
+ this.width = 0;
85
+ }
86
+ }
87
+ }
88
+ }
89
+ /**
90
+ * `RectangleF` with Position and size.
91
+ * @private
92
+ */
93
+ export class RectangleF {
94
+ /**
95
+ * Value of `X`.
96
+ * @private
97
+ */
98
+ public x : number;
99
+ /**
100
+ * Value of `Y`.
101
+ * @private
102
+ */
103
+ public y : number;
104
+ /**
105
+ * Value of `Height`.
106
+ * @private
107
+ */
108
+ public height : number;
109
+ /**
110
+ * Value of `Width`.
111
+ * @private
112
+ */
113
+ public width : number;
114
+ /**
115
+ * Instance of `RectangleF` class.
116
+ * @private
117
+ */
118
+ public constructor()
119
+ /**
120
+ * Instance of `RectangleF` class with X, Y, Width and Height.
121
+ * @private
122
+ */
123
+ public constructor(x : number, y : number, height : number, width : number)
124
+ /**
125
+ * Instance of `RectangleF` class with PointF, SizeF.
126
+ * @private
127
+ */
128
+ public constructor(pointF : PointF, sizeF : SizeF)
129
+ public constructor(arg1? : PointF | number, arg2? : SizeF | number, arg3 ?: number, arg4 ?: number ) {
130
+ if (typeof arg1 === typeof arg1 && typeof arg1 === 'undefined') {
131
+ this.x = 0;
132
+ this.y = 0;
133
+ this.height = 0;
134
+ this.width = 0;
135
+ } else {
136
+ if (arg1 instanceof PointF && arg2 instanceof SizeF && typeof arg3 === 'undefined') {
137
+ let pointf : PointF = arg1 as PointF;
138
+ this.x = pointf.x;
139
+ this.y = pointf.y;
140
+ let sizef : SizeF = arg2 as SizeF;
141
+ this.height = sizef.height;
142
+ this.width = sizef.width;
143
+ } else {
144
+ let x : number = arg1 as number;
145
+ let y : number = arg2 as number;
146
+ let width : number = arg3 as number;
147
+ let height : number = arg4 as number;
148
+ this.x = x;
149
+ this.y = y;
150
+ this.height = height;
151
+ this.width = width;
152
+ }
153
+ }
154
+ }
155
+ }
156
+ /**
157
+ * `Rectangle` with left, right, top and bottom.
158
+ * @private
159
+ */
160
+ export class Rectangle {
161
+ /**
162
+ * Value of `left`.
163
+ * @private
164
+ */
165
+ public left : number;
166
+ /**
167
+ * Value of `top`.
168
+ * @private
169
+ */
170
+ public top : number;
171
+ /**
172
+ * Value of `right`.
173
+ * @private
174
+ */
175
+ public right : number;
176
+ /**
177
+ * Value of `bottom`.
178
+ * @private
179
+ */
180
+ public bottom : number;
181
+ /**
182
+ * Instance of `RectangleF` class with X, Y, Width and Height.
183
+ * @private
184
+ */
185
+ public constructor(left : number, top : number, right : number, bottom : number) {
186
+ this.left = left;
187
+ this.top = top;
188
+ this.right = right;
189
+ this.bottom = bottom;
190
+ }
191
+ /**
192
+ * Gets a value of width
193
+ */
194
+ public get width() : number {
195
+ return this.right - this.left;
196
+ }
197
+ /**
198
+ * Gets a value of height
199
+ */
200
+ public get height() : number {
201
+ return this.bottom - this.top;
202
+ }
203
+ /**
204
+ * Gets a value of Top and Left
205
+ */
206
+ public get topLeft() : PointF {
207
+ return new PointF(this.left, this.top);
208
+ }
209
+ /**
210
+ * Gets a value of size
211
+ */
212
+ public get size() : SizeF {
213
+ return new SizeF(this.width, this.height);
214
+ }
215
+ public toString() : string {
216
+ return this.topLeft + 'x' + this.size;
217
+ }
218
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * public Enum for `PdfDestinationMode`.
3
+ * @private
4
+ */
5
+ export enum PdfDestinationMode {
6
+ /**
7
+ * Specifies the type of `Location`.
8
+ * @private
9
+ */
10
+ Location,
11
+ /**
12
+ * Specifies the type of `FitToPage`.
13
+ * @private
14
+ */
15
+ FitToPage,
16
+ /**
17
+ * Specifies the type of `FitR`.
18
+ * @private
19
+ */
20
+ FitR
21
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * PdfFunction.ts class for EJ2-PDF
3
+ * Implements the base class for all functions.
4
+ */
5
+ import { PdfDictionary } from '../../primitives/pdf-dictionary';
6
+ import { IPdfWrapper} from '../../../interfaces/i-pdf-wrapper';
7
+ import { DictionaryProperties } from './../../input-output/pdf-dictionary-properties';
8
+ import { PdfArray } from './../../primitives/pdf-array';
9
+ import { IPdfPrimitive } from './../../../interfaces/i-pdf-primitives';
10
+ export abstract class PdfFunction implements IPdfWrapper {
11
+ //Field
12
+ /**
13
+ * Internal variable to store dictionary.
14
+ * @private
15
+ */
16
+ private mDictionary: PdfDictionary = null;
17
+ /**
18
+ * Local variable to store the dictionary properties.
19
+ * @private
20
+ */
21
+ protected mDictionaryProperties : DictionaryProperties = new DictionaryProperties();
22
+ //Constructor
23
+ /**
24
+ * Initializes a new instance of the `PdfFunction` class.
25
+ * @public
26
+ */
27
+ public constructor(dictionary: PdfDictionary) {
28
+ this.mDictionary = dictionary;
29
+ }
30
+ //Properties
31
+ /**
32
+ * Gets or sets the domain of the function.
33
+ * @public
34
+ */
35
+ protected get domain(): PdfArray {
36
+ let domain: PdfArray = (<PdfArray>this.mDictionary.items.getValue(this.mDictionaryProperties.domain));
37
+ return domain;
38
+ }
39
+ protected set domain(value: PdfArray) {
40
+ this.mDictionary.items.setValue(this.mDictionaryProperties.domain, value);
41
+ }
42
+ /**
43
+ * Gets or sets the range.
44
+ * @public
45
+ */
46
+ protected get range(): PdfArray {
47
+ let range: PdfArray = (<PdfArray>(this.mDictionary.items.getValue(this.mDictionaryProperties.range)));
48
+ return range;
49
+ }
50
+ protected set range(value: PdfArray) {
51
+ this.mDictionary.items.setValue(this.mDictionaryProperties.range, value);
52
+ }
53
+ /**
54
+ * Gets the dictionary.
55
+ */
56
+ protected get dictionary(): PdfDictionary {
57
+ return this.mDictionary;
58
+ }
59
+ //IPdfWrapper Members
60
+ /**
61
+ * Gets the element.
62
+ */
63
+ get element(): IPdfPrimitive {
64
+ return this.mDictionary;
65
+ }
66
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * PdfSampledFunction.ts class for EJ2-PDF
3
+ * Implements PDF Sampled Function.
4
+ */
5
+ import { PdfArray } from './../../primitives/pdf-array';
6
+ import { PdfFunction} from './pdf-function';
7
+ import { PdfStream } from './../../primitives/pdf-stream';
8
+ import { PdfNumber} from './../../primitives/pdf-number';
9
+ export class PdfSampledFunction extends PdfFunction {
10
+ //Constructor
11
+ /**
12
+ * Initializes a new instance of the `PdfSampledFunction` class.
13
+ * @public
14
+ */
15
+ public constructor()
16
+ /**
17
+ * Initializes a new instance of the `PdfSampledFunction` class.
18
+ * @public
19
+ */
20
+ public constructor(domain: number[], range: number[], sizes: number[], samples: number[])
21
+ /**
22
+ * Initializes a new instance of the `PdfSampledFunction` class.
23
+ * @public
24
+ */
25
+ public constructor(domain?: number[], range?: number[], sizes?: number[], samples?: number[]) {
26
+ super(new PdfStream());
27
+ if (typeof domain === 'undefined') {
28
+ this.dictionary.items.setValue(this.mDictionaryProperties.functionType, new PdfNumber(0));
29
+ } else {
30
+ this.dictionary.items.setValue(this.mDictionaryProperties.functionType, new PdfNumber(0));
31
+ this.checkParams(domain, range, sizes, samples);
32
+ this.setDomainAndRange(domain, range);
33
+ this.setSizeAndValues(sizes, samples);
34
+ }
35
+ }
36
+ // Helper methods
37
+ /**
38
+ * Checks the input parameters.
39
+ */
40
+ private checkParams(domain: number[], range: number[], sizes: number[], samples: number[]) : void {
41
+ let rLength: number = range.length;
42
+ let dLength: number = domain.length;
43
+ let sLength: number = samples.length;
44
+ let frameLength: number = (rLength * (dLength / 4));
45
+ }
46
+ /**
47
+ * Sets the domain and range.
48
+ */
49
+ private setDomainAndRange(domain: number[], range: number[]) : void {
50
+ this.domain = new PdfArray(domain);
51
+ this.range = new PdfArray(range);
52
+ }
53
+ /**
54
+ * Sets the size and values.
55
+ */
56
+ private setSizeAndValues(sizes: number[], samples: number[]) : void {
57
+ let s: PdfStream = (<PdfStream>(this.dictionary));
58
+ this.dictionary.items.setValue(this.mDictionaryProperties.size, new PdfArray(sizes));
59
+ this.dictionary.items.setValue(this.mDictionaryProperties.bitsPerSample, new PdfNumber(8));
60
+ s.writeBytes(samples);
61
+ }
62
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * PdfCacheCollection.ts class for EJ2-PDF
3
+ */
4
+ import { Dictionary } from './../collections/dictionary';
5
+ import { PdfFont } from './../graphics/fonts/pdf-font';
6
+ import { IPdfCache } from './../../interfaces/i-pdf-cache';
7
+ /**
8
+ * `Collection of the cached objects`.
9
+ * @private
10
+ */
11
+ export class PdfCacheCollection {
12
+ // Fields
13
+ /**
14
+ * Stores the similar `objects`.
15
+ * @private
16
+ */
17
+ private referenceObjects : Object[][];
18
+ /**
19
+ * Stores the references of font with GUID `objects`.
20
+ * @private
21
+ */
22
+ private pdfFontCollection : Dictionary<string, PdfFont>;
23
+ // Constructors
24
+ /**
25
+ * Initializes a new instance of the `PdfCacheCollection` class.
26
+ * @private
27
+ */
28
+ public constructor() {
29
+ this.referenceObjects = [];
30
+ this.pdfFontCollection = new Dictionary<string, PdfFont>();
31
+ }
32
+ // Public methods
33
+ /**
34
+ * `Searches` for the similar cached object. If is not found - adds the object to the cache.
35
+ * @private
36
+ */
37
+ public search(obj : IPdfCache) : IPdfCache {
38
+ let result : IPdfCache = null;
39
+ let group : Object[] = this.getGroup(obj);
40
+ if (group == null) {
41
+ group = this.createNewGroup();
42
+ } else if (group.length > 0) {
43
+ result = group[0] as IPdfCache;
44
+ }
45
+ group.push(obj);
46
+ return result;
47
+ }
48
+ // Implementation
49
+ /**
50
+ * `Creates` a new group.
51
+ * @private
52
+ */
53
+ public createNewGroup() : Object[] {
54
+ let group : Object[] = [];
55
+ this.referenceObjects.push(group);
56
+ return group;
57
+ }
58
+ /**
59
+ * `Find and Return` a group.
60
+ * @private
61
+ */
62
+ public getGroup(result : IPdfCache) : Object[] {
63
+ let group : Object[] = null;
64
+ if (result !== null) {
65
+ let len : number = this.referenceObjects.length;
66
+ for (let i : number = 0; i < len; i++) {
67
+ if (this.referenceObjects.length > 0) {
68
+ let tGroup : Object[] = this.referenceObjects[i];
69
+ if (tGroup.length > 0) {
70
+ let representative : IPdfCache = tGroup[0] as IPdfCache;
71
+ if (result.equalsTo(representative)) {
72
+ group = tGroup;
73
+ break;
74
+ }
75
+ } else {
76
+ this.removeGroup(tGroup);
77
+ }
78
+ }
79
+ len = this.referenceObjects.length;
80
+ }
81
+ }
82
+ return group;
83
+ }
84
+ /**
85
+ * Remove a group from the storage.
86
+ */
87
+ public removeGroup(group : Object[]) : void {
88
+ if (group !== null) {
89
+ let index : number = this.referenceObjects.indexOf(group);
90
+ this.referenceObjects.slice(index, index + 1);
91
+ }
92
+ }
93
+ public destroy() : void {
94
+ this.pdfFontCollection = undefined;
95
+ this.referenceObjects = undefined;
96
+ }
97
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * PdfCollection.ts class for EJ2-PDF
3
+ * The class used to handle the collection of PdF objects.
4
+ */
5
+ export class PdfCollection {
6
+ // Fields
7
+ /**
8
+ * Stores the `objects` as array.
9
+ * @private
10
+ */
11
+ private collection : Object[];
12
+ // Constructors
13
+ /**
14
+ * Initializes a new instance of the `Collection` class.
15
+ * @private
16
+ */
17
+ public constructor() {
18
+ //
19
+ }
20
+ // Properties
21
+ /**
22
+ * Gets the `Count` of stored objects.
23
+ * @private
24
+ */
25
+ public get count() : number {
26
+ if (typeof this.collection === 'undefined') {
27
+ this.collection = [];
28
+ }
29
+ return this.collection.length;
30
+ }
31
+ /**
32
+ * Gets the `list` of stored objects.
33
+ * @private
34
+ */
35
+ public get list() : Object[] {
36
+ if (typeof this.collection === 'undefined') {
37
+ this.collection = [];
38
+ }
39
+ return this.collection;
40
+ }
41
+ }
@@ -0,0 +1,170 @@
1
+ /**
2
+ * PdfDestination.ts class for EJ2-PDF
3
+ */
4
+ import { IPdfWrapper } from './../../interfaces/i-pdf-wrapper';
5
+ import { IPdfPrimitive } from './../../interfaces/i-pdf-primitives';
6
+ import { PointF, RectangleF } from './../drawing/pdf-drawing';
7
+ import { PdfPageBase } from './../pages/pdf-page-base';
8
+ import { PdfArray } from './../primitives/pdf-array';
9
+ import { PdfPage } from './../pages/pdf-page';
10
+ import { PdfPageRotateAngle } from './../pages/enum';
11
+ import { PdfDestinationMode } from './../general/enum';
12
+ import { PdfSection } from './../pages/pdf-section';
13
+ import { PdfReferenceHolder } from './../primitives/pdf-reference';
14
+ import { PdfName } from './../primitives/pdf-name';
15
+ import { PdfNumber } from './../primitives/pdf-number';
16
+ import { DictionaryProperties } from './../input-output/pdf-dictionary-properties';
17
+ /**
18
+ * `PdfDestination` class represents an anchor in the document
19
+ * where bookmarks or annotations can direct when clicked.
20
+ */
21
+ export class PdfDestination implements IPdfWrapper {
22
+ // Fields
23
+ /**
24
+ * Internal variable for accessing fields from `DictionryProperties` class.
25
+ * @private
26
+ */
27
+ protected dictionaryProperties : DictionaryProperties = new DictionaryProperties();
28
+ /**
29
+ * Type of the `destination`.
30
+ * @private
31
+ */
32
+ private destinationMode : PdfDestinationMode = PdfDestinationMode.Location;
33
+ /**
34
+ * `Zoom` factor.
35
+ * @private
36
+ * @default 0
37
+ */
38
+ private zoomFactor : number = 0;
39
+ /**
40
+ * `Location` of the destination.
41
+ * @default new PointF() with 0 ,0 as co-ordinates
42
+ * @private
43
+ */
44
+ private destinationLocation : PointF = new PointF(0, 0);
45
+ /**
46
+ * `Bounds` of the destination as RectangleF.
47
+ * @default RectangleF.Empty
48
+ * @private
49
+ */
50
+ private bounds : RectangleF = new RectangleF();
51
+ /**
52
+ * Parent `page` reference.
53
+ * @private
54
+ */
55
+ private pdfPage : PdfPageBase;
56
+ /**
57
+ * Pdf primitive representing `this` object.
58
+ * @private
59
+ */
60
+ private array : PdfArray = new PdfArray();
61
+ // Constructors
62
+ /**
63
+ * Initializes a new instance of the `PdfDestination` class with page object.
64
+ * @private
65
+ */
66
+ public constructor(page : PdfPageBase)
67
+ /**
68
+ * Initializes a new instance of the `PdfDestination` class with page object and location.
69
+ * @private
70
+ */
71
+ public constructor(page : PdfPageBase, location : PointF)
72
+ /**
73
+ * Initializes a new instance of the `PdfDestination` class with page object and bounds.
74
+ * @private
75
+ */
76
+ public constructor(page : PdfPageBase, rectangle : RectangleF)
77
+ public constructor(arg1 : PdfPageBase, arg2 ?: RectangleF | PointF) {
78
+ let angle : PdfPageRotateAngle = PdfPageRotateAngle.RotateAngle0;
79
+ this.destinationLocation = new PointF(0, this.destinationLocation.y);
80
+ this.pdfPage = arg1;
81
+ if (arg2 instanceof PointF) {
82
+ this.destinationLocation = arg2;
83
+ } else {
84
+ this.bounds = arg2;
85
+ }
86
+ }
87
+ // Properties
88
+ /**
89
+ * Gets and Sets the `zoom` factor.
90
+ * @private
91
+ */
92
+ public get zoom() : number {
93
+ return this.zoomFactor;
94
+ }
95
+ public set zoom(value : number) {
96
+ this.zoomFactor = value;
97
+ this.initializePrimitive();
98
+ }
99
+ /**
100
+ * Gets and Sets the `page` object.
101
+ * @private
102
+ */
103
+ public get page() : PdfPageBase {
104
+ return this.pdfPage;
105
+ }
106
+ public set page(value : PdfPageBase) {
107
+ this.pdfPage = value;
108
+ this.initializePrimitive();
109
+ }
110
+ /**
111
+ * Gets and Sets the destination `mode`.
112
+ * @private
113
+ */
114
+ public get mode() : PdfDestinationMode {
115
+ return this. destinationMode;
116
+ }
117
+ public set mode(value : PdfDestinationMode) {
118
+ this.destinationMode = value;
119
+ this.initializePrimitive();
120
+ }
121
+ /**
122
+ * Gets and Sets the `location`.
123
+ * @private
124
+ */
125
+ public get location() : PointF {
126
+ return this.destinationLocation;
127
+ }
128
+ public set location(value : PointF) {
129
+ this.destinationLocation = value;
130
+ this.initializePrimitive();
131
+ }
132
+ /**
133
+ * `Translates` co-ordinates to PDF co-ordinate system (lower/left).
134
+ * @private
135
+ */
136
+ private pointToNativePdf(page : PdfPage, point : PointF) : PointF {
137
+ let section : PdfSection = page.section;
138
+ return section.pointToNativePdf(page, point);
139
+ }
140
+ /**
141
+ * `In fills` array by correct values.
142
+ * @private
143
+ */
144
+ private initializePrimitive() : void {
145
+ this.array.clear();
146
+ this.array.add(new PdfReferenceHolder(this.pdfPage));
147
+ switch (this.destinationMode) {
148
+ case PdfDestinationMode.Location:
149
+ let simplePage : PdfPage = this.pdfPage as PdfPage;
150
+ let point : PointF = new PointF();
151
+ point = this.pointToNativePdf(simplePage, this.destinationLocation);
152
+ this.array.add(new PdfName(this.dictionaryProperties.xyz));
153
+ this.array.add(new PdfNumber(point.x));
154
+ this.array.add(new PdfNumber(point.y));
155
+ this.array.add(new PdfNumber(this.zoomFactor));
156
+ break;
157
+ case PdfDestinationMode.FitToPage:
158
+ this.array.add(new PdfName(this.dictionaryProperties.fit));
159
+ break;
160
+ }
161
+ }
162
+ /**
163
+ * Gets the `element` representing this object.
164
+ * @private
165
+ */
166
+ public get element() : IPdfPrimitive {
167
+ this.initializePrimitive();
168
+ return this.array;
169
+ }
170
+ }