@syncfusion/ej2-pdf-export 23.2.6 → 24.1.41
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/CHANGELOG.md +0 -26
- package/dist/ej2-pdf-export.min.js +2 -2
- package/dist/ej2-pdf-export.umd.min.js +1 -1
- package/dist/ej2-pdf-export.umd.min.js.map +1 -1
- package/dist/es6/ej2-pdf-export.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf-export.es5.js.map +1 -1
- package/dist/global/ej2-pdf-export.min.js +1 -1
- package/dist/global/ej2-pdf-export.min.js.map +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 +65 -0
- package/dist/ts/implementation/document/pdf-document-base.ts +180 -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/document/pdf-viewer-preferences.ts +578 -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 +63 -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 +439 -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 +2429 -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 +571 -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 +663 -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 +306 -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 +1193 -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 +7 -7
- package/src/implementation/document/pdf-document-base.js +1 -2
|
@@ -0,0 +1,644 @@
|
|
|
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
|
+
}
|