@syncfusion/ej2-pdf-export 20.3.47 → 20.4.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.eslintrc.json +16 -1
  2. package/dist/ej2-pdf-export.min.js +1 -1
  3. package/dist/ej2-pdf-export.umd.min.js +1 -1
  4. package/dist/global/ej2-pdf-export.min.js +1 -1
  5. package/dist/global/index.d.ts +1 -1
  6. package/package.json +7 -8
  7. package/dist/ts/implementation/actions/action.ts +0 -76
  8. package/dist/ts/implementation/actions/uri-action.ts +0 -52
  9. package/dist/ts/implementation/annotations/action-link-annotation.ts +0 -43
  10. package/dist/ts/implementation/annotations/annotation-collection.ts +0 -159
  11. package/dist/ts/implementation/annotations/annotation.ts +0 -241
  12. package/dist/ts/implementation/annotations/document-link-annotation.ts +0 -118
  13. package/dist/ts/implementation/annotations/link-annotation.ts +0 -32
  14. package/dist/ts/implementation/annotations/pdf-text-web-link.ts +0 -265
  15. package/dist/ts/implementation/annotations/uri-annotation.ts +0 -86
  16. package/dist/ts/implementation/collections/dictionary.ts +0 -150
  17. package/dist/ts/implementation/collections/object-object-pair/dictionary.ts +0 -125
  18. package/dist/ts/implementation/collections/utils.ts +0 -38
  19. package/dist/ts/implementation/document/automatic-fields/automatic-field-info-collection.ts +0 -39
  20. package/dist/ts/implementation/document/automatic-fields/automatic-field-info.ts +0 -108
  21. package/dist/ts/implementation/document/automatic-fields/automatic-field.ts +0 -127
  22. package/dist/ts/implementation/document/automatic-fields/composite-field.ts +0 -76
  23. package/dist/ts/implementation/document/automatic-fields/multiple-value-field.ts +0 -37
  24. package/dist/ts/implementation/document/automatic-fields/page-count-field.ts +0 -75
  25. package/dist/ts/implementation/document/automatic-fields/pdf-numbers-convertor.ts +0 -157
  26. package/dist/ts/implementation/document/automatic-fields/pdf-page-number-field.ts +0 -82
  27. package/dist/ts/implementation/document/automatic-fields/pdf-template-value-pair.ts +0 -60
  28. package/dist/ts/implementation/document/automatic-fields/single-value-field.ts +0 -48
  29. package/dist/ts/implementation/document/pdf-catalog.ts +0 -52
  30. package/dist/ts/implementation/document/pdf-document-base.ts +0 -166
  31. package/dist/ts/implementation/document/pdf-document-template.ts +0 -310
  32. package/dist/ts/implementation/document/pdf-document.ts +0 -342
  33. package/dist/ts/implementation/drawing/pdf-drawing.ts +0 -218
  34. package/dist/ts/implementation/general/enum.ts +0 -21
  35. package/dist/ts/implementation/general/functions/pdf-function.ts +0 -66
  36. package/dist/ts/implementation/general/functions/pdf-sampled-function.ts +0 -62
  37. package/dist/ts/implementation/general/pdf-cache-collection.ts +0 -97
  38. package/dist/ts/implementation/general/pdf-collection.ts +0 -41
  39. package/dist/ts/implementation/general/pdf-destination.ts +0 -170
  40. package/dist/ts/implementation/graphics/brushes/enum.ts +0 -237
  41. package/dist/ts/implementation/graphics/brushes/pdf-blend.ts +0 -294
  42. package/dist/ts/implementation/graphics/brushes/pdf-brush.ts +0 -68
  43. package/dist/ts/implementation/graphics/brushes/pdf-brushes.ts +0 -2438
  44. package/dist/ts/implementation/graphics/brushes/pdf-color-blend.ts +0 -295
  45. package/dist/ts/implementation/graphics/brushes/pdf-gradient-brush.ts +0 -311
  46. package/dist/ts/implementation/graphics/brushes/pdf-linear-gradient-brush.ts +0 -406
  47. package/dist/ts/implementation/graphics/brushes/pdf-radial-gradient-brush.ts +0 -290
  48. package/dist/ts/implementation/graphics/brushes/pdf-solid-brush.ts +0 -107
  49. package/dist/ts/implementation/graphics/brushes/pdf-tiling-brush.ts +0 -304
  50. package/dist/ts/implementation/graphics/constants.ts +0 -31
  51. package/dist/ts/implementation/graphics/enum.ts +0 -413
  52. package/dist/ts/implementation/graphics/figures/arc.ts +0 -133
  53. package/dist/ts/implementation/graphics/figures/base/draw-element.ts +0 -59
  54. package/dist/ts/implementation/graphics/figures/base/element-layouter.ts +0 -260
  55. package/dist/ts/implementation/graphics/figures/base/fill-element.ts +0 -72
  56. package/dist/ts/implementation/graphics/figures/base/graphics-element.ts +0 -34
  57. package/dist/ts/implementation/graphics/figures/base/pdf-shape-element.ts +0 -69
  58. package/dist/ts/implementation/graphics/figures/base/shape-layouter.ts +0 -276
  59. package/dist/ts/implementation/graphics/figures/base/text-layouter.ts +0 -205
  60. package/dist/ts/implementation/graphics/figures/ellipse-part.ts +0 -76
  61. package/dist/ts/implementation/graphics/figures/enum.ts +0 -80
  62. package/dist/ts/implementation/graphics/figures/layout-element.ts +0 -132
  63. package/dist/ts/implementation/graphics/figures/path.ts +0 -646
  64. package/dist/ts/implementation/graphics/figures/pdf-template.ts +0 -205
  65. package/dist/ts/implementation/graphics/figures/rectangle-area.ts +0 -108
  66. package/dist/ts/implementation/graphics/figures/text-element.ts +0 -445
  67. package/dist/ts/implementation/graphics/fonts/enum.ts +0 -385
  68. package/dist/ts/implementation/graphics/fonts/pdf-font-metrics.ts +0 -248
  69. package/dist/ts/implementation/graphics/fonts/pdf-font.ts +0 -316
  70. package/dist/ts/implementation/graphics/fonts/pdf-standard-font-metrics-factory.ts +0 -606
  71. package/dist/ts/implementation/graphics/fonts/pdf-standard-font.ts +0 -243
  72. package/dist/ts/implementation/graphics/fonts/pdf-string-format.ts +0 -474
  73. package/dist/ts/implementation/graphics/fonts/pdf-true-type-font.ts +0 -165
  74. package/dist/ts/implementation/graphics/fonts/rtl/rtl-bidirectional.ts +0 -958
  75. package/dist/ts/implementation/graphics/fonts/rtl/rtl-text-shape.ts +0 -374
  76. package/dist/ts/implementation/graphics/fonts/rtl-renderer.ts +0 -255
  77. package/dist/ts/implementation/graphics/fonts/string-layouter.ts +0 -617
  78. package/dist/ts/implementation/graphics/fonts/string-tokenizer.ts +0 -275
  79. package/dist/ts/implementation/graphics/fonts/ttf-OS2-Table.ts +0 -206
  80. package/dist/ts/implementation/graphics/fonts/ttf-apple-cmap-sub-table.ts +0 -18
  81. package/dist/ts/implementation/graphics/fonts/ttf-cmap-sub-table.ts +0 -18
  82. package/dist/ts/implementation/graphics/fonts/ttf-cmap-table.ts +0 -14
  83. package/dist/ts/implementation/graphics/fonts/ttf-glyph-header.ts +0 -26
  84. package/dist/ts/implementation/graphics/fonts/ttf-glyph-info.ts +0 -35
  85. package/dist/ts/implementation/graphics/fonts/ttf-head-table.ts +0 -94
  86. package/dist/ts/implementation/graphics/fonts/ttf-horizontal-header-table.ts +0 -56
  87. package/dist/ts/implementation/graphics/fonts/ttf-loca-table.ts +0 -10
  88. package/dist/ts/implementation/graphics/fonts/ttf-long-hor-metric.ts +0 -14
  89. package/dist/ts/implementation/graphics/fonts/ttf-metrics.ts +0 -106
  90. package/dist/ts/implementation/graphics/fonts/ttf-microsoft-cmap-sub-table.ts +0 -58
  91. package/dist/ts/implementation/graphics/fonts/ttf-name-record.ts +0 -33
  92. package/dist/ts/implementation/graphics/fonts/ttf-name-table.ts +0 -22
  93. package/dist/ts/implementation/graphics/fonts/ttf-post-table.ts +0 -42
  94. package/dist/ts/implementation/graphics/fonts/ttf-reader.ts +0 -1254
  95. package/dist/ts/implementation/graphics/fonts/ttf-table-info.ts +0 -26
  96. package/dist/ts/implementation/graphics/fonts/ttf-trimmed-cmap-sub-table.ts +0 -26
  97. package/dist/ts/implementation/graphics/fonts/unicode-true-type-font.ts +0 -577
  98. package/dist/ts/implementation/graphics/images/byte-array.ts +0 -137
  99. package/dist/ts/implementation/graphics/images/image-decoder.ts +0 -437
  100. package/dist/ts/implementation/graphics/images/pdf-bitmap.ts +0 -110
  101. package/dist/ts/implementation/graphics/images/pdf-image.ts +0 -132
  102. package/dist/ts/implementation/graphics/pdf-color.ts +0 -478
  103. package/dist/ts/implementation/graphics/pdf-graphics.ts +0 -2424
  104. package/dist/ts/implementation/graphics/pdf-margins.ts +0 -124
  105. package/dist/ts/implementation/graphics/pdf-pen.ts +0 -370
  106. package/dist/ts/implementation/graphics/pdf-resources.ts +0 -300
  107. package/dist/ts/implementation/graphics/pdf-transformation-matrix.ts +0 -246
  108. package/dist/ts/implementation/graphics/pdf-transparency.ts +0 -93
  109. package/dist/ts/implementation/graphics/unit-convertor.ts +0 -96
  110. package/dist/ts/implementation/input-output/big-endian-writer.ts +0 -121
  111. package/dist/ts/implementation/input-output/cross-table.ts +0 -21
  112. package/dist/ts/implementation/input-output/enum.ts +0 -16
  113. package/dist/ts/implementation/input-output/pdf-cross-table.ts +0 -524
  114. package/dist/ts/implementation/input-output/pdf-dictionary-properties.ts +0 -515
  115. package/dist/ts/implementation/input-output/pdf-main-object-collection.ts +0 -194
  116. package/dist/ts/implementation/input-output/pdf-operators.ts +0 -363
  117. package/dist/ts/implementation/input-output/pdf-stream-writer.ts +0 -681
  118. package/dist/ts/implementation/input-output/pdf-writer.ts +0 -88
  119. package/dist/ts/implementation/pages/enum.ts +0 -201
  120. package/dist/ts/implementation/pages/page-added-event-arguments.ts +0 -39
  121. package/dist/ts/implementation/pages/pdf-document-page-collection.ts +0 -180
  122. package/dist/ts/implementation/pages/pdf-page-base.ts +0 -181
  123. package/dist/ts/implementation/pages/pdf-page-layer-collection.ts +0 -348
  124. package/dist/ts/implementation/pages/pdf-page-layer.ts +0 -271
  125. package/dist/ts/implementation/pages/pdf-page-settings.ts +0 -192
  126. package/dist/ts/implementation/pages/pdf-page-size.ts +0 -162
  127. package/dist/ts/implementation/pages/pdf-page-template-element.ts +0 -659
  128. package/dist/ts/implementation/pages/pdf-page.ts +0 -235
  129. package/dist/ts/implementation/pages/pdf-section-collection.ts +0 -187
  130. package/dist/ts/implementation/pages/pdf-section-page-collection.ts +0 -61
  131. package/dist/ts/implementation/pages/pdf-section-templates.ts +0 -96
  132. package/dist/ts/implementation/pages/pdf-section.ts +0 -644
  133. package/dist/ts/implementation/primitives/pdf-array.ts +0 -386
  134. package/dist/ts/implementation/primitives/pdf-boolean.ts +0 -119
  135. package/dist/ts/implementation/primitives/pdf-dictionary.ts +0 -513
  136. package/dist/ts/implementation/primitives/pdf-name.ts +0 -218
  137. package/dist/ts/implementation/primitives/pdf-number.ts +0 -165
  138. package/dist/ts/implementation/primitives/pdf-reference.ts +0 -430
  139. package/dist/ts/implementation/primitives/pdf-stream.ts +0 -336
  140. package/dist/ts/implementation/primitives/pdf-string.ts +0 -397
  141. package/dist/ts/implementation/structured-elements/grid/layout/grid-layouter.ts +0 -2027
  142. package/dist/ts/implementation/structured-elements/grid/pdf-grid-cell.ts +0 -1189
  143. package/dist/ts/implementation/structured-elements/grid/pdf-grid-column.ts +0 -206
  144. package/dist/ts/implementation/structured-elements/grid/pdf-grid-row.ts +0 -470
  145. package/dist/ts/implementation/structured-elements/grid/pdf-grid.ts +0 -853
  146. package/dist/ts/implementation/structured-elements/grid/styles/pdf-borders.ts +0 -240
  147. package/dist/ts/implementation/structured-elements/grid/styles/style.ts +0 -424
  148. package/dist/ts/implementation/structured-elements/tables/light-tables/enum.ts +0 -16
  149. package/dist/ts/interfaces/i-pdf-cache.ts +0 -23
  150. package/dist/ts/interfaces/i-pdf-changable.ts +0 -17
  151. package/dist/ts/interfaces/i-pdf-clonable.ts +0 -12
  152. package/dist/ts/interfaces/i-pdf-primitives.ts +0 -45
  153. package/dist/ts/interfaces/i-pdf-true-type-font.ts +0 -48
  154. package/dist/ts/interfaces/i-pdf-wrapper.ts +0 -13
  155. package/dist/ts/interfaces/i-pdf-writer.ts +0 -29
