@syncfusion/ej2-pdf-export 22.1.34 → 22.1.37

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 (169) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/ej2-pdf-export.min.js +2 -2
  3. package/dist/ej2-pdf-export.umd.min.js +2 -2
  4. package/dist/ej2-pdf-export.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-pdf-export.es2015.js +748 -93
  6. package/dist/es6/ej2-pdf-export.es2015.js.map +1 -1
  7. package/dist/es6/ej2-pdf-export.es5.js +933 -225
  8. package/dist/es6/ej2-pdf-export.es5.js.map +1 -1
  9. package/dist/global/ej2-pdf-export.min.js +2 -2
  10. package/dist/global/ej2-pdf-export.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +5 -5
  13. package/src/implementation/document/pdf-catalog.d.ts +7 -0
  14. package/src/implementation/document/pdf-catalog.js +16 -0
  15. package/src/implementation/document/pdf-document-base.d.ts +13 -0
  16. package/src/implementation/document/pdf-document-base.js +18 -0
  17. package/src/implementation/document/pdf-viewer-preferences.d.ts +467 -0
  18. package/src/implementation/document/pdf-viewer-preferences.js +624 -0
  19. package/src/implementation/input-output/pdf-dictionary-properties.d.ts +55 -0
  20. package/src/implementation/input-output/pdf-dictionary-properties.js +55 -0
  21. package/dist/ts/implementation/actions/action.ts +0 -76
  22. package/dist/ts/implementation/actions/uri-action.ts +0 -52
  23. package/dist/ts/implementation/annotations/action-link-annotation.ts +0 -43
  24. package/dist/ts/implementation/annotations/annotation-collection.ts +0 -159
  25. package/dist/ts/implementation/annotations/annotation.ts +0 -241
  26. package/dist/ts/implementation/annotations/document-link-annotation.ts +0 -118
  27. package/dist/ts/implementation/annotations/link-annotation.ts +0 -32
  28. package/dist/ts/implementation/annotations/pdf-text-web-link.ts +0 -265
  29. package/dist/ts/implementation/annotations/uri-annotation.ts +0 -86
  30. package/dist/ts/implementation/collections/dictionary.ts +0 -150
  31. package/dist/ts/implementation/collections/object-object-pair/dictionary.ts +0 -125
  32. package/dist/ts/implementation/collections/utils.ts +0 -38
  33. package/dist/ts/implementation/document/automatic-fields/automatic-field-info-collection.ts +0 -39
  34. package/dist/ts/implementation/document/automatic-fields/automatic-field-info.ts +0 -108
  35. package/dist/ts/implementation/document/automatic-fields/automatic-field.ts +0 -127
  36. package/dist/ts/implementation/document/automatic-fields/composite-field.ts +0 -76
  37. package/dist/ts/implementation/document/automatic-fields/multiple-value-field.ts +0 -37
  38. package/dist/ts/implementation/document/automatic-fields/page-count-field.ts +0 -75
  39. package/dist/ts/implementation/document/automatic-fields/pdf-numbers-convertor.ts +0 -157
  40. package/dist/ts/implementation/document/automatic-fields/pdf-page-number-field.ts +0 -82
  41. package/dist/ts/implementation/document/automatic-fields/pdf-template-value-pair.ts +0 -60
  42. package/dist/ts/implementation/document/automatic-fields/single-value-field.ts +0 -48
  43. package/dist/ts/implementation/document/pdf-catalog.ts +0 -52
  44. package/dist/ts/implementation/document/pdf-document-base.ts +0 -166
  45. package/dist/ts/implementation/document/pdf-document-template.ts +0 -310
  46. package/dist/ts/implementation/document/pdf-document.ts +0 -342
  47. package/dist/ts/implementation/drawing/pdf-drawing.ts +0 -218
  48. package/dist/ts/implementation/general/enum.ts +0 -21
  49. package/dist/ts/implementation/general/functions/pdf-function.ts +0 -66
  50. package/dist/ts/implementation/general/functions/pdf-sampled-function.ts +0 -62
  51. package/dist/ts/implementation/general/pdf-cache-collection.ts +0 -97
  52. package/dist/ts/implementation/general/pdf-collection.ts +0 -41
  53. package/dist/ts/implementation/general/pdf-destination.ts +0 -170
  54. package/dist/ts/implementation/graphics/brushes/enum.ts +0 -237
  55. package/dist/ts/implementation/graphics/brushes/pdf-blend.ts +0 -294
  56. package/dist/ts/implementation/graphics/brushes/pdf-brush.ts +0 -68
  57. package/dist/ts/implementation/graphics/brushes/pdf-brushes.ts +0 -2438
  58. package/dist/ts/implementation/graphics/brushes/pdf-color-blend.ts +0 -295
  59. package/dist/ts/implementation/graphics/brushes/pdf-gradient-brush.ts +0 -311
  60. package/dist/ts/implementation/graphics/brushes/pdf-linear-gradient-brush.ts +0 -406
  61. package/dist/ts/implementation/graphics/brushes/pdf-radial-gradient-brush.ts +0 -290
  62. package/dist/ts/implementation/graphics/brushes/pdf-solid-brush.ts +0 -107
  63. package/dist/ts/implementation/graphics/brushes/pdf-tiling-brush.ts +0 -304
  64. package/dist/ts/implementation/graphics/constants.ts +0 -31
  65. package/dist/ts/implementation/graphics/enum.ts +0 -413
  66. package/dist/ts/implementation/graphics/figures/arc.ts +0 -133
  67. package/dist/ts/implementation/graphics/figures/base/draw-element.ts +0 -59
  68. package/dist/ts/implementation/graphics/figures/base/element-layouter.ts +0 -260
  69. package/dist/ts/implementation/graphics/figures/base/fill-element.ts +0 -72
  70. package/dist/ts/implementation/graphics/figures/base/graphics-element.ts +0 -34
  71. package/dist/ts/implementation/graphics/figures/base/pdf-shape-element.ts +0 -69
  72. package/dist/ts/implementation/graphics/figures/base/shape-layouter.ts +0 -276
  73. package/dist/ts/implementation/graphics/figures/base/text-layouter.ts +0 -205
  74. package/dist/ts/implementation/graphics/figures/ellipse-part.ts +0 -76
  75. package/dist/ts/implementation/graphics/figures/enum.ts +0 -80
  76. package/dist/ts/implementation/graphics/figures/layout-element.ts +0 -132
  77. package/dist/ts/implementation/graphics/figures/path.ts +0 -646
  78. package/dist/ts/implementation/graphics/figures/pdf-template.ts +0 -205
  79. package/dist/ts/implementation/graphics/figures/rectangle-area.ts +0 -108
  80. package/dist/ts/implementation/graphics/figures/text-element.ts +0 -445
  81. package/dist/ts/implementation/graphics/fonts/enum.ts +0 -385
  82. package/dist/ts/implementation/graphics/fonts/pdf-font-metrics.ts +0 -248
  83. package/dist/ts/implementation/graphics/fonts/pdf-font.ts +0 -316
  84. package/dist/ts/implementation/graphics/fonts/pdf-standard-font-metrics-factory.ts +0 -606
  85. package/dist/ts/implementation/graphics/fonts/pdf-standard-font.ts +0 -243
  86. package/dist/ts/implementation/graphics/fonts/pdf-string-format.ts +0 -474
  87. package/dist/ts/implementation/graphics/fonts/pdf-true-type-font.ts +0 -165
  88. package/dist/ts/implementation/graphics/fonts/rtl/rtl-bidirectional.ts +0 -958
  89. package/dist/ts/implementation/graphics/fonts/rtl/rtl-text-shape.ts +0 -374
  90. package/dist/ts/implementation/graphics/fonts/rtl-renderer.ts +0 -255
  91. package/dist/ts/implementation/graphics/fonts/string-layouter.ts +0 -617
  92. package/dist/ts/implementation/graphics/fonts/string-tokenizer.ts +0 -275
  93. package/dist/ts/implementation/graphics/fonts/ttf-OS2-Table.ts +0 -206
  94. package/dist/ts/implementation/graphics/fonts/ttf-apple-cmap-sub-table.ts +0 -18
  95. package/dist/ts/implementation/graphics/fonts/ttf-cmap-sub-table.ts +0 -18
  96. package/dist/ts/implementation/graphics/fonts/ttf-cmap-table.ts +0 -14
  97. package/dist/ts/implementation/graphics/fonts/ttf-glyph-header.ts +0 -26
  98. package/dist/ts/implementation/graphics/fonts/ttf-glyph-info.ts +0 -35
  99. package/dist/ts/implementation/graphics/fonts/ttf-head-table.ts +0 -94
  100. package/dist/ts/implementation/graphics/fonts/ttf-horizontal-header-table.ts +0 -56
  101. package/dist/ts/implementation/graphics/fonts/ttf-loca-table.ts +0 -10
  102. package/dist/ts/implementation/graphics/fonts/ttf-long-hor-metric.ts +0 -14
  103. package/dist/ts/implementation/graphics/fonts/ttf-metrics.ts +0 -106
  104. package/dist/ts/implementation/graphics/fonts/ttf-microsoft-cmap-sub-table.ts +0 -58
  105. package/dist/ts/implementation/graphics/fonts/ttf-name-record.ts +0 -33
  106. package/dist/ts/implementation/graphics/fonts/ttf-name-table.ts +0 -22
  107. package/dist/ts/implementation/graphics/fonts/ttf-post-table.ts +0 -42
  108. package/dist/ts/implementation/graphics/fonts/ttf-reader.ts +0 -1254
  109. package/dist/ts/implementation/graphics/fonts/ttf-table-info.ts +0 -26
  110. package/dist/ts/implementation/graphics/fonts/ttf-trimmed-cmap-sub-table.ts +0 -26
  111. package/dist/ts/implementation/graphics/fonts/unicode-true-type-font.ts +0 -577
  112. package/dist/ts/implementation/graphics/images/byte-array.ts +0 -137
  113. package/dist/ts/implementation/graphics/images/image-decoder.ts +0 -439
  114. package/dist/ts/implementation/graphics/images/pdf-bitmap.ts +0 -110
  115. package/dist/ts/implementation/graphics/images/pdf-image.ts +0 -132
  116. package/dist/ts/implementation/graphics/pdf-color.ts +0 -478
  117. package/dist/ts/implementation/graphics/pdf-graphics.ts +0 -2424
  118. package/dist/ts/implementation/graphics/pdf-margins.ts +0 -124
  119. package/dist/ts/implementation/graphics/pdf-pen.ts +0 -370
  120. package/dist/ts/implementation/graphics/pdf-resources.ts +0 -300
  121. package/dist/ts/implementation/graphics/pdf-transformation-matrix.ts +0 -246
  122. package/dist/ts/implementation/graphics/pdf-transparency.ts +0 -93
  123. package/dist/ts/implementation/graphics/unit-convertor.ts +0 -96
  124. package/dist/ts/implementation/input-output/big-endian-writer.ts +0 -121
  125. package/dist/ts/implementation/input-output/cross-table.ts +0 -21
  126. package/dist/ts/implementation/input-output/enum.ts +0 -16
  127. package/dist/ts/implementation/input-output/pdf-cross-table.ts +0 -524
  128. package/dist/ts/implementation/input-output/pdf-dictionary-properties.ts +0 -515
  129. package/dist/ts/implementation/input-output/pdf-main-object-collection.ts +0 -194
  130. package/dist/ts/implementation/input-output/pdf-operators.ts +0 -363
  131. package/dist/ts/implementation/input-output/pdf-stream-writer.ts +0 -681
  132. package/dist/ts/implementation/input-output/pdf-writer.ts +0 -88
  133. package/dist/ts/implementation/pages/enum.ts +0 -201
  134. package/dist/ts/implementation/pages/page-added-event-arguments.ts +0 -39
  135. package/dist/ts/implementation/pages/pdf-document-page-collection.ts +0 -180
  136. package/dist/ts/implementation/pages/pdf-page-base.ts +0 -181
  137. package/dist/ts/implementation/pages/pdf-page-layer-collection.ts +0 -348
  138. package/dist/ts/implementation/pages/pdf-page-layer.ts +0 -271
  139. package/dist/ts/implementation/pages/pdf-page-settings.ts +0 -192
  140. package/dist/ts/implementation/pages/pdf-page-size.ts +0 -162
  141. package/dist/ts/implementation/pages/pdf-page-template-element.ts +0 -659
  142. package/dist/ts/implementation/pages/pdf-page.ts +0 -235
  143. package/dist/ts/implementation/pages/pdf-section-collection.ts +0 -187
  144. package/dist/ts/implementation/pages/pdf-section-page-collection.ts +0 -61
  145. package/dist/ts/implementation/pages/pdf-section-templates.ts +0 -96
  146. package/dist/ts/implementation/pages/pdf-section.ts +0 -644
  147. package/dist/ts/implementation/primitives/pdf-array.ts +0 -386
  148. package/dist/ts/implementation/primitives/pdf-boolean.ts +0 -119
  149. package/dist/ts/implementation/primitives/pdf-dictionary.ts +0 -513
  150. package/dist/ts/implementation/primitives/pdf-name.ts +0 -218
  151. package/dist/ts/implementation/primitives/pdf-number.ts +0 -165
  152. package/dist/ts/implementation/primitives/pdf-reference.ts +0 -430
  153. package/dist/ts/implementation/primitives/pdf-stream.ts +0 -336
  154. package/dist/ts/implementation/primitives/pdf-string.ts +0 -397
  155. package/dist/ts/implementation/structured-elements/grid/layout/grid-layouter.ts +0 -2027
  156. package/dist/ts/implementation/structured-elements/grid/pdf-grid-cell.ts +0 -1193
  157. package/dist/ts/implementation/structured-elements/grid/pdf-grid-column.ts +0 -206
  158. package/dist/ts/implementation/structured-elements/grid/pdf-grid-row.ts +0 -470
  159. package/dist/ts/implementation/structured-elements/grid/pdf-grid.ts +0 -853
  160. package/dist/ts/implementation/structured-elements/grid/styles/pdf-borders.ts +0 -240
  161. package/dist/ts/implementation/structured-elements/grid/styles/style.ts +0 -424
  162. package/dist/ts/implementation/structured-elements/tables/light-tables/enum.ts +0 -16
  163. package/dist/ts/interfaces/i-pdf-cache.ts +0 -23
  164. package/dist/ts/interfaces/i-pdf-changable.ts +0 -17
  165. package/dist/ts/interfaces/i-pdf-clonable.ts +0 -12
  166. package/dist/ts/interfaces/i-pdf-primitives.ts +0 -45
  167. package/dist/ts/interfaces/i-pdf-true-type-font.ts +0 -48
  168. package/dist/ts/interfaces/i-pdf-wrapper.ts +0 -13
  169. package/dist/ts/interfaces/i-pdf-writer.ts +0 -29
