pdfmake 0.3.0-beta.3 → 0.3.0-beta.5
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 +9 -0
- package/build/pdfmake.js +2213 -8630
- package/build/pdfmake.js.map +1 -1
- package/build/pdfmake.min.js +2 -2
- package/build/pdfmake.min.js.map +1 -1
- package/build/vfs_fonts.js +6 -5
- package/js/3rd-party/svg-to-pdfkit/source.js +247 -920
- package/js/3rd-party/svg-to-pdfkit.js +0 -3
- package/js/DocMeasure.js +6 -139
- package/js/DocPreprocessor.js +2 -54
- package/js/DocumentContext.js +0 -40
- package/js/ElementWriter.js +2 -70
- package/js/LayoutBuilder.js +20 -165
- package/js/Line.js +6 -25
- package/js/OutputDocument.js +15 -24
- package/js/OutputDocumentServer.js +0 -6
- package/js/PDFDocument.js +1 -46
- package/js/PageElementWriter.js +7 -31
- package/js/PageSize.js +2 -16
- package/js/Printer.js +5 -46
- package/js/Renderer.js +11 -98
- package/js/SVGMeasure.js +1 -20
- package/js/StyleContextStack.js +12 -36
- package/js/TableProcessor.js +36 -117
- package/js/TextBreaker.js +2 -44
- package/js/TextDecorator.js +1 -38
- package/js/TextInlines.js +8 -49
- package/js/URLResolver.js +0 -13
- package/js/base.js +1 -17
- package/js/browser-extensions/OutputDocumentBrowser.js +5 -17
- package/js/browser-extensions/URLBrowserResolver.js +0 -17
- package/js/browser-extensions/fonts/Roboto.js +0 -4
- package/js/browser-extensions/index.js +0 -16
- package/js/browser-extensions/pdfMake.js +2 -4
- package/js/browser-extensions/standard-fonts/Courier.js +0 -4
- package/js/browser-extensions/standard-fonts/Helvetica.js +0 -4
- package/js/browser-extensions/standard-fonts/Symbol.js +0 -4
- package/js/browser-extensions/standard-fonts/Times.js +0 -4
- package/js/browser-extensions/standard-fonts/ZapfDingbats.js +0 -4
- package/js/columnCalculator.js +6 -18
- package/js/helpers/node.js +3 -27
- package/js/helpers/tools.js +0 -8
- package/js/helpers/variableType.js +4 -9
- package/js/index.js +0 -6
- package/js/qrEnc.js +126 -215
- package/js/tableLayouts.js +1 -28
- package/js/virtual-fs.js +3 -19
- package/package.json +2 -2
- package/src/OutputDocument.js +78 -78
package/js/DocPreprocessor.js
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
-
|
|
6
5
|
var _variableType = require("./helpers/variableType");
|
|
7
|
-
|
|
8
6
|
var _node = require("./helpers/node");
|
|
9
|
-
|
|
10
7
|
const convertValueToString = value => {
|
|
11
8
|
if ((0, _variableType.isString)(value)) {
|
|
12
9
|
return value.replace(/\t/g, ' '); // expand tab as spaces
|
|
@@ -14,12 +11,12 @@ const convertValueToString = value => {
|
|
|
14
11
|
return value.toString();
|
|
15
12
|
} else if (!(0, _variableType.isValue)(value) || (0, _variableType.isEmptyObject)(value)) {
|
|
16
13
|
return '';
|
|
17
|
-
}
|
|
14
|
+
}
|
|
18
15
|
|
|
16
|
+
// TODO: throw exception ?
|
|
19
17
|
|
|
20
18
|
return value;
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
class DocPreprocessor {
|
|
24
21
|
preprocessDocument(docStructure) {
|
|
25
22
|
this.parentNode = null;
|
|
@@ -27,7 +24,6 @@ class DocPreprocessor {
|
|
|
27
24
|
this.nodeReferences = [];
|
|
28
25
|
return this.preprocessNode(docStructure);
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
preprocessNode(node) {
|
|
32
28
|
// expand shortcuts and casting values
|
|
33
29
|
if (Array.isArray(node)) {
|
|
@@ -43,7 +39,6 @@ class DocPreprocessor {
|
|
|
43
39
|
// cast value in text property
|
|
44
40
|
node.text = convertValueToString(node.text);
|
|
45
41
|
}
|
|
46
|
-
|
|
47
42
|
if (node.columns) {
|
|
48
43
|
return this.preprocessColumns(node);
|
|
49
44
|
} else if (node.stack) {
|
|
@@ -74,77 +69,59 @@ class DocPreprocessor {
|
|
|
74
69
|
throw new Error(`Unrecognized document structure: ${(0, _node.stringifyNode)(node)}`);
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
|
-
|
|
78
72
|
preprocessColumns(node) {
|
|
79
73
|
let columns = node.columns;
|
|
80
|
-
|
|
81
74
|
for (let i = 0, l = columns.length; i < l; i++) {
|
|
82
75
|
columns[i] = this.preprocessNode(columns[i]);
|
|
83
76
|
}
|
|
84
|
-
|
|
85
77
|
return node;
|
|
86
78
|
}
|
|
87
|
-
|
|
88
79
|
preprocessVerticalContainer(node) {
|
|
89
80
|
let items = node.stack;
|
|
90
|
-
|
|
91
81
|
for (let i = 0, l = items.length; i < l; i++) {
|
|
92
82
|
items[i] = this.preprocessNode(items[i]);
|
|
93
83
|
}
|
|
94
|
-
|
|
95
84
|
return node;
|
|
96
85
|
}
|
|
97
|
-
|
|
98
86
|
preprocessList(node) {
|
|
99
87
|
let items = node.ul || node.ol;
|
|
100
|
-
|
|
101
88
|
for (let i = 0, l = items.length; i < l; i++) {
|
|
102
89
|
items[i] = this.preprocessNode(items[i]);
|
|
103
90
|
}
|
|
104
|
-
|
|
105
91
|
return node;
|
|
106
92
|
}
|
|
107
|
-
|
|
108
93
|
preprocessTable(node) {
|
|
109
94
|
let col;
|
|
110
95
|
let row;
|
|
111
96
|
let cols;
|
|
112
97
|
let rows;
|
|
113
|
-
|
|
114
98
|
for (col = 0, cols = node.table.body[0].length; col < cols; col++) {
|
|
115
99
|
for (row = 0, rows = node.table.body.length; row < rows; row++) {
|
|
116
100
|
let rowData = node.table.body[row];
|
|
117
101
|
let data = rowData[col];
|
|
118
|
-
|
|
119
102
|
if (data !== undefined) {
|
|
120
103
|
if (data === null) {
|
|
121
104
|
// transform to object
|
|
122
105
|
data = '';
|
|
123
106
|
}
|
|
124
|
-
|
|
125
107
|
if (!data._span) {
|
|
126
108
|
rowData[col] = this.preprocessNode(data);
|
|
127
109
|
}
|
|
128
110
|
}
|
|
129
111
|
}
|
|
130
112
|
}
|
|
131
|
-
|
|
132
113
|
return node;
|
|
133
114
|
}
|
|
134
|
-
|
|
135
115
|
preprocessText(node) {
|
|
136
116
|
if (node.tocItem) {
|
|
137
117
|
if (!Array.isArray(node.tocItem)) {
|
|
138
118
|
node.tocItem = [node.tocItem];
|
|
139
119
|
}
|
|
140
|
-
|
|
141
120
|
for (let i = 0, l = node.tocItem.length; i < l; i++) {
|
|
142
121
|
if (!(0, _variableType.isString)(node.tocItem[i])) {
|
|
143
122
|
node.tocItem[i] = '_default_';
|
|
144
123
|
}
|
|
145
|
-
|
|
146
124
|
let tocItemId = node.tocItem[i];
|
|
147
|
-
|
|
148
125
|
if (!this.tocs[tocItemId]) {
|
|
149
126
|
this.tocs[tocItemId] = {
|
|
150
127
|
toc: {
|
|
@@ -153,26 +130,21 @@ class DocPreprocessor {
|
|
|
153
130
|
}
|
|
154
131
|
};
|
|
155
132
|
}
|
|
156
|
-
|
|
157
133
|
if (!node.id) {
|
|
158
134
|
node.id = `toc-${tocItemId}-${this.tocs[tocItemId].toc._items.length}`;
|
|
159
135
|
}
|
|
160
|
-
|
|
161
136
|
let tocItemRef = {
|
|
162
137
|
_nodeRef: this._getNodeForNodeRef(node),
|
|
163
138
|
_textNodeRef: node
|
|
164
139
|
};
|
|
165
|
-
|
|
166
140
|
this.tocs[tocItemId].toc._items.push(tocItemRef);
|
|
167
141
|
}
|
|
168
142
|
}
|
|
169
|
-
|
|
170
143
|
if (node.id) {
|
|
171
144
|
if (this.nodeReferences[node.id]) {
|
|
172
145
|
if (!this.nodeReferences[node.id]._pseudo) {
|
|
173
146
|
throw new Error(`Node id '${node.id}' already exists`);
|
|
174
147
|
}
|
|
175
|
-
|
|
176
148
|
this.nodeReferences[node.id]._nodeRef = this._getNodeForNodeRef(node);
|
|
177
149
|
this.nodeReferences[node.id]._textNodeRef = node;
|
|
178
150
|
this.nodeReferences[node.id]._pseudo = false;
|
|
@@ -183,7 +155,6 @@ class DocPreprocessor {
|
|
|
183
155
|
};
|
|
184
156
|
}
|
|
185
157
|
}
|
|
186
|
-
|
|
187
158
|
if (node.pageReference) {
|
|
188
159
|
if (!this.nodeReferences[node.pageReference]) {
|
|
189
160
|
this.nodeReferences[node.pageReference] = {
|
|
@@ -192,12 +163,10 @@ class DocPreprocessor {
|
|
|
192
163
|
_pseudo: true
|
|
193
164
|
};
|
|
194
165
|
}
|
|
195
|
-
|
|
196
166
|
node.text = '00000';
|
|
197
167
|
node.linkToDestination = node.pageReference;
|
|
198
168
|
node._pageRef = this.nodeReferences[node.pageReference];
|
|
199
169
|
}
|
|
200
|
-
|
|
201
170
|
if (node.textReference) {
|
|
202
171
|
if (!this.nodeReferences[node.textReference]) {
|
|
203
172
|
this.nodeReferences[node.textReference] = {
|
|
@@ -205,87 +174,66 @@ class DocPreprocessor {
|
|
|
205
174
|
_pseudo: true
|
|
206
175
|
};
|
|
207
176
|
}
|
|
208
|
-
|
|
209
177
|
node.text = '';
|
|
210
178
|
node.linkToDestination = node.textReference;
|
|
211
179
|
node._textRef = this.nodeReferences[node.textReference];
|
|
212
180
|
}
|
|
213
|
-
|
|
214
181
|
if (node.text && node.text.text) {
|
|
215
182
|
node.text = [this.preprocessNode(node.text)];
|
|
216
183
|
} else if (Array.isArray(node.text)) {
|
|
217
184
|
let isSetParentNode = false;
|
|
218
|
-
|
|
219
185
|
if (this.parentNode === null) {
|
|
220
186
|
this.parentNode = node;
|
|
221
187
|
isSetParentNode = true;
|
|
222
188
|
}
|
|
223
|
-
|
|
224
189
|
for (let i = 0, l = node.text.length; i < l; i++) {
|
|
225
190
|
node.text[i] = this.preprocessNode(node.text[i]);
|
|
226
191
|
}
|
|
227
|
-
|
|
228
192
|
if (isSetParentNode) {
|
|
229
193
|
this.parentNode = null;
|
|
230
194
|
}
|
|
231
195
|
}
|
|
232
|
-
|
|
233
196
|
return node;
|
|
234
197
|
}
|
|
235
|
-
|
|
236
198
|
preprocessToc(node) {
|
|
237
199
|
if (!node.toc.id) {
|
|
238
200
|
node.toc.id = '_default_';
|
|
239
201
|
}
|
|
240
|
-
|
|
241
202
|
node.toc.title = node.toc.title ? this.preprocessNode(node.toc.title) : null;
|
|
242
203
|
node.toc._items = [];
|
|
243
|
-
|
|
244
204
|
if (this.tocs[node.toc.id]) {
|
|
245
205
|
if (!this.tocs[node.toc.id].toc._pseudo) {
|
|
246
206
|
throw new Error(`TOC '${node.toc.id}' already exists`);
|
|
247
207
|
}
|
|
248
|
-
|
|
249
208
|
node.toc._items = this.tocs[node.toc.id].toc._items;
|
|
250
209
|
}
|
|
251
|
-
|
|
252
210
|
this.tocs[node.toc.id] = node;
|
|
253
211
|
return node;
|
|
254
212
|
}
|
|
255
|
-
|
|
256
213
|
preprocessImage(node) {
|
|
257
214
|
if (node.image.type !== undefined && node.image.data !== undefined && node.image.type === 'Buffer' && Array.isArray(node.image.data)) {
|
|
258
215
|
node.image = Buffer.from(node.image.data);
|
|
259
216
|
}
|
|
260
|
-
|
|
261
217
|
return node;
|
|
262
218
|
}
|
|
263
|
-
|
|
264
219
|
preprocessCanvas(node) {
|
|
265
220
|
return node;
|
|
266
221
|
}
|
|
267
|
-
|
|
268
222
|
preprocessSVG(node) {
|
|
269
223
|
return node;
|
|
270
224
|
}
|
|
271
|
-
|
|
272
225
|
preprocessQr(node) {
|
|
273
226
|
return node;
|
|
274
227
|
}
|
|
275
|
-
|
|
276
228
|
preprocessAttachment(node) {
|
|
277
229
|
return node;
|
|
278
230
|
}
|
|
279
|
-
|
|
280
231
|
_getNodeForNodeRef(node) {
|
|
281
232
|
if (this.parentNode) {
|
|
282
233
|
return this.parentNode;
|
|
283
234
|
}
|
|
284
|
-
|
|
285
235
|
return node;
|
|
286
236
|
}
|
|
287
|
-
|
|
288
237
|
}
|
|
289
|
-
|
|
290
238
|
var _default = DocPreprocessor;
|
|
291
239
|
exports.default = _default;
|
package/js/DocumentContext.js
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
-
|
|
6
5
|
var _variableType = require("./helpers/variableType");
|
|
7
|
-
|
|
8
6
|
var _events = require("events");
|
|
9
|
-
|
|
10
7
|
/**
|
|
11
8
|
* A store for current x, y positions and available width/height.
|
|
12
9
|
* It facilitates column divisions and vertical sync
|
|
@@ -25,7 +22,6 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
25
22
|
this.backgroundLength = [];
|
|
26
23
|
this.addPage(pageSize);
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
beginColumnGroup() {
|
|
30
26
|
this.snapshots.push({
|
|
31
27
|
x: this.x,
|
|
@@ -45,7 +41,6 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
45
41
|
});
|
|
46
42
|
this.lastColumnWidth = 0;
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
beginColumn(width, offset, endingCell) {
|
|
50
45
|
let saved = this.snapshots[this.snapshots.length - 1];
|
|
51
46
|
this.calculateBottomMost(saved);
|
|
@@ -54,11 +49,9 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
54
49
|
this.x = this.x + this.lastColumnWidth + (offset || 0);
|
|
55
50
|
this.y = saved.y;
|
|
56
51
|
this.availableWidth = width; //saved.availableWidth - offset;
|
|
57
|
-
|
|
58
52
|
this.availableHeight = saved.availableHeight;
|
|
59
53
|
this.lastColumnWidth = width;
|
|
60
54
|
}
|
|
61
|
-
|
|
62
55
|
calculateBottomMost(destContext) {
|
|
63
56
|
if (this.endingCell) {
|
|
64
57
|
this.saveContextInEndingCell(this.endingCell);
|
|
@@ -67,7 +60,6 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
67
60
|
destContext.bottomMost = bottomMostContext(this, destContext.bottomMost);
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
|
-
|
|
71
63
|
markEnding(endingCell) {
|
|
72
64
|
this.page = endingCell._columnEndingContext.page;
|
|
73
65
|
this.x = endingCell._columnEndingContext.x;
|
|
@@ -76,7 +68,6 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
76
68
|
this.availableHeight = endingCell._columnEndingContext.availableHeight;
|
|
77
69
|
this.lastColumnWidth = endingCell._columnEndingContext.lastColumnWidth;
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
saveContextInEndingCell(endingCell) {
|
|
81
72
|
endingCell._columnEndingContext = {
|
|
82
73
|
page: this.page,
|
|
@@ -87,14 +78,12 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
87
78
|
lastColumnWidth: this.lastColumnWidth
|
|
88
79
|
};
|
|
89
80
|
}
|
|
90
|
-
|
|
91
81
|
completeColumnGroup(height) {
|
|
92
82
|
let saved = this.snapshots.pop();
|
|
93
83
|
this.calculateBottomMost(saved);
|
|
94
84
|
this.endingCell = null;
|
|
95
85
|
this.x = saved.x;
|
|
96
86
|
let y = saved.bottomMost.y;
|
|
97
|
-
|
|
98
87
|
if (height) {
|
|
99
88
|
if (saved.page === saved.bottomMost.page) {
|
|
100
89
|
if (saved.y + height > y) {
|
|
@@ -104,36 +93,29 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
104
93
|
y += height;
|
|
105
94
|
}
|
|
106
95
|
}
|
|
107
|
-
|
|
108
96
|
this.y = y;
|
|
109
97
|
this.page = saved.bottomMost.page;
|
|
110
98
|
this.availableWidth = saved.availableWidth;
|
|
111
99
|
this.availableHeight = saved.bottomMost.availableHeight;
|
|
112
|
-
|
|
113
100
|
if (height) {
|
|
114
101
|
this.availableHeight -= y - saved.bottomMost.y;
|
|
115
102
|
}
|
|
116
|
-
|
|
117
103
|
this.lastColumnWidth = saved.lastColumnWidth;
|
|
118
104
|
}
|
|
119
|
-
|
|
120
105
|
addMargin(left, right) {
|
|
121
106
|
this.x += left;
|
|
122
107
|
this.availableWidth -= left + (right || 0);
|
|
123
108
|
}
|
|
124
|
-
|
|
125
109
|
moveDown(offset) {
|
|
126
110
|
this.y += offset;
|
|
127
111
|
this.availableHeight -= offset;
|
|
128
112
|
return this.availableHeight > 0;
|
|
129
113
|
}
|
|
130
|
-
|
|
131
114
|
initializePage() {
|
|
132
115
|
this.y = this.pageMargins.top;
|
|
133
116
|
this.availableHeight = this.getCurrentPage().pageSize.height - this.pageMargins.top - this.pageMargins.bottom;
|
|
134
117
|
this.pageSnapshot().availableWidth = this.getCurrentPage().pageSize.width - this.pageMargins.left - this.pageMargins.right;
|
|
135
118
|
}
|
|
136
|
-
|
|
137
119
|
pageSnapshot() {
|
|
138
120
|
if (this.snapshots[0]) {
|
|
139
121
|
return this.snapshots[0];
|
|
@@ -141,29 +123,24 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
141
123
|
return this;
|
|
142
124
|
}
|
|
143
125
|
}
|
|
144
|
-
|
|
145
126
|
moveTo(x, y) {
|
|
146
127
|
if (x !== undefined && x !== null) {
|
|
147
128
|
this.x = x;
|
|
148
129
|
this.availableWidth = this.getCurrentPage().pageSize.width - this.x - this.pageMargins.right;
|
|
149
130
|
}
|
|
150
|
-
|
|
151
131
|
if (y !== undefined && y !== null) {
|
|
152
132
|
this.y = y;
|
|
153
133
|
this.availableHeight = this.getCurrentPage().pageSize.height - this.y - this.pageMargins.bottom;
|
|
154
134
|
}
|
|
155
135
|
}
|
|
156
|
-
|
|
157
136
|
moveToRelative(x, y) {
|
|
158
137
|
if (x !== undefined && x !== null) {
|
|
159
138
|
this.x = this.x + x;
|
|
160
139
|
}
|
|
161
|
-
|
|
162
140
|
if (y !== undefined && y !== null) {
|
|
163
141
|
this.y = this.y + y;
|
|
164
142
|
}
|
|
165
143
|
}
|
|
166
|
-
|
|
167
144
|
beginDetachedBlock() {
|
|
168
145
|
this.snapshots.push({
|
|
169
146
|
x: this.x,
|
|
@@ -175,7 +152,6 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
175
152
|
lastColumnWidth: this.lastColumnWidth
|
|
176
153
|
});
|
|
177
154
|
}
|
|
178
|
-
|
|
179
155
|
endDetachedBlock() {
|
|
180
156
|
let saved = this.snapshots.pop();
|
|
181
157
|
this.x = saved.x;
|
|
@@ -186,19 +162,16 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
186
162
|
this.endingCell = saved.endingCell;
|
|
187
163
|
this.lastColumnWidth = saved.lastColumnWidth;
|
|
188
164
|
}
|
|
189
|
-
|
|
190
165
|
moveToNextPage(pageOrientation) {
|
|
191
166
|
let nextPageIndex = this.page + 1;
|
|
192
167
|
let prevPage = this.page;
|
|
193
168
|
let prevY = this.y;
|
|
194
169
|
let createNewPage = nextPageIndex >= this.pages.length;
|
|
195
|
-
|
|
196
170
|
if (createNewPage) {
|
|
197
171
|
let currentAvailableWidth = this.availableWidth;
|
|
198
172
|
let currentPageOrientation = this.getCurrentPage().pageSize.orientation;
|
|
199
173
|
let pageSize = getPageSize(this.getCurrentPage(), pageOrientation);
|
|
200
174
|
this.addPage(pageSize);
|
|
201
|
-
|
|
202
175
|
if (currentPageOrientation === pageSize.orientation) {
|
|
203
176
|
this.availableWidth = currentAvailableWidth;
|
|
204
177
|
}
|
|
@@ -206,7 +179,6 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
206
179
|
this.page = nextPageIndex;
|
|
207
180
|
this.initializePage();
|
|
208
181
|
}
|
|
209
|
-
|
|
210
182
|
return {
|
|
211
183
|
newPageCreated: createNewPage,
|
|
212
184
|
prevPage: prevPage,
|
|
@@ -214,7 +186,6 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
214
186
|
y: this.y
|
|
215
187
|
};
|
|
216
188
|
}
|
|
217
|
-
|
|
218
189
|
addPage(pageSize) {
|
|
219
190
|
let page = {
|
|
220
191
|
items: [],
|
|
@@ -227,15 +198,12 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
227
198
|
this.emit('pageAdded');
|
|
228
199
|
return page;
|
|
229
200
|
}
|
|
230
|
-
|
|
231
201
|
getCurrentPage() {
|
|
232
202
|
if (this.page < 0 || this.page >= this.pages.length) {
|
|
233
203
|
return null;
|
|
234
204
|
}
|
|
235
|
-
|
|
236
205
|
return this.pages[this.page];
|
|
237
206
|
}
|
|
238
|
-
|
|
239
207
|
getCurrentPosition() {
|
|
240
208
|
let pageSize = this.getCurrentPage().pageSize;
|
|
241
209
|
let innerHeight = pageSize.height - this.pageMargins.top - this.pageMargins.bottom;
|
|
@@ -251,9 +219,7 @@ class DocumentContext extends _events.EventEmitter {
|
|
|
251
219
|
horizontalRatio: (this.x - this.pageMargins.left) / innerWidth
|
|
252
220
|
};
|
|
253
221
|
}
|
|
254
|
-
|
|
255
222
|
}
|
|
256
|
-
|
|
257
223
|
function pageOrientation(pageOrientationString, currentPageOrientation) {
|
|
258
224
|
if (pageOrientationString === undefined) {
|
|
259
225
|
return currentPageOrientation;
|
|
@@ -263,10 +229,8 @@ function pageOrientation(pageOrientationString, currentPageOrientation) {
|
|
|
263
229
|
return 'portrait';
|
|
264
230
|
}
|
|
265
231
|
}
|
|
266
|
-
|
|
267
232
|
const getPageSize = (currentPage, newPageOrientation) => {
|
|
268
233
|
newPageOrientation = pageOrientation(newPageOrientation, currentPage.pageSize.orientation);
|
|
269
|
-
|
|
270
234
|
if (newPageOrientation !== currentPage.pageSize.orientation) {
|
|
271
235
|
return {
|
|
272
236
|
orientation: newPageOrientation,
|
|
@@ -281,10 +245,8 @@ const getPageSize = (currentPage, newPageOrientation) => {
|
|
|
281
245
|
};
|
|
282
246
|
}
|
|
283
247
|
};
|
|
284
|
-
|
|
285
248
|
function bottomMostContext(c1, c2) {
|
|
286
249
|
let r;
|
|
287
|
-
|
|
288
250
|
if (c1.page > c2.page) {
|
|
289
251
|
r = c1;
|
|
290
252
|
} else if (c2.page > c1.page) {
|
|
@@ -292,7 +254,6 @@ function bottomMostContext(c1, c2) {
|
|
|
292
254
|
} else {
|
|
293
255
|
r = c1.y > c2.y ? c1 : c2;
|
|
294
256
|
}
|
|
295
|
-
|
|
296
257
|
return {
|
|
297
258
|
page: r.page,
|
|
298
259
|
x: r.x,
|
|
@@ -301,6 +262,5 @@ function bottomMostContext(c1, c2) {
|
|
|
301
262
|
availableWidth: r.availableWidth
|
|
302
263
|
};
|
|
303
264
|
}
|
|
304
|
-
|
|
305
265
|
var _default = DocumentContext;
|
|
306
266
|
exports.default = _default;
|