@@ -1,374 +0,0 @@
1
- /**
2
- * ArabicShapeRenderer.ts class for EJ2-PDF
3
- */
4
- import { Dictionary} from './../../../collections/dictionary';
5
- export class ArabicShapeRenderer {
6
- //#region Constants
7
- private readonly arabicCharTable : string[][] = [['\u0621', '\uFE80'], ['\u0622', '\uFE81', '\uFE82'],
8
- ['\u0623', '\uFE83', '\uFE84'],
9
- ['\u0624', '\uFE85', '\uFE86'],
10
- ['\u0625', '\uFE87', '\uFE88'],
11
- ['\u0626', '\uFE89', '\uFE8A', '\uFE8B', '\uFE8C'],
12
- ['\u0627', '\uFE8D', '\uFE8E'],
13
- ['\u0628', '\uFE8F', '\uFE90', '\uFE91', '\uFE92'],
14
- ['\u0629', '\uFE93', '\uFE94'],
15
- ['\u062A', '\uFE95', '\uFE96', '\uFE97', '\uFE98'],
16
- ['\u062B', '\uFE99', '\uFE9A', '\uFE9B', '\uFE9C'],
17
- ['\u062C', '\uFE9D', '\uFE9E', '\uFE9F', '\uFEA0'],
18
- ['\u062D', '\uFEA1', '\uFEA2', '\uFEA3', '\uFEA4'],
19
- ['\u062E', '\uFEA5', '\uFEA6', '\uFEA7', '\uFEA8'],
20
- ['\u062F', '\uFEA9', '\uFEAA'],
21
- ['\u0630', '\uFEAB', '\uFEAC'],
22
- ['\u0631', '\uFEAD', '\uFEAE'],
23
- ['\u0632', '\uFEAF', '\uFEB0'],
24
- ['\u0633', '\uFEB1', '\uFEB2', '\uFEB3', '\uFEB4'],
25
- ['\u0634', '\uFEB5', '\uFEB6', '\uFEB7', '\uFEB8'],
26
- ['\u0635', '\uFEB9', '\uFEBA', '\uFEBB', '\uFEBC'],
27
- ['\u0636', '\uFEBD', '\uFEBE', '\uFEBF', '\uFEC0'],
28
- ['\u0637', '\uFEC1', '\uFEC2', '\uFEC3', '\uFEC4'],
29
- ['\u0638', '\uFEC5', '\uFEC6', '\uFEC7', '\uFEC8'],
30
- ['\u0639', '\uFEC9', '\uFECA', '\uFECB', '\uFECC'],
31
- ['\u063A', '\uFECD', '\uFECE', '\uFECF', '\uFED0'],
32
- ['\u0640', '\u0640', '\u0640', '\u0640', '\u0640'],
33
- ['\u0641', '\uFED1', '\uFED2', '\uFED3', '\uFED4'],
34
- ['\u0642', '\uFED5', '\uFED6', '\uFED7', '\uFED8'],
35
- ['\u0643', '\uFED9', '\uFEDA', '\uFEDB', '\uFEDC'],
36
- ['\u0644', '\uFEDD', '\uFEDE', '\uFEDF', '\uFEE0'],
37
- ['\u0645', '\uFEE1', '\uFEE2', '\uFEE3', '\uFEE4'],
38
- ['\u0646', '\uFEE5', '\uFEE6', '\uFEE7', '\uFEE8'],
39
- ['\u0647', '\uFEE9', '\uFEEA', '\uFEEB', '\uFEEC'],
40
- ['\u0648', '\uFEED', '\uFEEE'],
41
- ['\u0649', '\uFEEF', '\uFEF0', '\uFBE8', '\uFBE9'],
42
- ['\u064A', '\uFEF1', '\uFEF2', '\uFEF3', '\uFEF4'],
43
- ['\u0671', '\uFB50', '\uFB51'],
44
- ['\u0679', '\uFB66', '\uFB67', '\uFB68', '\uFB69'],
45
- ['\u067A', '\uFB5E', '\uFB5F', '\uFB60', '\uFB61'],
46
- ['\u067B', '\uFB52', '\uFB53', '\uFB54', '\uFB55'],
47
- ['\u067E', '\uFB56', '\uFB57', '\uFB58', '\uFB59'],
48
- ['\u067F', '\uFB62', '\uFB63', '\uFB64', '\uFB65'],
49
- ['\u0680', '\uFB5A', '\uFB5B', '\uFB5C', '\uFB5D'],
50
- ['\u0683', '\uFB76', '\uFB77', '\uFB78', '\uFB79'],
51
- ['\u0684', '\uFB72', '\uFB73', '\uFB74', '\uFB75'],
52
- ['\u0686', '\uFB7A', '\uFB7B', '\uFB7C', '\uFB7D'],
53
- ['\u0687', '\uFB7E', '\uFB7F', '\uFB80', '\uFB81'],
54
- ['\u0688', '\uFB88', '\uFB89'],
55
- ['\u068C', '\uFB84', '\uFB85'],
56
- ['\u068D', '\uFB82', '\uFB83'],
57
- ['\u068E', '\uFB86', '\uFB87'],
58
- ['\u0691', '\uFB8C', '\uFB8D'],
59
- ['\u0698', '\uFB8A', '\uFB8B'],
60
- ['\u06A4', '\uFB6A', '\uFB6B', '\uFB6C', '\uFB6D'],
61
- ['\u06A6', '\uFB6E', '\uFB6F', '\uFB70', '\uFB71'],
62
- ['\u06A9', '\uFB8E', '\uFB8F', '\uFB90', '\uFB91'],
63
- ['\u06AD', '\uFBD3', '\uFBD4', '\uFBD5', '\uFBD6'],
64
- ['\u06AF', '\uFB92', '\uFB93', '\uFB94', '\uFB95'],
65
- ['\u06B1', '\uFB9A', '\uFB9B', '\uFB9C', '\uFB9D'],
66
- ['\u06B3', '\uFB96', '\uFB97', '\uFB98', '\uFB99'],
67
- ['\u06BA', '\uFB9E', '\uFB9F'],
68
- ['\u06BB', '\uFBA0', '\uFBA1', '\uFBA2', '\uFBA3'],
69
- ['\u06BE', '\uFBAA', '\uFBAB', '\uFBAC', '\uFBAD'],
70
- ['\u06C0', '\uFBA4', '\uFBA5'],
71
- ['\u06C1', '\uFBA6', '\uFBA7', '\uFBA8', '\uFBA9'],
72
- ['\u06C5', '\uFBE0', '\uFBE1'],
73
- ['\u06C6', '\uFBD9', '\uFBDA'],
74
- ['\u06C7', '\uFBD7', '\uFBD8'],
75
- ['\u06C8', '\uFBDB', '\uFBDC'],
76
- ['\u06C9', '\uFBE2', '\uFBE3'],
77
- ['\u06CB', '\uFBDE', '\uFBDF'],
78
- ['\u06CC', '\uFBFC', '\uFBFD', '\uFBFE', '\uFBFF'],
79
- ['\u06D0', '\uFBE4', '\uFBE5', '\uFBE6', '\uFBE7'],
80
- ['\u06D2', '\uFBAE', '\uFBAF'],
81
- ['\u06D3', '\uFBB0', '\uFBB1']
82
- ];
83
- private readonly alef : string = '\u0627';
84
- private readonly alefHamza : string = '\u0623';
85
- private readonly alefHamzaBelow : string = '\u0625';
86
- private readonly alefMadda : string = '\u0622';
87
- private readonly lam : string = '\u0644';
88
- private readonly hamza : string = '\u0621';
89
- private readonly zeroWidthJoiner : string = '\u200D';
90
- private readonly hamzaAbove : string = '\u0654';
91
- private readonly hamzaBelow : string = '\u0655';
92
- private readonly wawHamza : string = '\u0624';
93
- private readonly yehHamza : string = '\u0626';
94
- private readonly waw : string = '\u0648';
95
- private readonly alefMaksura : string = '\u0649';
96
- private readonly yeh : string = '\u064A';
97
- private readonly farsiYeh : string = '\u06CC';
98
- private readonly shadda : string = '\u0651';
99
- private readonly madda : string = '\u0653';
100
- private readonly lwa : string = '\uFEFB';
101
- private readonly lwawh : string = '\uFEF7';
102
- private readonly lwawhb : string = '\uFEF9';
103
- private readonly lwawm : string = '\uFEF5';
104
- private readonly bwhb : string = '\u06D3';
105
- private readonly fathatan : string = '\u064B';
106
- private readonly superScriptalef : string = '\u0670';
107
- private readonly vowel : number = 0x1;
108
- // #endregion
109
- //#region Fields
110
- private arabicMapTable : Dictionary<string, string[]> = new Dictionary<string, string[]>();
111
- //#endregion
112
- //#region Constructor
113
- public constructor() {
114
- for (let i : number = 0; i < this.arabicCharTable.length; i++) {
115
- this.arabicMapTable.setValue(this.arabicCharTable[i][0], this.arabicCharTable[i]);
116
- }
117
- }
118
- //#endregion
119
- //#region implementation
120
- private getCharacterShape( input : string, index : number) : string {
121
- if ((input >= this.hamza) && (input <= this.bwhb)) {
122
- let value : string[] = [];
123
- if (this.arabicMapTable.getValue(input)) {
124
- value = this.arabicMapTable.getValue(input);
125
- return value[index + 1];
126
- }
127
- } else if (input >= this.lwawm && input <= this.lwa) {
128
- return (input) as string;
129
- }
130
- return input;
131
- }
132
- public shape( text : string, level : number) : string {
133
- let builder : string = '';
134
- let str2 : string = '';
135
- for (let i : number = 0; i < text.length; i++) {
136
- let c : string = text[i];
137
- if (c >= '؀' && c <= 'ۿ') {
138
- //if(c>= 0x0600.toString() && c<= 0x06FF.toString()) {
139
- str2 = str2 + c;
140
- } else {
141
- if (str2.length > 0) {
142
- let st : string = this.doShape(str2.toString(), 0);
143
- builder = builder + st;
144
- str2 = '';
145
- }
146
- builder = builder + c;
147
- }
148
- }
149
- if (str2.length > 0) {
150
- let st : string = this.doShape(str2.toString(), 0);
151
- builder = builder + st;
152
- }
153
- return builder.toString();
154
- }
155
- private doShape(input : string, level: number) : string {
156
- let str : string = '';
157
- let ligature : number = 0;
158
- let len : number = 0;
159
- let i : number = 0;
160
- let next : string = '';
161
- let previous : ArabicShape = new ArabicShape();
162
- let present : ArabicShape = new ArabicShape();
163
- while (i < input.length) {
164
- next = input[i++];
165
- ligature = this.ligature(next, present);
166
- if (ligature === 0) {
167
- let shapeCount : number = this.getShapeCount(next);
168
- len = (shapeCount === 1) ? 0 : 2;
169
- if (previous.Shapes > 2) {
170
- len += 1;
171
- }
172
- len = len % (present.Shapes);
173
- present.Value = this.getCharacterShape(present.Value, len);
174
- str = this.append(str, previous, level);
175
- previous = present;
176
- present = new ArabicShape();
177
- present.Value = next;
178
- present.Shapes = shapeCount;
179
- present.Ligature++;
180
- }
181
- }
182
- len = (previous.Shapes > 2) ? 1 : 0;
183
- len = len % (present.Shapes);
184
- present.Value = this.getCharacterShape(present.Value, len);
185
- str = this.append(str, previous, level);
186
- str = this.append(str, present, level);
187
- return str.toString();
188
- }
189
- private append( builder : string, shape : ArabicShape, level : number) : string {
190
- if (shape.Value !== '') {
191
- builder = builder + shape.Value;
192
- shape.Ligature -= 1;
193
- if (shape.Type !== '') {
194
- if ((level & this.vowel) === 0) {
195
- builder = builder + shape.Type;
196
- shape.Ligature -= 1;
197
- } else {
198
- shape.Ligature -= 1;
199
- }
200
- }
201
- if (shape.vowel !== '') {
202
- if ((level & this.vowel) === 0) {
203
- builder = builder + shape.vowel;
204
- shape.Ligature -= 1;
205
- } else {
206
- shape.Ligature -= 1;
207
- }
208
- }
209
- }
210
- return builder;
211
- }
212
- private ligature(value : string, shape : ArabicShape): number {
213
- if (shape.Value !== '') {
214
- let result : number = 0;
215
- if ((value >= this.fathatan && value <= this.hamzaBelow) || value === this.superScriptalef) {
216
- result = 1;
217
- if ((shape.vowel !== '') && (value !== this.shadda)) {
218
- result = 2;
219
- }
220
- if (value === this.shadda) {
221
- if (shape.Type == null) {
222
- shape.Type = this.shadda;
223
- } else {
224
- return 0;
225
- }
226
- } else if (value === this.hamzaBelow) {
227
- if (shape.Value === this.alef) {
228
- shape.Value = this.alefHamzaBelow;
229
- result = 2;
230
- } else if (value === this.lwa) {
231
- shape.Value = this.lwawhb;
232
- result = 2;
233
- } else {
234
- shape.Type = this.hamzaBelow;
235
- }
236
- } else if (value === this.hamzaAbove) {
237
- if (shape.Value === this.alef) {
238
- shape.Value = this.alefHamza;
239
- result = 2;
240
- } else if (shape.Value === this.lwa) {
241
- shape.Value = this.lwawh;
242
- result = 2;
243
- } else if (shape.Value === this.waw) {
244
- shape.Value = this.wawHamza;
245
- result = 2;
246
- } else if (shape.Value === this.yeh || shape.Value === this.alefMaksura || shape.Value === this.farsiYeh) {
247
- shape.Value = this.yehHamza;
248
- result = 2;
249
- } else {
250
- shape.Type = this.hamzaAbove;
251
- }
252
- } else if (value === this.madda) {
253
- if (shape.Value === this.alef) {
254
- shape.Value = this.alefMadda;
255
- result = 2;
256
- }
257
- } else {
258
- shape.vowel = value;
259
- }
260
- if (result === 1) {
261
- shape.Ligature++;
262
- }
263
- return result;
264
- }
265
- if (shape.vowel !== '') {
266
- return 0;
267
- }
268
- if (shape.Value === this.lam) {
269
- if (value === this.alef) {
270
- shape.Value = this.lwa;
271
- shape.Shapes = 2;
272
- result = 3;
273
- } else if (value === this.alefHamza) {
274
- shape.Value = this.lwawh;
275
- shape.Shapes = 2;
276
- result = 3;
277
- } else if (value === this.alefHamzaBelow) {
278
- shape.Value = this.lwawhb;
279
- shape.Shapes = 2;
280
- result = 3;
281
- } else if (value === this.alefMadda) {
282
- shape.Value = this.lwawm;
283
- shape.Shapes = 2;
284
- result = 3;
285
- }
286
- }
287
- // else if (shape.Value === '') {
288
- // shape.Value = value;
289
- // shape.Shapes = this.getShapeCount(value);
290
- // result = 1;
291
- // }
292
- return result;
293
- } else {
294
- return 0;
295
- }
296
- }
297
- private getShapeCount(shape : string): number {
298
- if ((shape >= this.hamza) && (shape <= this.bwhb) && !((shape >= this.fathatan && shape <= this.hamzaBelow)
299
- || shape === this.superScriptalef)) {
300
- let c : string[] = [];
301
- if (this.arabicMapTable.getValue(shape)) {
302
- c = this.arabicMapTable.getValue(shape);
303
- return c.length - 1;
304
- }
305
- } else if (shape === this.zeroWidthJoiner) {
306
- return 4;
307
- }
308
- return 1;
309
- }
310
- }
311
- //#endregion
312
- //#region Internals
313
- export class ArabicShape {
314
- //#region Fields
315
- private shapeValue : string = '';
316
- private shapeType : string = '';
317
- private shapeVowel : string = '';
318
- private shapeLigature : number = 0;
319
- private shapeShapes : number = 1;
320
- //#endregion
321
- //#region Properties
322
- /**
323
- * Gets or sets the values.
324
- * @private
325
- */
326
- public get Value() : string {
327
- return this.shapeValue;
328
- }
329
- public set Value(value : string) {
330
- this.shapeValue = value;
331
- }
332
- /**
333
- * Gets or sets the values.
334
- * @private
335
- */
336
- public get Type() : string {
337
- return this.shapeType;
338
- }
339
- public set Type(value : string) {
340
- this.shapeType = value;
341
- }
342
- /**
343
- * Gets or sets the values.
344
- * @private
345
- */
346
- public get vowel() : string {
347
- return this.shapeVowel;
348
- }
349
- public set vowel(value : string) {
350
- this.shapeVowel = value;
351
- }
352
- /**
353
- * Gets or sets the values.
354
- * @private
355
- */
356
- public get Ligature() : number {
357
- return this.shapeLigature;
358
- }
359
- public set Ligature(value : number) {
360
- this.shapeLigature = value;
361
- }
362
- /**
363
- * Gets or sets the values.
364
- * @private
365
- */
366
- public get Shapes() : number {
367
- return this.shapeShapes;
368
- }
369
- public set Shapes(value : number) {
370
- this.shapeShapes = value;
371
- }
372
- //#endregion
373
- }
374
- //#endregion
@@ -1,255 +0,0 @@
1
- /**
2
- * RTL-Renderer.ts class for EJ2-PDF
3
- */
4
- import { PdfStringFormat } from './pdf-string-format';
5
- import { PdfTrueTypeFont} from './pdf-true-type-font';
6
- import { UnicodeTrueTypeFont } from './unicode-true-type-font';
7
- import { TtfReader} from './ttf-reader';
8
- import { PdfString} from './../../primitives/pdf-string';
9
- import { ArabicShapeRenderer} from './rtl/rtl-text-shape';
10
- import { PdfTextDirection} from './../enum';
11
- import { Bidi} from './rtl/rtl-bidirectional';
12
- import { TtfGlyphInfo } from './ttf-glyph-info';
13
- /**
14
- * `Metrics` of the font.
15
- * @private
16
- */
17
- export class RtlRenderer {
18
- //region Constants
19
- /// Open bracket symbol.
20
- /// </summary>
21
- private readonly openBracket : string = '(';
22
- /// <summary>
23
- /// Close bracket symbol.
24
- /// </summary>
25
- private readonly closeBracket : string = ')';
26
- //#region Constructors
27
- /// <summary>
28
- /// Initializes a new instance of the <see cref="RtlRenderer"/> class.
29
- /// </summary>
30
- // public constructor() {
31
- // }
32
- //#region Public Methods
33
- /// <summary>
34
- /// Layouts text. Changes blocks position in the RTL text.
35
- /// Ligates the text if needed.
36
- /// </summary>
37
- /// <param name="line">Line of the text.</param>
38
- /// <param name="font">Font to be used for string printing.</param>
39
- /// <param name="rtl">Font alignment.</param>
40
- /// <param name="wordSpace">Indicates whether Word Spacing used or not.</param>
41
- /// <returns>Layout string.</returns>
42
- public layout(line : string, font : PdfTrueTypeFont, rtl : boolean, wordSpace : boolean, format : PdfStringFormat) : string[] {
43
- if (line == null) {
44
- throw new Error('ArgumentNullException : line');
45
- }
46
- if (font == null) {
47
- throw new Error('ArgumentNullException : font');
48
- }
49
- let result : string[] = [];
50
- if (font.Unicode) {
51
- result = this.customLayout(line, rtl, format , font , wordSpace);
52
- } else {
53
- result = [];
54
- result[0] = line;
55
- }
56
- return result;
57
- }
58
- /// <summary>
59
- /// Layouts a string and splits it by the words and using correct lay outing.
60
- /// </summary>
61
- /// <param name="line">Text line.</param>
62
- /// <param name="font">Font object.</param>
63
- /// <param name="rtl">Indicates whether RTL should be applied.</param>
64
- /// <param name="wordSpace">Indicates whether word spacing is used.</param>
65
- /// <returns>Array of words if converted, null otherwise.</returns>
66
- public splitLayout( line : string, font : PdfTrueTypeFont, rtl : boolean, wordSpace : boolean, format : PdfStringFormat): string[] {
67
- if (line == null) {
68
- throw new Error('ArgumentNullException : line');
69
- }
70
- if (font == null) {
71
- throw new Error('ArgumentNullException : font');
72
- }
73
- let words : string[] = [];
74
- let system : boolean = false;
75
- if (!system || words == null) {
76
- words = this.customSplitLayout(line, font, rtl, wordSpace, format);
77
- }
78
- return words;
79
- }
80
- //#endregion
81
- //#region Implementation
82
- // private isEnglish( word : string) : boolean
83
- // {
84
- // let c : string = (word.length > 0) ? word[0] : '';
85
- // return (c >= '0' && c < 'ÿ');
86
- // }
87
- // private keepOrder( words : string, startIndex : number, count: number, result : string[], resultIndex : number) : void
88
- // {
89
- // for (let i : number = 0, ri = resultIndex - count + 1; i < count; ++i, ++ri) {
90
- // result[ri] = words[i + startIndex];
91
- // }
92
- // }
93
- /// <summary>
94
- /// Uses system API to layout the text.
95
- /// </summary>
96
- /// <param name="line">Line of the text to be layouted.</param>
97
- /// <param name="font">Font which is used for text printing.</param>
98
- /// <param name="rtl">Indicates whether we use RTL or RTL lay outing of the text container.</param>
99
- /// <returns>Layout string.</returns>
100
- /* tslint:disable-next-line:max-line-length */
101
- public getGlyphIndex( line : string, font : PdfTrueTypeFont, rtl : boolean, /*out*/ glyphs : Uint16Array, custom ?: boolean | null) : { success : boolean, glyphs : Uint16Array } {
102
- let success : boolean = true;
103
- let fail : boolean = false;
104
- if (line == null) {
105
- throw new Error('ArgumentNullException : line');
106
- }
107
- if (font == null) {
108
- throw new Error('ArgumentNullException : font');
109
- }
110
- glyphs = null;
111
- if (line.length === 0) {
112
- return { success : fail, glyphs : glyphs };
113
- }
114
- let renderer : ArabicShapeRenderer = new ArabicShapeRenderer();
115
- let text : string = renderer.shape(line, 0);
116
- let internalFont : UnicodeTrueTypeFont = font.fontInternal as UnicodeTrueTypeFont;
117
- let ttfReader : TtfReader = internalFont.ttfReader;
118
- glyphs = new Uint16Array(text.length);
119
- let i : number = 0;
120
- for (let k : number = 0, len : number = text.length; k < len; k++) {
121
- let ch : string = text[k];
122
- let glyphInfo : TtfGlyphInfo = ttfReader.getGlyph(ch);
123
- if ( glyphInfo !== null && typeof glyphInfo !== 'undefined' ) {
124
- glyphs[i++] = (glyphInfo).index as number;
125
- }
126
- }
127
- return { success : success, glyphs : glyphs };
128
- }
129
- /// <summary>
130
- /// Uses manual algorithm for text lay outing.
131
- /// </summary>
132
- /// <param name="line">Line of the text to be layouted.</param>
133
- /// <param name="font">Font which is used for text printing.</param>
134
- /// <param name="rtl">Indicates whether we use RTL or RTL lay outing of the text container.</param>
135
- /// <param name="wordSpace">If true - word spacing is used.</param>
136
- /// <returns>layout string array.</returns>
137
- public customLayout(line : string, rtl : boolean, format : PdfStringFormat) : string
138
- public customLayout(line : string, rtl : boolean, format : PdfStringFormat, font : PdfTrueTypeFont, wordSpace : boolean): string[]
139
- /* tslint:disable-next-line:max-line-length */
140
- public customLayout(line : string, rtl : boolean, format : PdfStringFormat, font ?: PdfTrueTypeFont, wordSpace ?: boolean): string[] | string {
141
- if (wordSpace === null || typeof wordSpace === 'undefined' ) {
142
- if (line == null) {
143
- throw new Error('ArgumentNullException : line');
144
- }
145
- let result : string = null;
146
- //bidirectional order.
147
- if (format !== null && typeof format !== 'undefined' && format.textDirection !== PdfTextDirection.None) {
148
- let bidi : Bidi = new Bidi();
149
- result = bidi.getLogicalToVisualString(line, rtl);
150
- }
151
- return result;
152
- } else {
153
- if (line == null) {
154
- throw new Error('ArgumentNullException : line');
155
- }
156
- if (font == null) {
157
- throw new Error('ArgumentNullException : font');
158
- }
159
- let layouted : string = null;
160
- if (format !== null && typeof format !== 'undefined' && format.textDirection !== PdfTextDirection.None) {
161
- let renderer : ArabicShapeRenderer = new ArabicShapeRenderer();
162
- let txt : string = renderer.shape(line, 0);
163
- layouted = this.customLayout(txt, rtl, format);
164
- }
165
- // else {
166
- // layouted = this.customLayout(line, rtl, format);
167
- // }
168
- // We have unicode font, but from the file.
169
- let result : string[] = [];
170
- // Split the text by words if word spacing is not default.
171
- if (wordSpace) {
172
- let words : string[] = layouted.split('');
173
- let count : number = words.length;
174
- for (let i : number = 0; i < count; i++) {
175
- words[i] = this.addChars(font, words[i]);
176
- }
177
- result = words;
178
- } else {
179
- result = [];
180
- result[0] = this.addChars(font, layouted);
181
- }
182
- return result;
183
- }
184
- }
185
-
186
- /// <summary>
187
- /// Add information about used glyphs to the font.
188
- /// </summary>
189
- /// <param name="font">Font used for text rendering.</param>
190
- /// <param name="glyphs">Array of used glyphs.</param>
191
- /// <returns>String in the form to be written to the file.</returns>
192
- public addChars( font : PdfTrueTypeFont, glyphs : string) : string {
193
- let line : string = glyphs;
194
- if (font == null) {
195
- throw new Error('ArgumentNullException : font');
196
- }
197
- if (line == null) {
198
- throw new Error('ArgumentNullException : line');
199
- }
200
- let text : string = line;
201
- let internalFont : UnicodeTrueTypeFont = font.fontInternal as UnicodeTrueTypeFont;
202
- let ttfReader : TtfReader = internalFont.ttfReader;
203
- font.setSymbols(text);
204
- // Reconvert string according to unicode standard.
205
- text = ttfReader.convertString(text);
206
- let bytes : number[] = PdfString.toUnicodeArray(text, false);
207
- text = PdfString.byteToString(bytes);
208
- return text;
209
- // else {
210
- // if (font == null) {
211
- // throw new Error('ArgumentNullException : font');
212
- // }
213
- // if (glyphs == null) {
214
- // throw new Error('ArgumentNullException : glyphs');
215
- // }
216
- // // Mark the chars as used.
217
- // let text : string = '';
218
- // font.setSymbols(glyphs);
219
- // // Create string from the glyphs.
220
- //
221
- // let chars : string[] = [];
222
- // for (let i : number = 0; i < glyphs.length; i++) {
223
- // chars[i] = glyphs[i].toString();
224
- // }
225
- // for (let j : number = 0 ; j < chars.length; j++) {
226
- // text = text + chars[j];
227
- // }
228
- // let bytes : number[] = PdfString.toUnicodeArray(text, false);
229
- // text = PdfString.byteToString(bytes);
230
- // return text;
231
- // }
232
- }
233
-
234
- /// <summary>
235
- /// Layouts a string and splits it by the words by using custom lay outing.
236
- /// </summary>
237
- /// <param name="line">Text line.</param>
238
- /// <param name="font">Font object.</param>
239
- /// <param name="rtl">Indicates whether RTL should be applied.</param>
240
- /// <param name="wordSpace">Indicates whether word spacing is used.</param>
241
- /// <returns>Array of words if converted, null otherwise.</returns>
242
- /* tslint:disable-next-line:max-line-length */
243
- public customSplitLayout(line : string, font : PdfTrueTypeFont, rtl : boolean, wordSpace : boolean, format : PdfStringFormat) : string[] {
244
- if (line == null) {
245
- throw new Error('ArgumentNullException : line');
246
- }
247
- if (font == null) {
248
- throw new Error('ArgumentNullException : font');
249
- }
250
- let reversedLine : string = this.customLayout(line, rtl, format);
251
- let words : string[] = reversedLine.split('');
252
- return words;
253
- }
254
- //#endregion
255
- }