@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,644 +0,0 @@
1
- /**
2
- * PdfSection.ts class for EJ2-PDF
3
- */
4
- import { PdfDocument } from './../document/pdf-document';
5
- import { PdfDocumentBase } from './../document/pdf-document-base';
6
- import { PdfPageSettings } from './pdf-page-settings';
7
- import { PdfPage } from './pdf-page';
8
- import { PageAddedEventArgs } from './page-added-event-arguments';
9
- import { PdfPageBase } from './pdf-page-base';
10
- import { PdfPageOrientation, PdfPageRotateAngle } from './enum';
11
- import { PdfReferenceHolder } from './../primitives/pdf-reference';
12
- import { PdfArray } from './../primitives/pdf-array';
13
- import { PdfNumber } from './../primitives/pdf-number';
14
- import { PdfName } from './../primitives/pdf-name';
15
- import { PdfDictionary } from './../primitives/pdf-dictionary';
16
- import { SaveSectionEventHandler } from './../primitives/pdf-dictionary';
17
- import { DictionaryProperties } from './../input-output/pdf-dictionary-properties';
18
- import { IPdfWrapper } from './../../interfaces/i-pdf-wrapper';
19
- import { IPdfPrimitive } from './../../interfaces/i-pdf-primitives';
20
- import { IPdfWriter } from './../../interfaces/i-pdf-writer';
21
- import { PdfSectionCollection } from './pdf-section-collection';
22
- import { PdfSectionPageCollection } from './pdf-section-page-collection';
23
- import { PointF, RectangleF, SizeF } from './../drawing/pdf-drawing';
24
- import { PdfSectionTemplate } from './pdf-section-templates';
25
- import { PdfPageTemplateElement } from './pdf-page-template-element';
26
- import { PdfPageLayer } from './pdf-page-layer';
27
- /**
28
- * Represents a `section` entity. A section it's a set of the pages with similar page settings.
29
- */
30
- export class PdfSection implements IPdfWrapper {
31
- //Fields
32
- //public PageAdded() : PageAddedEventArgs.PageAddedEventHandler = new PageAddedEventArgs.PageAddedEventHandler(Object,args)
33
- /**
34
- * @hidden
35
- * @private
36
- */
37
- private pageAdded : PageAddedEventArgs = new PageAddedEventArgs();
38
- /**
39
- * the parent `document`.
40
- * @private
41
- */
42
- private pdfDocument : PdfDocument;
43
- /**
44
- * Page `settings` of the pages in the section.
45
- * @private
46
- */
47
- private settings : PdfPageSettings;
48
- /**
49
- * Internal variable to store `initial page settings`.
50
- * @private
51
- */
52
- public initialSettings : PdfPageSettings;
53
- /**
54
- * @hidden
55
- * @private
56
- */
57
- public pagesReferences : PdfArray;
58
- /**
59
- * @hidden
60
- * @private
61
- */
62
- private section : PdfDictionary;
63
- /**
64
- * @hidden
65
- * @private
66
- */
67
- private pageCount : PdfNumber;
68
- /**
69
- * @hidden
70
- * @private
71
- */
72
- private sectionCollection : PdfSectionCollection;
73
- /**
74
- * @hidden
75
- * @private
76
- */
77
- private pdfPages : PdfPageBase[] = [];
78
- /**
79
- * Indicates if the `progress is turned on`.
80
- * @private
81
- */
82
- private isProgressOn : boolean;
83
- /**
84
- * Page `template` for the section.
85
- * @private
86
- */
87
- private pageTemplate : PdfSectionTemplate;
88
- /**
89
- * @hidden
90
- * @private
91
- */
92
- private dictionaryProperties : DictionaryProperties = new DictionaryProperties();
93
- /**
94
- * A virtual `collection of pages`.
95
- * @private
96
- */
97
- private pagesCollection : PdfSectionPageCollection;
98
- /**
99
- * Stores the information about the page settings of the current section.
100
- * @private
101
- */
102
- private state : PageSettingsState;
103
- //constructor
104
- /**
105
- * Initializes a new instance of the `PdfSection` class.
106
- * @private
107
- */
108
- constructor(document : PdfDocument)
109
- /**
110
- * Initializes a new instance of the `PdfSection` class.
111
- * @private
112
- */
113
- constructor(document : PdfDocument, pageSettings : PdfPageSettings)
114
- constructor(document : PdfDocument, pageSettings? : PdfPageSettings) {
115
- this.pdfDocument = document;
116
- if (typeof pageSettings === 'undefined') {
117
- this.settings = document.pageSettings.clone();
118
- this.initialSettings = this.settings.clone();
119
- } else {
120
- this.settings = pageSettings.clone();
121
- this.initialSettings = this.settings.clone();
122
- }
123
- this.initialize();
124
- }
125
- //Property
126
- /**
127
- * Gets or sets the `parent`.
128
- * @private
129
- */
130
- public get parent() : PdfSectionCollection {
131
- return this.sectionCollection;
132
- }
133
- public set parent(value : PdfSectionCollection) {
134
- this.sectionCollection = value;
135
- this.section.items.setValue(this.dictionaryProperties.parent, new PdfReferenceHolder(value));
136
- }
137
- /**
138
- * Gets the `parent document`.
139
- * @private
140
- */
141
- public get parentDocument() : PdfDocumentBase {
142
- return this.pdfDocument;
143
- }
144
- /**
145
- * Gets or sets the `page settings` of the section.
146
- * @private
147
- */
148
- public get pageSettings() : PdfPageSettings {
149
- return this.settings;
150
- }
151
- public set pageSettings(value : PdfPageSettings) {
152
- if (value != null) {
153
- this.settings = value;
154
- } else {
155
- throw Error('Value can not be null.');
156
- }
157
- }
158
- /**
159
- * Gets the wrapped `element`.
160
- * @private
161
- */
162
- public get element() : IPdfPrimitive {
163
- return this.section;
164
- }
165
- /**
166
- * Gets the `count` of the pages in the section.
167
- * @private
168
- */
169
- public get count() : number {
170
- return this.pagesReferences.count;
171
- }
172
- /**
173
- * Gets or sets a `template` for the pages in the section.
174
- * @private
175
- */
176
- public get template() : PdfSectionTemplate {
177
- if (this.pageTemplate == null) {
178
- this.pageTemplate = new PdfSectionTemplate();
179
- }
180
- return this.pageTemplate;
181
- }
182
- public set template(value : PdfSectionTemplate) {
183
- this.pageTemplate = value;
184
- }
185
- /**
186
- * Gets the `document`.
187
- * @private
188
- */
189
- public get document() : PdfDocument {
190
- return this.sectionCollection.document;
191
- }
192
- /**
193
- * Gets the collection of `pages` in a section (Read only)
194
- * @private
195
- */
196
- public get pages() : PdfSectionPageCollection {
197
- if (this.pagesCollection == null || typeof this.pagesCollection === 'undefined') {
198
- this.pagesCollection = new PdfSectionPageCollection(this);
199
- }
200
- return this.pagesCollection;
201
- }
202
- //methods
203
- /**
204
- * `Return the page collection` of current section.
205
- * @private
206
- */
207
- public getPages() : PdfPageBase[] {
208
- return this.pdfPages;
209
- }
210
- /**
211
- * `Translates` point into native coordinates of the page.
212
- * @private
213
- */
214
- public pointToNativePdf(page : PdfPage, point : PointF) : PointF {
215
- let bounds : RectangleF = this.getActualBounds(page, true);
216
- point.x += bounds.x;
217
- point.y = this.pageSettings.height - (point.y);
218
- return point;
219
- }
220
- /**
221
- * Sets the page setting of the current section.
222
- * @public
223
- * @param settings Instance of `PdfPageSettings`
224
- */
225
- public setPageSettings(settings : PdfPageSettings) : void {
226
- this.settings = settings;
227
- this.state.orientation = settings.orientation;
228
- this.state.rotate = settings.rotate;
229
- this.state.size = settings.size;
230
- this.state.origin = settings.origin;
231
- }
232
- /**
233
- * `Initializes` the object.
234
- * @private
235
- */
236
- private initialize() : void {
237
- this.pagesReferences = new PdfArray();
238
- this.section = new PdfDictionary();
239
- this.state = new PageSettingsState(this.pdfDocument);
240
- this.section.sectionBeginSave = new SaveSectionEventHandler(this, this.state);
241
- this.pageCount = new PdfNumber(0);
242
- this.section.items.setValue(this.dictionaryProperties.count, this.pageCount);
243
- this.section.items.setValue(this.dictionaryProperties.type, new PdfName(this.dictionaryProperties.pages));
244
- this.section.items.setValue(this.dictionaryProperties.kids, this.pagesReferences);
245
- }
246
- /**
247
- * Checks whether any template should be printed on this layer.
248
- * @private
249
- * @param document The parent document.
250
- * @param page The parent page.
251
- * @param foreground Layer z-order.
252
- * @returns True - if some content should be printed on the layer, False otherwise.
253
- */
254
- public containsTemplates(document : PdfDocument, page : PdfPage, foreground : boolean) : boolean {
255
- let documentHeaders : PdfPageTemplateElement[] = this.getDocumentTemplates(document, page, foreground);
256
- let sectionTemplates : PdfPageTemplateElement[] = this.getSectionTemplates(page, foreground);
257
- return (documentHeaders.length > 0 || sectionTemplates.length > 0);
258
- }
259
- /**
260
- * Returns array of the document templates.
261
- * @private
262
- * @param document The parent document.
263
- * @param page The parent page.
264
- * @param headers If true - return headers/footers, if false - return simple templates.
265
- * @param foreground If true - return foreground templates, if false - return background templates.
266
- * @returns Returns array of the document templates.
267
- */
268
- /* tslint:disable */
269
- private getDocumentTemplates(document : PdfDocument, page : PdfPage, foreground : boolean) : PdfPageTemplateElement[] {
270
- let templates : PdfPageTemplateElement[] = [];
271
- if (this.template.applyDocumentTopTemplate && document.template.getTop(page) != null) {
272
- if ((!(document.template.getTop(page).foreground || foreground)) || (document.template.getTop(page).foreground && foreground)) {
273
- templates.push(document.template.getTop(page));
274
- }
275
- }
276
- if (this.template.applyDocumentBottomTemplate && document.template.getBottom(page) != null) {
277
- if ((!(document.template.getBottom(page).foreground || foreground)) || (document.template.getBottom(page).foreground && foreground)) {
278
- templates.push(document.template.getBottom(page));
279
- }
280
- }
281
- if (this.template.applyDocumentLeftTemplate && document.template.getLeft(page) != null) {
282
- if ((!(document.template.getLeft(page).foreground || foreground)) || (document.template.getLeft(page).foreground && foreground)) {
283
- templates.push(document.template.getLeft(page));
284
- }
285
- }
286
- if (this.template.applyDocumentRightTemplate && document.template.getRight(page) != null) {
287
- if ((!(document.template.getRight(page).foreground || foreground)) || (document.template.getRight(page).foreground && foreground)) {
288
- templates.push(document.template.getRight(page));
289
- }
290
- }
291
- return templates;
292
- }
293
- /**
294
- * Returns array of the section templates.
295
- * @private
296
- * @param page The parent page.
297
- * @param foreground If true - return foreground templates, if false - return background templates.
298
- * @returns Returns array of the section templates.
299
- */
300
- /* tslint:disable */
301
- private getSectionTemplates(page : PdfPage, foreground : boolean) : PdfPageTemplateElement[] {
302
- let templates : PdfPageTemplateElement[] = [];
303
- if (this.template.getTop(page) != null) {
304
- let pageTemplate : PdfPageTemplateElement = this.template.getTop(page);
305
- if ((!(pageTemplate.foreground || foreground)) || (pageTemplate.foreground && foreground)) {
306
- templates.push(pageTemplate);
307
- }
308
- }
309
- if (this.template.getBottom(page) != null) {
310
- let pageTemplate : PdfPageTemplateElement = this.template.getBottom(page);
311
- if ((!(pageTemplate.foreground || foreground)) || (pageTemplate.foreground && foreground)) {
312
- templates.push(pageTemplate);
313
- }
314
- }
315
- if (this.template.getLeft(page) != null) {
316
- let pageTemplate : PdfPageTemplateElement = this.template.getLeft(page);
317
- if ((!(pageTemplate.foreground || foreground)) || (pageTemplate.foreground && foreground)) {
318
- templates.push(pageTemplate);
319
- }
320
- }
321
- if (this.template.getRight(page) != null) {
322
- let pageTemplate : PdfPageTemplateElement = this.template.getRight(page);
323
- if ((!(pageTemplate.foreground || foreground)) || (pageTemplate.foreground && foreground)) {
324
- templates.push(pageTemplate);
325
- }
326
- }
327
- return templates;
328
- }
329
- /* tslint:enable */
330
- /**
331
- * `Adds` the specified page.
332
- * @private
333
- */
334
- public add(page? : PdfPage) : void | PdfPage {
335
- if (typeof page === 'undefined') {
336
- let page : PdfPage = new PdfPage();
337
- this.add(page);
338
- return page;
339
- } else {
340
- let r : PdfReferenceHolder = this.checkPresence(page);
341
- this.pdfPages.push(page);
342
- this.pagesReferences.add(r);
343
- page.setSection(this);
344
- page.resetProgress();
345
- this.pageAddedMethod(page);
346
- }
347
- }
348
- /**
349
- * `Checks the presence`.
350
- * @private
351
- */
352
- private checkPresence(page : PdfPage) : PdfReferenceHolder {
353
- let rh : PdfReferenceHolder = new PdfReferenceHolder(page);
354
- let contains : boolean = false;
355
- let sc : PdfSectionCollection = this.parent;
356
- for (let index : number = 0; index < sc.section.length; index++) {
357
- let section : PdfSection = sc.section[index];
358
- contains = contains || section.contains(page);
359
- }
360
- return rh;
361
- }
362
- /**
363
- * `Determines` whether the page in within the section.
364
- * @private
365
- */
366
- public contains(page : PdfPage) : boolean {
367
- let index : number = this.indexOf(page);
368
- return (0 <= index);
369
- }
370
- /**
371
- * Get the `index of` the page.
372
- * @private
373
- */
374
- public indexOf(page : PdfPage) : number {
375
- for (let index : number = 0; index < this.pdfPages.length; index++) {
376
- if (this.pdfPages[index] === page) {
377
- return this.pdfPages.indexOf(page);
378
- }
379
- }
380
- let r : PdfReferenceHolder = new PdfReferenceHolder(page);
381
- return this.pagesReferences.indexOf(r);
382
- }
383
- /**
384
- * Call two event's methods.
385
- * @hidden
386
- * @private
387
- */
388
- private pageAddedMethod(page : PdfPage) : void {
389
- //Create event's arguments
390
- let args : PageAddedEventArgs = new PageAddedEventArgs(page);
391
- this.onPageAdded(args);
392
- let parent : PdfSectionCollection = this.parent;
393
- parent.document.pages.onPageAdded(args);
394
- this.pageCount.intValue = this.count;
395
- }
396
- /**
397
- * Called when the page has been added.
398
- * @hidden
399
- * @private
400
- */
401
- protected onPageAdded(args : PageAddedEventArgs) : void {
402
- //
403
- }
404
- /**
405
- * Calculates actual `bounds` of the page.
406
- * @private
407
- */
408
- public getActualBounds(page : PdfPage, includeMargins : boolean) : RectangleF
409
- /**
410
- * Calculates actual `bounds` of the page.
411
- * @private
412
- */
413
- public getActualBounds(document : PdfDocument, page : PdfPage, includeMargins : boolean) : RectangleF
414
- public getActualBounds(arg1 : PdfDocument | PdfPage, arg2 : PdfPage|boolean, arg3 ?: boolean) : RectangleF {
415
- if (arg1 instanceof PdfPage && typeof arg2 === 'boolean') {
416
- let result : RectangleF;
417
- let document : PdfDocument = this.parent.document;
418
- result = this.getActualBounds(document, arg1, arg2);
419
- return result;
420
- } else {
421
- arg1 = arg1 as PdfDocument;
422
- arg2 = arg2 as PdfPage;
423
- arg3 = arg3 as boolean;
424
- let bounds : RectangleF = new RectangleF(0, 0, 0, 0);
425
- bounds.height = (arg3) ? this.pageSettings.size.height : this.pageSettings.getActualSize().height;
426
- bounds.width = (arg3) ? this.pageSettings.size.width : this.pageSettings.getActualSize().width;
427
- let left : number = this.getLeftIndentWidth(arg1, arg2, arg3);
428
- let top : number = this.getTopIndentHeight(arg1, arg2, arg3);
429
- let right : number = this.getRightIndentWidth(arg1, arg2, arg3);
430
- let bottom : number = this.getBottomIndentHeight(arg1, arg2, arg3);
431
- bounds.x += left;
432
- bounds.y += top;
433
- bounds.width -= (left + right);
434
- bounds.height -= (top + bottom);
435
- return bounds;
436
- }
437
- }
438
- /**
439
- * Calculates width of the `left indent`.
440
- * @private
441
- */
442
- public getLeftIndentWidth(document : PdfDocument, page : PdfPage, includeMargins : boolean) : number {
443
- if (document == null) {
444
- throw new Error('ArgumentNullException:document');
445
- }
446
- if (page == null) {
447
- throw new Error('ArgumentNullException:page');
448
- }
449
- let value : number = (includeMargins) ? this.pageSettings.margins.left : 0;
450
- let templateWidth : number = (this.template.getLeft(page) != null) ? this.template.getLeft(page).width : 0;
451
- let docTemplateWidth : number = (document.template.getLeft(page) != null) ? document.template.getLeft(page).width : 0;
452
- value += (this.template.applyDocumentLeftTemplate) ? Math.max(templateWidth, docTemplateWidth) : templateWidth;
453
- return value;
454
- }
455
- /**
456
- * Calculates `Height` of the top indent.
457
- * @private
458
- */
459
- public getTopIndentHeight(document : PdfDocument, page : PdfPage, includeMargins : boolean) : number {
460
- if (document == null) {
461
- throw new Error('ArgumentNullException:document');
462
- }
463
- if (page == null) {
464
- throw new Error('ArgumentNullException:page');
465
- }
466
- let value : number = (includeMargins) ? this.pageSettings.margins.top : 0;
467
- let templateHeight : number = (this.template.getTop(page) != null) ? this.template.getTop(page).height : 0;
468
- let docTemplateHeight : number = (document.template.getTop(page) != null) ? document.template.getTop(page).height : 0;
469
- value += (this.template.applyDocumentTopTemplate) ? Math.max(templateHeight, docTemplateHeight) : templateHeight;
470
- return value;
471
- }
472
- /**
473
- * Calculates `width` of the right indent.
474
- * @private
475
- */
476
- public getRightIndentWidth(document : PdfDocument, page : PdfPage, includeMargins : boolean) : number {
477
- if (document == null) {
478
- throw new Error('ArgumentNullException:document');
479
- }
480
- if (page == null) {
481
- throw new Error('ArgumentNullException:page');
482
- }
483
- let value : number = (includeMargins) ? this.pageSettings.margins.right : 0;
484
- let templateWidth : number = (this.template.getRight(page) != null) ? this.template.getRight(page).width : 0;
485
- let docTemplateWidth : number = (document.template.getRight(page) != null) ? document.template.getRight(page).width : 0;
486
- value += (this.template.applyDocumentRightTemplate) ? Math.max(templateWidth, docTemplateWidth) : templateWidth;
487
- return value;
488
- }
489
- /**
490
- * Calculates `Height` of the bottom indent.
491
- * @private
492
- */
493
- public getBottomIndentHeight(document : PdfDocument, page : PdfPage, includeMargins : boolean) : number {
494
- if (document == null) {
495
- throw new Error('ArgumentNullException:document');
496
- }
497
- if (page == null) {
498
- throw new Error('ArgumentNullException:page');
499
- }
500
- let value : number = (includeMargins) ? this.pageSettings.margins.bottom : 0;
501
- let templateHeight : number = (this.template.getBottom(page) != null) ? this.template.getBottom(page).height : 0;
502
- let docTemplateHeight : number = (document.template.getBottom(page) != null) ? document.template.getBottom(page).height : 0;
503
- value += (this.template.applyDocumentBottomTemplate) ? Math.max(templateHeight, docTemplateHeight) : templateHeight;
504
- return value;
505
- }
506
- /**
507
- * `Removes` the page from the section.
508
- * @private
509
- */
510
- public remove(page : PdfPage) : void {
511
- if (page == null) {
512
- throw Error('ArgumentNullException("page")');
513
- }
514
- let index : number = this.pdfPages.indexOf(page);
515
- this.pagesReferences.removeAt(index);
516
- let temproaryPages : PdfPageBase[] = [];
517
- for (let j : number = 0; j < index; j++) {
518
- temproaryPages.push(this.pdfPages[j]);
519
- }
520
- for (let j : number = index + 1; j < this.pdfPages.length; j++) {
521
- temproaryPages.push(this.pdfPages[j]);
522
- }
523
- this.pdfPages = temproaryPages;
524
- }
525
- /**
526
- * In fills dictionary by the data from `Page settings`.
527
- * @private
528
- */
529
- private applyPageSettings(container : PdfDictionary, parentSettings : PdfPageSettings, state : PageSettingsState) : void {
530
- let bounds : RectangleF = new RectangleF(state.origin, state.size);
531
- container.items.setValue(this.dictionaryProperties.mediaBox, PdfArray.fromRectangle(bounds));
532
- let rotate : number = 0;
533
- rotate = PdfSectionCollection.rotateFactor * state.rotate;
534
- let angle : PdfNumber = new PdfNumber(rotate);
535
- container.items.setValue(this.dictionaryProperties.rotate, angle);
536
- }
537
- /**
538
- * Catches the Save event of the dictionary.
539
- * @hidden
540
- * @private
541
- */
542
- public beginSave(state : PageSettingsState, writer : IPdfWriter) : void {
543
- let doc : PdfDocument = writer.document as PdfDocument;
544
- this.applyPageSettings(this.section, doc.pageSettings, state);
545
- }
546
- /**
547
- * Draws page templates on the page.
548
- * @private
549
- */
550
- public drawTemplates(page : PdfPage, layer : PdfPageLayer, document : PdfDocument, foreground : boolean) : void {
551
- let documentHeaders : PdfPageTemplateElement[] = this.getDocumentTemplates(document, page, foreground);
552
- let sectionHeaders : PdfPageTemplateElement[] = this.getSectionTemplates(page, foreground);
553
- this.drawTemplatesHelper(layer, document, documentHeaders);
554
- this.drawTemplatesHelper(layer, document, sectionHeaders);
555
- }
556
- /**
557
- * Draws page templates on the page.
558
- * @private
559
- */
560
- private drawTemplatesHelper(layer : PdfPageLayer, document : PdfDocument, templates : PdfPageTemplateElement[]) : void {
561
- if (templates != null && templates.length > 0) {
562
- let len : number = templates.length;
563
- for (let i : number = 0; i < len; i++) {
564
- let template : PdfPageTemplateElement = templates[i];
565
- template.draw(layer, document);
566
- }
567
- }
568
- }
569
- }
570
- export class PageSettingsState {
571
- //Private Fields
572
- /**
573
- * @hidden
574
- * @private
575
- */
576
- private pageOrientation : PdfPageOrientation;
577
- /**
578
- * @hidden
579
- * @private
580
- */
581
- private pageRotate : PdfPageRotateAngle;
582
- /**
583
- * @hidden
584
- * @private
585
- */
586
- private pageSize : SizeF;
587
- /**
588
- * @hidden
589
- * @private
590
- */
591
- private pageOrigin : PointF;
592
- //public Properties
593
- /**
594
- * @hidden
595
- * @private
596
- */
597
- public get orientation() : PdfPageOrientation {
598
- return this.pageOrientation;
599
- }
600
- public set orientation(value : PdfPageOrientation) {
601
- this.pageOrientation = value;
602
- }
603
- /**
604
- * @hidden
605
- * @private
606
- */
607
- public get rotate() : PdfPageRotateAngle {
608
- return this.pageRotate;
609
- }
610
- public set rotate(value : PdfPageRotateAngle) {
611
- this.pageRotate = value;
612
- }
613
- /**
614
- * @hidden
615
- * @private
616
- */
617
- public get size() : SizeF {
618
- return this.pageSize;
619
- }
620
- public set size(value : SizeF) {
621
- this.pageSize = value;
622
- }
623
- /**
624
- * @hidden
625
- * @private
626
- */
627
- public get origin() : PointF {
628
- return this.pageOrigin;
629
- }
630
- public set origin(value : PointF) {
631
- this.pageOrigin = value;
632
- }
633
- //Public Constructor
634
- /**
635
- * New instance to store the `PageSettings`.
636
- * @private
637
- */
638
- public constructor(document : PdfDocument) {
639
- this.pageOrientation = document.pageSettings.orientation;
640
- this.pageRotate = document.pageSettings.rotate;
641
- this.pageSize = document.pageSettings.size;
642
- this.pageOrigin = document.pageSettings.origin;
643
- }
644
- }