@@ -1,132 +0,0 @@
1
- /**
2
- * PdfImage.ts class for EJ2-PDF
3
- */
4
- import { IPdfWrapper } from './../../../interfaces/i-pdf-wrapper';
5
- import { IPdfPrimitive } from './../../../interfaces/i-pdf-primitives';
6
- import { PdfStream } from './../../primitives/pdf-stream';
7
- import { SizeF } from './../../drawing/pdf-drawing';
8
- import { PdfGraphicsUnit } from './../enum';
9
- import { PdfUnitConverter } from './../unit-convertor';
10
- import { PdfBitmap } from './pdf-bitmap';
11
- /**
12
- * `PdfImage` class represents the base class for images and provides functionality for the 'PdfBitmap' class.
13
- * @private
14
- */
15
- export abstract class PdfImage implements IPdfWrapper {
16
- /**
17
- * `Width` of an image.
18
- * @private
19
- */
20
- private imageWidth : number;
21
- /**
22
- * `Height` of an image.
23
- * @private
24
- */
25
- private imageHeight : number;
26
- /**
27
- * `Bits per component` of an image.
28
- * @hidden
29
- * @private
30
- */
31
- public bitsPerComponent : number;
32
- /**
33
- * `horizontal resolution` of an image.
34
- * @hidden
35
- * @private
36
- */
37
- public horizontalResolution : number;
38
- /**
39
- * `Vertical resolution` of an image.
40
- * @hidden
41
- * @private
42
- */
43
- public verticalResolution : number;
44
- /**
45
- * `physical dimension` of an image.
46
- * @hidden
47
- * @private
48
- */
49
- private imagePhysicalDimension : SizeF;
50
- /**
51
- * Gets and Sets the `width` of an image.
52
- * @private
53
- */
54
- public get width() : number {
55
- return this.imageWidth;
56
- }
57
- public set width(value : number) {
58
- this.imageWidth = value;
59
- }
60
- /**
61
- * Gets and Sets the `height` of an image.
62
- * @private
63
- */
64
- public get height() : number {
65
- return this.imageHeight;
66
- }
67
- public set height(value : number) {
68
- this.imageHeight = value;
69
- }
70
- /**
71
- * Gets or sets the size of the image.
72
- * @private
73
- */
74
- public set size(value : SizeF) {
75
- this.width = value.width;
76
- this.height = value.height;
77
- }
78
- /**
79
- * Gets the `physical dimension` of an image.
80
- * @private
81
- */
82
- public get physicalDimension() : SizeF {
83
- this.imagePhysicalDimension = this.getPointSize(this.width, this.height, this.horizontalResolution, this.verticalResolution);
84
- return new SizeF(this.width, this.height);
85
- }
86
- /**
87
- * return the stored `stream of an image`.
88
- * @private
89
- */
90
- public imageStream : PdfStream;
91
- // /**
92
- // * Gets the `image stream as string`.
93
- // * @private
94
- // */
95
- // public static fromString(string : string) : PdfImage {
96
- // let image : PdfImage = new PdfBitmap(string);
97
- // return image;
98
- // }
99
- /**
100
- * Gets the `element` image stream.
101
- * @private
102
- */
103
- public get element() : IPdfPrimitive {
104
- return this.imageStream;
105
- }
106
- /**
107
- * `Save` the image stream.
108
- * @private
109
- */
110
- public abstract save() : void;
111
- /**
112
- * Return the value of `width and height of an image` in points.
113
- * @private
114
- */
115
- public getPointSize(width : number, height : number) : SizeF
116
- public getPointSize(width : number, height : number, horizontalResolution : number, verticalResolution : number) : SizeF
117
- public getPointSize(width : number, height : number, horizontalResolution ?: number, verticalResolution ?: number) : SizeF {
118
- if (typeof horizontalResolution === 'undefined') {
119
- let dpiX : number = PdfUnitConverter.horizontalResolution;
120
- let dpiY : number = PdfUnitConverter.verticalResolution;
121
- let size : SizeF = this.getPointSize(width, height, dpiX, dpiY);
122
- return size;
123
- } else {
124
- let ucX : PdfUnitConverter = new PdfUnitConverter(horizontalResolution);
125
- let ucY : PdfUnitConverter = new PdfUnitConverter(verticalResolution);
126
- let ptWidth : number = ucX.convertUnits(width, PdfGraphicsUnit.Pixel, PdfGraphicsUnit.Point);
127
- let ptHeight : number = ucY.convertUnits(height, PdfGraphicsUnit.Pixel, PdfGraphicsUnit.Point);
128
- let size : SizeF = new SizeF(ptWidth, ptHeight);
129
- return size;
130
- }
131
- }
132
- }
@@ -1,478 +0,0 @@
1
- import { PdfColorSpace } from './enum';
2
- import { Operators } from './../input-output/pdf-operators';
3
- import { Dictionary } from './../collections/dictionary';
4
- import { PdfNumber } from './../primitives/pdf-number';
5
- import { PdfArray } from './../primitives/pdf-array';
6
- /**
7
- * Implements structures and routines working with `color`.
8
- * ```typescript
9
- * // create a new PDF document
10
- * let document : PdfDocument = new PdfDocument();
11
- * // add a new page to the document
12
- * let page1 : PdfPage = document.pages.add();
13
- * // set the font
14
- * let font : PdfStandardFont = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
15
- * //
16
- * // set color
17
- * let brushColor : PdfColor = new PdfColor(0, 0, 0);
18
- * //
19
- * // create black brush
20
- * let blackBrush : PdfSolidBrush = new PdfSolidBrush(brushColor);
21
- * // draw the text
22
- * page1.graphics.drawString('Hello World', font, blackBrush, new PointF(0, 0));
23
- * // save the document
24
- * document.save('output.pdf');
25
- * // destroy the document
26
- * document.destroy();
27
- * ```
28
- * @default black color
29
- */
30
- export class PdfColor {
31
- //Fields
32
- /**
33
- * Holds `RGB colors` converted into strings.
34
- * @private
35
- */
36
- private static rgbStrings : Dictionary<number, Object> = new Dictionary<number, Object>();
37
- /**
38
- * Holds Gray scale colors converted into strings for `stroking`.
39
- * @private
40
- */
41
- private static grayStringsSroke : Dictionary<number, Object> = new Dictionary<number, Object>();
42
- /**
43
- * Holds Gray scale colors converted into strings for `filling`.
44
- * @private
45
- */
46
- private static grayStringsFill : Dictionary<number, Object> = new Dictionary<number, Object>();
47
- /**
48
- * Value of `Red` channel.
49
- * @private
50
- */
51
- private redColor : number;
52
- /**
53
- * Value of `Cyan` channel.
54
- * @private
55
- */
56
- private cyanColor : number;
57
- /**
58
- * Value of `Green` channel.
59
- * @private
60
- */
61
- private greenColor : number;
62
- /**
63
- * Value of `Magenta` channel.
64
- * @private
65
- */
66
- private magentaColor : number;
67
- /**
68
- * Value of `Blue` channel.
69
- * @private
70
- */
71
- private blueColor : number;
72
- /**
73
- * Value of `Yellow` channel.
74
- * @private
75
- */
76
- private yellowColor : number;
77
- /**
78
- * Value of `Black` channel.
79
- * @private
80
- */
81
- private blackColor : number;
82
- /**
83
- * Value of `Gray` channel.
84
- * @private
85
- */
86
- private grayColor : number;
87
- /**
88
- * `Alpha` channel.
89
- * @private
90
- */
91
- private alpha : number;
92
- /**
93
- * Shows if the color `is empty`.
94
- * @private
95
- */
96
- private filled : boolean;
97
- /**
98
- * `Max value` of color channel.
99
- * @private
100
- */
101
- public static readonly maxColourChannelValue : number = 255.0;
102
-
103
- //constructor
104
- /**
105
- * Initialize a new instance for `PdfColor` class.
106
- */
107
- public constructor()
108
- public constructor(color1 : PdfColor)
109
- public constructor(color1 : number)
110
- public constructor(color1 : number, color2 : number, color3 : number)
111
- public constructor(color1 : number, color2 : number, color3 : number, color4 : number)
112
- public constructor(color1 ?: number|PdfColor, color2 ?: number, color3 ?: number, color4 ?: number) {
113
- if (typeof color1 === 'undefined') {
114
- if (typeof color2 !== 'undefined' && typeof color3 !== 'undefined' && typeof color4 !== 'undefined') {
115
- this.assignRGB(color2, color3, color4);
116
- } else {
117
- this.filled = false;
118
- }
119
- } else if (color1 instanceof PdfColor) {
120
- this.redColor = color1.r;
121
- this.greenColor = color1.g;
122
- this.blueColor = color1.b;
123
- this.grayColor = color1.gray;
124
- this.alpha = color1.alpha;
125
- this.filled = (this.alpha !== 0);
126
- /* tslint:disable-next-line:max-line-length */
127
- } else if (typeof color1 === 'number' && typeof color2 === 'undefined' && typeof color3 === 'undefined' && typeof color4 === 'undefined') {
128
- if (color1 < 0) {
129
- color1 = 0;
130
- }
131
- if (color1 > 1) {
132
- color1 = 1;
133
- }
134
- this.redColor = color1 * PdfColor.maxColourChannelValue;
135
- this.greenColor = color1 * PdfColor.maxColourChannelValue;
136
- this.blueColor = color1 * PdfColor.maxColourChannelValue;
137
- this.cyanColor = color1;
138
- this.magentaColor = color1;
139
- this.yellowColor = color1;
140
- this.blackColor = color1;
141
- this.grayColor = color1;
142
- this.alpha = PdfColor.maxColourChannelValue;
143
- this.filled = true;
144
- } else if (typeof color4 === 'undefined') {
145
- this.assignRGB(color1, color2, color3);
146
- } else {
147
- this.assignRGB(color2, color3, color4, color1);
148
- }
149
- }
150
- /**
151
- * `Assign` red, green, blue colors with alpha value..
152
- * @private
153
- */
154
- private assignRGB(r : number, g : number, b : number, a ?: number) : void {
155
- if (typeof r === 'undefined' || typeof g === 'undefined' || typeof b === 'undefined') {
156
- this.filled = false;
157
- } else {
158
- this.cyanColor = 0;
159
- this.magentaColor = 0;
160
- this.yellowColor = 0;
161
- this.blackColor = 0;
162
- this.grayColor = 0;
163
- this.redColor = r;
164
- this.greenColor = g;
165
- this.blueColor = b;
166
- if ( typeof a === 'undefined') {
167
- this.alpha = PdfColor.maxColourChannelValue;
168
- } else {
169
- this.alpha = a;
170
- }
171
- this.filled = true;
172
- this.assignCMYK(r, g, b);
173
- }
174
- }
175
- /**
176
- * `Calculate and assign` cyan, megenta, yellow colors from rgb values..
177
- * @private
178
- */
179
- private assignCMYK(r : number, g : number, b : number) : void {
180
- let red : number = r / PdfColor.maxColourChannelValue;
181
- let green : number = g / PdfColor.maxColourChannelValue;
182
- let blue : number = b / PdfColor.maxColourChannelValue;
183
- let black : number = PdfNumber.min(1 - red, 1 - green, 1 - blue);
184
- let cyan : number = (black === 1.0) ? 0 : (1 - red - black) / (1 - black);
185
- let magenta : number = (black === 1.0) ? 0 : (1 - green - black) / (1 - black);
186
- let yellow : number = (black === 1.0) ? 0 : (1 - blue - black) / (1 - black);
187
- this.blackColor = black;
188
- this.cyanColor = cyan;
189
- this.magentaColor = magenta;
190
- this.yellowColor = yellow;
191
- }
192
-
193
- //Properties
194
- // public static get Empty():PdfColor
195
- // {
196
- // return this.s_emptyColor
197
- // }
198
- /**
199
- * Gets or sets `Red` channel value.
200
- * @private
201
- */
202
- public get r() : number {
203
- return this.redColor;
204
- }
205
- public set r(value : number) {
206
- this.redColor = value;
207
- this.assignCMYK(this.redColor, this.greenColor, this.blueColor);
208
- this.filled = true;
209
- }
210
- /**
211
- * Gets the `Red` color
212
- * @private
213
- */
214
- public get red() : number {
215
- return (this.r / PdfColor.maxColourChannelValue);
216
- }
217
- /**
218
- * Gets or sets `Blue` channel value.
219
- * @private
220
- */
221
- public get b() : number {
222
- return this.blueColor;
223
- }
224
- public set b(value : number) {
225
- this.blueColor = value;
226
- this.assignCMYK(this.redColor, this.greenColor, this.blueColor);
227
- this.filled = true;
228
- }
229
- /**
230
- * Gets the `blue` color.
231
- * @private
232
- */
233
- public get blue() : number {
234
- return (this.b / PdfColor.maxColourChannelValue);
235
- }
236
- /**
237
- * Gets or sets `Cyan` channel value.
238
- * @private
239
- */
240
- public get c() : number {
241
- return this.cyanColor;
242
- }
243
- public set c(value : number) {
244
- if (value < 0) {
245
- this.cyanColor = 0;
246
- } else if (value > 1) {
247
- this.cyanColor = 1;
248
- } else {
249
- this.cyanColor = value;
250
- }
251
- this.assignRGB(this.cyanColor, this.magentaColor, this.yellowColor, this.blackColor);
252
- this.filled = true;
253
- }
254
- /**
255
- * Gets or sets `Black` channel value.
256
- * @private
257
- */
258
- public get k(): number {
259
- return this.blackColor;
260
- }
261
- public set k(value: number) {
262
- if ((value < 0)) {
263
- this.blackColor = 0;
264
- } else if ((value > 1)) {
265
- this.blackColor = 1;
266
- } else {
267
- this.blackColor = value;
268
- }
269
- this.assignRGB(this.cyanColor, this.magentaColor, this.yellowColor, this.blackColor);
270
- this.filled = true;
271
- }
272
- /**
273
- * Gets or sets `Magenta` channel value.
274
- * @private
275
- */
276
- public get m(): number {
277
- return this.magentaColor;
278
- }
279
- public set m(value: number) {
280
- if ((value < 0)) {
281
- this.magentaColor = 0;
282
- } else if ((value > 1)) {
283
- this.magentaColor = 1;
284
- } else {
285
- this.magentaColor = value;
286
- }
287
- this.assignRGB(this.cyanColor, this.magentaColor, this.yellowColor, this.blackColor);
288
- this.filled = true;
289
- }
290
- /**
291
- * Gets or sets `Yellow` channel value.
292
- * @private
293
- */
294
- public get y(): number {
295
- return this.yellowColor;
296
- }
297
- public set y(value: number) {
298
- if ((value < 0)) {
299
- this.yellowColor = 0;
300
- } else if ((value > 1)) {
301
- this.yellowColor = 1;
302
- } else {
303
- this.yellowColor = value;
304
- }
305
- this.assignRGB(this.cyanColor, this.magentaColor, this.yellowColor, this.blackColor);
306
- this.filled = true;
307
- }
308
- /**
309
- * Gets or sets `Green` channel value.
310
- * @private
311
- */
312
- public get g() : number {
313
- return this.greenColor;
314
- }
315
- public set g(value : number) {
316
- this.greenColor = value;
317
- this.assignCMYK(this.redColor, this.greenColor, this.blueColor);
318
- this.filled = true;
319
- }
320
- /**
321
- * Gets the `Green` color.
322
- * @private
323
- */
324
- public get green() : number {
325
- return (this.g / PdfColor.maxColourChannelValue);
326
- }
327
- /**
328
- * Gets or sets `Gray` channel value.
329
- * @private
330
- */
331
- public get gray() : number
332
- {
333
- return ((((this.redColor + this.greenColor) + this.blueColor)) / (PdfColor.maxColourChannelValue * 3));
334
- }
335
- public set gray(value : number) {
336
- if (value < 0) {
337
- this.grayColor = 0;
338
- } else if (value > 1) {
339
- this.grayColor = 1;
340
- } else {
341
- this.grayColor = value;
342
- }
343
- this.r = (this.grayColor * PdfColor.maxColourChannelValue);
344
- this.g = (this.grayColor * PdfColor.maxColourChannelValue);
345
- this.b = (this.grayColor * PdfColor.maxColourChannelValue);
346
- this.assignCMYK(this.redColor, this.greenColor, this.blueColor);
347
- this.filled = true;
348
- }
349
- /**
350
- * Gets whether the PDFColor `is Empty` or not.
351
- * @private
352
- */
353
- public get isEmpty() : boolean
354
- {
355
- return !this.filled;
356
- }
357
- /**
358
- * Gets or sets `Alpha` channel value.
359
- * @private
360
- */
361
- public get a() : number
362
- {
363
- return this.alpha;
364
- }
365
- public set a(value : number) {
366
- if (value < 0) {
367
- this.alpha = 0;
368
- } else {
369
- // if (this.alpha !== value) {
370
- this.alpha = value;
371
- // }
372
- }
373
- this.filled = true;
374
- }
375
- //Public methods
376
- /**
377
- * Converts `PDFColor to PDF string` representation.
378
- * @private
379
- */
380
- public toString(colorSpace : PdfColorSpace, stroke : boolean) : string {
381
- if (this.isEmpty) {
382
- return '';
383
- }
384
- let str : string = '';
385
- switch (colorSpace) {
386
- case PdfColorSpace.Rgb:
387
- str = this.rgbToString(stroke);
388
- break;
389
- case PdfColorSpace.GrayScale:
390
- str = this.grayScaleToString(stroke);
391
- break;
392
- case PdfColorSpace.Cmyk:
393
- str = this.cmykToString(stroke);
394
- break;
395
- }
396
- return str;
397
- }
398
- /**
399
- * Sets `GrayScale` color.
400
- * @private
401
- */
402
- private grayScaleToString(ifStroking : boolean) : string {
403
- let gray : number = this.gray;
404
- let colour : string = '';
405
- let obj : Object = null;
406
- /* tslint:disable-next-line:max-line-length */
407
- obj = (ifStroking) ? PdfColor.grayStringsSroke.containsKey(gray) ? PdfColor.grayStringsSroke.getValue(gray) : null : PdfColor.grayStringsFill.containsKey(gray) ? PdfColor.grayStringsFill.getValue(gray) : null;
408
- if (obj == null) {
409
- if (ifStroking) {
410
- colour = gray.toString() + ' G';
411
- PdfColor.grayStringsSroke.setValue(gray, colour);
412
- }
413
- } else {
414
- colour = obj.toString();
415
- }
416
- return colour + Operators.newLine;
417
- }
418
- /**
419
- * Sets `RGB` color.
420
- * @private
421
- */
422
- private rgbToString(ifStroking : boolean) : string {
423
- let r : number = this.r;
424
- let g : number = this.g;
425
- let b : number = this.b;
426
- let key : number = (r << 16) + (g << 8) + b;
427
- if (ifStroking) {
428
- key += 1 << 24;
429
- }
430
- let colour : string = '';
431
- let obj : Object = null;
432
- if (PdfColor.rgbStrings.containsKey(key)) {
433
- obj = PdfColor.rgbStrings.getValue(key);
434
- }
435
- if (obj == null) {
436
- let red : number = r / PdfColor.maxColourChannelValue;
437
- let green : number = g / PdfColor.maxColourChannelValue;
438
- let blue : number = b / PdfColor.maxColourChannelValue;
439
- if (ifStroking) {
440
- colour = red.toString() + ' ' + green.toString() + ' ' + blue.toString() + ' RG';
441
- } else {
442
- colour = red.toString() + ' ' + green.toString() + ' ' + blue.toString() + ' rg';
443
- }
444
- PdfColor.rgbStrings.setValue(key, colour);
445
- } else {
446
- colour = obj.toString();
447
- }
448
- return colour + Operators.newLine;
449
- }
450
- /***
451
- * Sets `CMYK` color.
452
- * @private
453
- */
454
- private cmykToString(ifStroking : boolean) : string {
455
- let cyan : number = this.c;
456
- let magenta : number = this.m;
457
- let yellow : number = this.y;
458
- let black : number = this.b;
459
- let colour : string = '';
460
- colour = cyan.toString() + ' ' + magenta.toString() + ' ' + yellow.toString() + ' ' + black.toString() + ' K';
461
- return colour + Operators.newLine;
462
- }
463
- /**
464
- * Converts `colour to a PDF array`.
465
- * @private
466
- */
467
- public toArray(colorSpace : PdfColorSpace) : PdfArray {
468
- let array : PdfArray = new PdfArray();
469
- switch (colorSpace) {
470
- case PdfColorSpace.Rgb:
471
- array.add(new PdfNumber(this.red));
472
- array.add(new PdfNumber(this.green));
473
- array.add(new PdfNumber(this.blue));
474
- break;
475
- }
476
- return array;
477
- }
478
- }