@syncfusion/ej2-pdf-export 20.2.45 → 20.3.47
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.
- package/dist/ej2-pdf-export.min.js +10 -0
- package/dist/ej2-pdf-export.umd.min.js +1 -1
- package/dist/global/ej2-pdf-export.min.js +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/implementation/actions/action.ts +76 -0
- package/dist/ts/implementation/actions/uri-action.ts +52 -0
- package/dist/ts/implementation/annotations/action-link-annotation.ts +43 -0
- package/dist/ts/implementation/annotations/annotation-collection.ts +159 -0
- package/dist/ts/implementation/annotations/annotation.ts +241 -0
- package/dist/ts/implementation/annotations/document-link-annotation.ts +118 -0
- package/dist/ts/implementation/annotations/link-annotation.ts +32 -0
- package/dist/ts/implementation/annotations/pdf-text-web-link.ts +265 -0
- package/dist/ts/implementation/annotations/uri-annotation.ts +86 -0
- package/dist/ts/implementation/collections/dictionary.ts +150 -0
- package/dist/ts/implementation/collections/object-object-pair/dictionary.ts +125 -0
- package/dist/ts/implementation/collections/utils.ts +38 -0
- package/dist/ts/implementation/document/automatic-fields/automatic-field-info-collection.ts +39 -0
- package/dist/ts/implementation/document/automatic-fields/automatic-field-info.ts +108 -0
- package/dist/ts/implementation/document/automatic-fields/automatic-field.ts +127 -0
- package/dist/ts/implementation/document/automatic-fields/composite-field.ts +76 -0
- package/dist/ts/implementation/document/automatic-fields/multiple-value-field.ts +37 -0
- package/dist/ts/implementation/document/automatic-fields/page-count-field.ts +75 -0
- package/dist/ts/implementation/document/automatic-fields/pdf-numbers-convertor.ts +157 -0
- package/dist/ts/implementation/document/automatic-fields/pdf-page-number-field.ts +82 -0
- package/dist/ts/implementation/document/automatic-fields/pdf-template-value-pair.ts +60 -0
- package/dist/ts/implementation/document/automatic-fields/single-value-field.ts +48 -0
- package/dist/ts/implementation/document/pdf-catalog.ts +52 -0
- package/dist/ts/implementation/document/pdf-document-base.ts +166 -0
- package/dist/ts/implementation/document/pdf-document-template.ts +310 -0
- package/dist/ts/implementation/document/pdf-document.ts +342 -0
- package/dist/ts/implementation/drawing/pdf-drawing.ts +218 -0
- package/dist/ts/implementation/general/enum.ts +21 -0
- package/dist/ts/implementation/general/functions/pdf-function.ts +66 -0
- package/dist/ts/implementation/general/functions/pdf-sampled-function.ts +62 -0
- package/dist/ts/implementation/general/pdf-cache-collection.ts +97 -0
- package/dist/ts/implementation/general/pdf-collection.ts +41 -0
- package/dist/ts/implementation/general/pdf-destination.ts +170 -0
- package/dist/ts/implementation/graphics/brushes/enum.ts +237 -0
- package/dist/ts/implementation/graphics/brushes/pdf-blend.ts +294 -0
- package/dist/ts/implementation/graphics/brushes/pdf-brush.ts +68 -0
- package/dist/ts/implementation/graphics/brushes/pdf-brushes.ts +2438 -0
- package/dist/ts/implementation/graphics/brushes/pdf-color-blend.ts +295 -0
- package/dist/ts/implementation/graphics/brushes/pdf-gradient-brush.ts +311 -0
- package/dist/ts/implementation/graphics/brushes/pdf-linear-gradient-brush.ts +406 -0
- package/dist/ts/implementation/graphics/brushes/pdf-radial-gradient-brush.ts +290 -0
- package/dist/ts/implementation/graphics/brushes/pdf-solid-brush.ts +107 -0
- package/dist/ts/implementation/graphics/brushes/pdf-tiling-brush.ts +304 -0
- package/dist/ts/implementation/graphics/constants.ts +31 -0
- package/dist/ts/implementation/graphics/enum.ts +413 -0
- package/dist/ts/implementation/graphics/figures/arc.ts +133 -0
- package/dist/ts/implementation/graphics/figures/base/draw-element.ts +59 -0
- package/dist/ts/implementation/graphics/figures/base/element-layouter.ts +260 -0
- package/dist/ts/implementation/graphics/figures/base/fill-element.ts +72 -0
- package/dist/ts/implementation/graphics/figures/base/graphics-element.ts +34 -0
- package/dist/ts/implementation/graphics/figures/base/pdf-shape-element.ts +69 -0
- package/dist/ts/implementation/graphics/figures/base/shape-layouter.ts +276 -0
- package/dist/ts/implementation/graphics/figures/base/text-layouter.ts +205 -0
- package/dist/ts/implementation/graphics/figures/ellipse-part.ts +76 -0
- package/dist/ts/implementation/graphics/figures/enum.ts +80 -0
- package/dist/ts/implementation/graphics/figures/layout-element.ts +132 -0
- package/dist/ts/implementation/graphics/figures/path.ts +646 -0
- package/dist/ts/implementation/graphics/figures/pdf-template.ts +205 -0
- package/dist/ts/implementation/graphics/figures/rectangle-area.ts +108 -0
- package/dist/ts/implementation/graphics/figures/text-element.ts +445 -0
- package/dist/ts/implementation/graphics/fonts/enum.ts +385 -0
- package/dist/ts/implementation/graphics/fonts/pdf-font-metrics.ts +248 -0
- package/dist/ts/implementation/graphics/fonts/pdf-font.ts +316 -0
- package/dist/ts/implementation/graphics/fonts/pdf-standard-font-metrics-factory.ts +606 -0
- package/dist/ts/implementation/graphics/fonts/pdf-standard-font.ts +243 -0
- package/dist/ts/implementation/graphics/fonts/pdf-string-format.ts +474 -0
- package/dist/ts/implementation/graphics/fonts/pdf-true-type-font.ts +165 -0
- package/dist/ts/implementation/graphics/fonts/rtl/rtl-bidirectional.ts +958 -0
- package/dist/ts/implementation/graphics/fonts/rtl/rtl-text-shape.ts +374 -0
- package/dist/ts/implementation/graphics/fonts/rtl-renderer.ts +255 -0
- package/dist/ts/implementation/graphics/fonts/string-layouter.ts +617 -0
- package/dist/ts/implementation/graphics/fonts/string-tokenizer.ts +275 -0
- package/dist/ts/implementation/graphics/fonts/ttf-OS2-Table.ts +206 -0
- package/dist/ts/implementation/graphics/fonts/ttf-apple-cmap-sub-table.ts +18 -0
- package/dist/ts/implementation/graphics/fonts/ttf-cmap-sub-table.ts +18 -0
- package/dist/ts/implementation/graphics/fonts/ttf-cmap-table.ts +14 -0
- package/dist/ts/implementation/graphics/fonts/ttf-glyph-header.ts +26 -0
- package/dist/ts/implementation/graphics/fonts/ttf-glyph-info.ts +35 -0
- package/dist/ts/implementation/graphics/fonts/ttf-head-table.ts +94 -0
- package/dist/ts/implementation/graphics/fonts/ttf-horizontal-header-table.ts +56 -0
- package/dist/ts/implementation/graphics/fonts/ttf-loca-table.ts +10 -0
- package/dist/ts/implementation/graphics/fonts/ttf-long-hor-metric.ts +14 -0
- package/dist/ts/implementation/graphics/fonts/ttf-metrics.ts +106 -0
- package/dist/ts/implementation/graphics/fonts/ttf-microsoft-cmap-sub-table.ts +58 -0
- package/dist/ts/implementation/graphics/fonts/ttf-name-record.ts +33 -0
- package/dist/ts/implementation/graphics/fonts/ttf-name-table.ts +22 -0
- package/dist/ts/implementation/graphics/fonts/ttf-post-table.ts +42 -0
- package/dist/ts/implementation/graphics/fonts/ttf-reader.ts +1254 -0
- package/dist/ts/implementation/graphics/fonts/ttf-table-info.ts +26 -0
- package/dist/ts/implementation/graphics/fonts/ttf-trimmed-cmap-sub-table.ts +26 -0
- package/dist/ts/implementation/graphics/fonts/unicode-true-type-font.ts +577 -0
- package/dist/ts/implementation/graphics/images/byte-array.ts +137 -0
- package/dist/ts/implementation/graphics/images/image-decoder.ts +437 -0
- package/dist/ts/implementation/graphics/images/pdf-bitmap.ts +110 -0
- package/dist/ts/implementation/graphics/images/pdf-image.ts +132 -0
- package/dist/ts/implementation/graphics/pdf-color.ts +478 -0
- package/dist/ts/implementation/graphics/pdf-graphics.ts +2424 -0
- package/dist/ts/implementation/graphics/pdf-margins.ts +124 -0
- package/dist/ts/implementation/graphics/pdf-pen.ts +370 -0
- package/dist/ts/implementation/graphics/pdf-resources.ts +300 -0
- package/dist/ts/implementation/graphics/pdf-transformation-matrix.ts +246 -0
- package/dist/ts/implementation/graphics/pdf-transparency.ts +93 -0
- package/dist/ts/implementation/graphics/unit-convertor.ts +96 -0
- package/dist/ts/implementation/input-output/big-endian-writer.ts +121 -0
- package/dist/ts/implementation/input-output/cross-table.ts +21 -0
- package/dist/ts/implementation/input-output/enum.ts +16 -0
- package/dist/ts/implementation/input-output/pdf-cross-table.ts +524 -0
- package/dist/ts/implementation/input-output/pdf-dictionary-properties.ts +515 -0
- package/dist/ts/implementation/input-output/pdf-main-object-collection.ts +194 -0
- package/dist/ts/implementation/input-output/pdf-operators.ts +363 -0
- package/dist/ts/implementation/input-output/pdf-stream-writer.ts +681 -0
- package/dist/ts/implementation/input-output/pdf-writer.ts +88 -0
- package/dist/ts/implementation/pages/enum.ts +201 -0
- package/dist/ts/implementation/pages/page-added-event-arguments.ts +39 -0
- package/dist/ts/implementation/pages/pdf-document-page-collection.ts +180 -0
- package/dist/ts/implementation/pages/pdf-page-base.ts +181 -0
- package/dist/ts/implementation/pages/pdf-page-layer-collection.ts +348 -0
- package/dist/ts/implementation/pages/pdf-page-layer.ts +271 -0
- package/dist/ts/implementation/pages/pdf-page-settings.ts +192 -0
- package/dist/ts/implementation/pages/pdf-page-size.ts +162 -0
- package/dist/ts/implementation/pages/pdf-page-template-element.ts +659 -0
- package/dist/ts/implementation/pages/pdf-page.ts +235 -0
- package/dist/ts/implementation/pages/pdf-section-collection.ts +187 -0
- package/dist/ts/implementation/pages/pdf-section-page-collection.ts +61 -0
- package/dist/ts/implementation/pages/pdf-section-templates.ts +96 -0
- package/dist/ts/implementation/pages/pdf-section.ts +644 -0
- package/dist/ts/implementation/primitives/pdf-array.ts +386 -0
- package/dist/ts/implementation/primitives/pdf-boolean.ts +119 -0
- package/dist/ts/implementation/primitives/pdf-dictionary.ts +513 -0
- package/dist/ts/implementation/primitives/pdf-name.ts +218 -0
- package/dist/ts/implementation/primitives/pdf-number.ts +165 -0
- package/dist/ts/implementation/primitives/pdf-reference.ts +430 -0
- package/dist/ts/implementation/primitives/pdf-stream.ts +336 -0
- package/dist/ts/implementation/primitives/pdf-string.ts +397 -0
- package/dist/ts/implementation/structured-elements/grid/layout/grid-layouter.ts +2027 -0
- package/dist/ts/implementation/structured-elements/grid/pdf-grid-cell.ts +1189 -0
- package/dist/ts/implementation/structured-elements/grid/pdf-grid-column.ts +206 -0
- package/dist/ts/implementation/structured-elements/grid/pdf-grid-row.ts +470 -0
- package/dist/ts/implementation/structured-elements/grid/pdf-grid.ts +853 -0
- package/dist/ts/implementation/structured-elements/grid/styles/pdf-borders.ts +240 -0
- package/dist/ts/implementation/structured-elements/grid/styles/style.ts +424 -0
- package/dist/ts/implementation/structured-elements/tables/light-tables/enum.ts +16 -0
- package/dist/ts/interfaces/i-pdf-cache.ts +23 -0
- package/dist/ts/interfaces/i-pdf-changable.ts +17 -0
- package/dist/ts/interfaces/i-pdf-clonable.ts +12 -0
- package/dist/ts/interfaces/i-pdf-primitives.ts +45 -0
- package/dist/ts/interfaces/i-pdf-true-type-font.ts +48 -0
- package/dist/ts/interfaces/i-pdf-wrapper.ts +13 -0
- package/dist/ts/interfaces/i-pdf-writer.ts +29 -0
- package/package.json +8 -7
|
@@ -0,0 +1,374 @@
|
|
|
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
|
|
@@ -0,0 +1,255 @@
|
|
|
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
|
+
}
|