scrivito_pdf_widget 1.0.2 → 1.0.4
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/scrivito_pdf_widget.js +4 -0
- data/app/assets/javascripts/{pdf_widget → scrivito_pdf_widget}/application.js +3 -3
- data/app/assets/javascripts/{pdf_widget → scrivito_pdf_widget}/editing.js +3 -1
- data/app/assets/javascripts/{pdf_widget → scrivito_pdf_widget}/jquery.viewer.js +0 -0
- data/app/assets/javascripts/{pdf_widget → scrivito_pdf_widget}/pdf.js +1488 -193
- data/app/assets/javascripts/{pdf_widget → scrivito_pdf_widget}/pdf.worker.js +3184 -8165
- data/app/assets/javascripts/{pdf_widget → scrivito_pdf_widget}/widget.js.erb +1 -1
- data/app/assets/stylesheets/scrivito_pdf_widget.css +4 -0
- data/app/assets/stylesheets/{pdf_widget → scrivito_pdf_widget}/application.css +1 -1
- data/app/assets/stylesheets/{pdf_widget → scrivito_pdf_widget}/widget.css +0 -0
- data/app/models/pdf.rb +1 -1
- data/lib/scrivito_pdf_widget/engine.rb +6 -0
- data/lib/scrivito_pdf_widget/version.rb +1 -1
- metadata +14 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9978c3c80af00d2aae10f8f04dad11e76a258179
|
4
|
+
data.tar.gz: 783bcc8fefd36ffaebb595fe74463f3386dadb06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0e03bf0a575edbd0f796bc3a34741ecb23a4c79777dab1fd49da6a3146d63e82f6a3ccb9670942ea33643955d7d9b67f9fdca3d42d2fae4b9452bbc43e32f85
|
7
|
+
data.tar.gz: eeb699e2101a2882c868b5bfad848428db8bf9c250c04bf69be9b87a861e9428a02dca70552dcd032c7b3ab9536acc4e8593d37efebcdbb48e6a4004ff517363
|
@@ -10,6 +10,6 @@
|
|
10
10
|
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
11
|
// GO AFTER THE REQUIRES BELOW.
|
12
12
|
//
|
13
|
-
//= require
|
14
|
-
//= require
|
15
|
-
//= require
|
13
|
+
//= require ./pdf
|
14
|
+
//= require ./jquery.viewer
|
15
|
+
//= require ./widget
|
File without changes
|
@@ -15,14 +15,15 @@
|
|
15
15
|
* limitations under the License.
|
16
16
|
*/
|
17
17
|
/*jshint globalstrict: false */
|
18
|
+
/* globals PDFJS */
|
18
19
|
|
19
20
|
// Initializing PDFJS global object (if still undefined)
|
20
21
|
if (typeof PDFJS === 'undefined') {
|
21
22
|
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
22
23
|
}
|
23
24
|
|
24
|
-
PDFJS.version = '1.0.
|
25
|
-
PDFJS.build = '
|
25
|
+
PDFJS.version = '1.0.1040';
|
26
|
+
PDFJS.build = '997096f';
|
26
27
|
|
27
28
|
(function pdfjsWrapper() {
|
28
29
|
// Use strict in our context only - users might not want it
|
@@ -51,7 +52,7 @@ PDFJS.build = '1694cd8';
|
|
51
52
|
|
52
53
|
var globalScope = (typeof window === 'undefined') ? this : window;
|
53
54
|
|
54
|
-
var isWorker = (typeof window
|
55
|
+
var isWorker = (typeof window === 'undefined');
|
55
56
|
|
56
57
|
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
|
57
58
|
|
@@ -302,7 +303,7 @@ function combineUrl(baseUrl, url) {
|
|
302
303
|
return url;
|
303
304
|
}
|
304
305
|
var i;
|
305
|
-
if (url.charAt(0)
|
306
|
+
if (url.charAt(0) === '/') {
|
306
307
|
// absolute path
|
307
308
|
i = baseUrl.indexOf('://');
|
308
309
|
if (url.charAt(1) === '/') {
|
@@ -372,6 +373,7 @@ var PasswordException = (function PasswordExceptionClosure() {
|
|
372
373
|
|
373
374
|
return PasswordException;
|
374
375
|
})();
|
376
|
+
PDFJS.PasswordException = PasswordException;
|
375
377
|
|
376
378
|
var UnknownErrorException = (function UnknownErrorExceptionClosure() {
|
377
379
|
function UnknownErrorException(msg, details) {
|
@@ -385,6 +387,7 @@ var UnknownErrorException = (function UnknownErrorExceptionClosure() {
|
|
385
387
|
|
386
388
|
return UnknownErrorException;
|
387
389
|
})();
|
390
|
+
PDFJS.UnknownErrorException = UnknownErrorException;
|
388
391
|
|
389
392
|
var InvalidPDFException = (function InvalidPDFExceptionClosure() {
|
390
393
|
function InvalidPDFException(msg) {
|
@@ -397,6 +400,7 @@ var InvalidPDFException = (function InvalidPDFExceptionClosure() {
|
|
397
400
|
|
398
401
|
return InvalidPDFException;
|
399
402
|
})();
|
403
|
+
PDFJS.InvalidPDFException = InvalidPDFException;
|
400
404
|
|
401
405
|
var MissingPDFException = (function MissingPDFExceptionClosure() {
|
402
406
|
function MissingPDFException(msg) {
|
@@ -409,6 +413,22 @@ var MissingPDFException = (function MissingPDFExceptionClosure() {
|
|
409
413
|
|
410
414
|
return MissingPDFException;
|
411
415
|
})();
|
416
|
+
PDFJS.MissingPDFException = MissingPDFException;
|
417
|
+
|
418
|
+
var UnexpectedResponseException =
|
419
|
+
(function UnexpectedResponseExceptionClosure() {
|
420
|
+
function UnexpectedResponseException(msg, status) {
|
421
|
+
this.name = 'UnexpectedResponseException';
|
422
|
+
this.message = msg;
|
423
|
+
this.status = status;
|
424
|
+
}
|
425
|
+
|
426
|
+
UnexpectedResponseException.prototype = new Error();
|
427
|
+
UnexpectedResponseException.constructor = UnexpectedResponseException;
|
428
|
+
|
429
|
+
return UnexpectedResponseException;
|
430
|
+
})();
|
431
|
+
PDFJS.UnexpectedResponseException = UnexpectedResponseException;
|
412
432
|
|
413
433
|
var NotImplementedException = (function NotImplementedExceptionClosure() {
|
414
434
|
function NotImplementedException(msg) {
|
@@ -464,15 +484,6 @@ function bytesToString(bytes) {
|
|
464
484
|
return strBuf.join('');
|
465
485
|
}
|
466
486
|
|
467
|
-
function stringToArray(str) {
|
468
|
-
var length = str.length;
|
469
|
-
var array = [];
|
470
|
-
for (var i = 0; i < length; ++i) {
|
471
|
-
array[i] = str.charCodeAt(i);
|
472
|
-
}
|
473
|
-
return array;
|
474
|
-
}
|
475
|
-
|
476
487
|
function stringToBytes(str) {
|
477
488
|
var length = str.length;
|
478
489
|
var bytes = new Uint8Array(length);
|
@@ -590,10 +601,10 @@ var Util = PDFJS.Util = (function UtilClosure() {
|
|
590
601
|
|
591
602
|
// makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
|
592
603
|
// creating many intermediate strings.
|
593
|
-
Util.makeCssRgb = function Util_makeCssRgb(
|
594
|
-
rgbBuf[1] =
|
595
|
-
rgbBuf[3] =
|
596
|
-
rgbBuf[5] =
|
604
|
+
Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
|
605
|
+
rgbBuf[1] = r;
|
606
|
+
rgbBuf[3] = g;
|
607
|
+
rgbBuf[5] = b;
|
597
608
|
return rgbBuf.join('');
|
598
609
|
};
|
599
610
|
|
@@ -972,7 +983,7 @@ function isEmptyObj(obj) {
|
|
972
983
|
}
|
973
984
|
|
974
985
|
function isBool(v) {
|
975
|
-
return typeof v
|
986
|
+
return typeof v === 'boolean';
|
976
987
|
}
|
977
988
|
|
978
989
|
function isInt(v) {
|
@@ -1124,7 +1135,7 @@ PDFJS.createPromiseCapability = createPromiseCapability;
|
|
1124
1135
|
pendingRejectionCheck: false,
|
1125
1136
|
|
1126
1137
|
scheduleHandlers: function scheduleHandlers(promise) {
|
1127
|
-
if (promise._status
|
1138
|
+
if (promise._status === STATUS_PENDING) {
|
1128
1139
|
return;
|
1129
1140
|
}
|
1130
1141
|
|
@@ -1150,10 +1161,10 @@ PDFJS.createPromiseCapability = createPromiseCapability;
|
|
1150
1161
|
|
1151
1162
|
try {
|
1152
1163
|
if (nextStatus === STATUS_RESOLVED) {
|
1153
|
-
if (typeof
|
1164
|
+
if (typeof handler.onResolve === 'function') {
|
1154
1165
|
nextValue = handler.onResolve(nextValue);
|
1155
1166
|
}
|
1156
|
-
} else if (typeof
|
1167
|
+
} else if (typeof handler.onReject === 'function') {
|
1157
1168
|
nextValue = handler.onReject(nextValue);
|
1158
1169
|
nextStatus = STATUS_RESOLVED;
|
1159
1170
|
|
@@ -1320,7 +1331,7 @@ PDFJS.createPromiseCapability = createPromiseCapability;
|
|
1320
1331
|
return;
|
1321
1332
|
}
|
1322
1333
|
|
1323
|
-
if (status
|
1334
|
+
if (status === STATUS_RESOLVED &&
|
1324
1335
|
Promise.isPromise(value)) {
|
1325
1336
|
value.then(this._updateStatus.bind(this, STATUS_RESOLVED),
|
1326
1337
|
this._updateStatus.bind(this, STATUS_REJECTED));
|
@@ -1348,7 +1359,7 @@ PDFJS.createPromiseCapability = createPromiseCapability;
|
|
1348
1359
|
|
1349
1360
|
then: function Promise_then(onResolve, onReject) {
|
1350
1361
|
var nextPromise = new Promise(function (resolve, reject) {
|
1351
|
-
this.resolve =
|
1362
|
+
this.resolve = resolve;
|
1352
1363
|
this.reject = reject;
|
1353
1364
|
});
|
1354
1365
|
this._handlers.push({
|
@@ -1663,6 +1674,14 @@ PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
|
1663
1674
|
PDFJS.disableRange = (PDFJS.disableRange === undefined ?
|
1664
1675
|
false : PDFJS.disableRange);
|
1665
1676
|
|
1677
|
+
/**
|
1678
|
+
* Disable streaming of PDF file data. By default PDF.js attempts to load PDF
|
1679
|
+
* in chunks. This default behavior can be disabled.
|
1680
|
+
* @var {boolean}
|
1681
|
+
*/
|
1682
|
+
PDFJS.disableStream = (PDFJS.disableStream === undefined ?
|
1683
|
+
false : PDFJS.disableStream);
|
1684
|
+
|
1666
1685
|
/**
|
1667
1686
|
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
|
1668
1687
|
* will automatically keep fetching more data even if it isn't needed to display
|
@@ -1768,6 +1787,11 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
|
|
1768
1787
|
* parameters: function that needs to be called with new password and reason
|
1769
1788
|
* (see {PasswordResponses}).
|
1770
1789
|
*
|
1790
|
+
* @param {function} progressCallback is optional. It is used to be able to
|
1791
|
+
* monitor the loading progress of the PDF file (necessary to implement e.g.
|
1792
|
+
* a loading bar). The callback receives an {Object} with the properties:
|
1793
|
+
* {number} loaded and {number} total.
|
1794
|
+
*
|
1771
1795
|
* @return {Promise} A promise that is resolved with {@link PDFDocumentProxy}
|
1772
1796
|
* object.
|
1773
1797
|
*/
|
@@ -1856,10 +1880,20 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
|
1856
1880
|
/**
|
1857
1881
|
* @return {Promise} A promise that is resolved with a lookup table for
|
1858
1882
|
* mapping named destinations to reference numbers.
|
1883
|
+
*
|
1884
|
+
* This can be slow for large documents: use getDestination instead
|
1859
1885
|
*/
|
1860
1886
|
getDestinations: function PDFDocumentProxy_getDestinations() {
|
1861
1887
|
return this.transport.getDestinations();
|
1862
1888
|
},
|
1889
|
+
/**
|
1890
|
+
* @param {string} id The named destination to get.
|
1891
|
+
* @return {Promise} A promise that is resolved with all information
|
1892
|
+
* of the given named destination.
|
1893
|
+
*/
|
1894
|
+
getDestination: function PDFDocumentProxy_getDestination(id) {
|
1895
|
+
return this.transport.getDestination(id);
|
1896
|
+
},
|
1863
1897
|
/**
|
1864
1898
|
* @return {Promise} A promise that is resolved with a lookup table for
|
1865
1899
|
* mapping named attachments to their content.
|
@@ -2080,8 +2114,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|
2080
2114
|
// this call to render.
|
2081
2115
|
this.pendingDestroy = false;
|
2082
2116
|
|
2083
|
-
var renderingIntent = (
|
2084
|
-
(params.intent == 'print' ? 'print' : 'display') : 'display');
|
2117
|
+
var renderingIntent = (params.intent === 'print' ? 'print' : 'display');
|
2085
2118
|
|
2086
2119
|
if (!this.intentStates[renderingIntent]) {
|
2087
2120
|
this.intentStates[renderingIntent] = {};
|
@@ -2414,6 +2447,12 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|
2414
2447
|
});
|
2415
2448
|
});
|
2416
2449
|
|
2450
|
+
pdfDataRangeTransport.addProgressiveReadListener(function(chunk) {
|
2451
|
+
messageHandler.send('OnDataRange', {
|
2452
|
+
chunk: chunk
|
2453
|
+
});
|
2454
|
+
});
|
2455
|
+
|
2417
2456
|
messageHandler.on('RequestDataRange',
|
2418
2457
|
function transportDataRange(data) {
|
2419
2458
|
pdfDataRangeTransport.requestDataRange(data.begin, data.end);
|
@@ -2428,42 +2467,58 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|
2428
2467
|
this.workerReadyCapability.resolve(pdfDocument);
|
2429
2468
|
}, this);
|
2430
2469
|
|
2431
|
-
messageHandler.on('NeedPassword',
|
2470
|
+
messageHandler.on('NeedPassword',
|
2471
|
+
function transportNeedPassword(exception) {
|
2432
2472
|
if (this.passwordCallback) {
|
2433
2473
|
return this.passwordCallback(updatePassword,
|
2434
2474
|
PasswordResponses.NEED_PASSWORD);
|
2435
2475
|
}
|
2436
|
-
this.workerReadyCapability.reject(
|
2437
|
-
|
2476
|
+
this.workerReadyCapability.reject(
|
2477
|
+
new PasswordException(exception.message, exception.code));
|
2438
2478
|
}, this);
|
2439
2479
|
|
2440
|
-
messageHandler.on('IncorrectPassword',
|
2480
|
+
messageHandler.on('IncorrectPassword',
|
2481
|
+
function transportIncorrectPassword(exception) {
|
2441
2482
|
if (this.passwordCallback) {
|
2442
2483
|
return this.passwordCallback(updatePassword,
|
2443
2484
|
PasswordResponses.INCORRECT_PASSWORD);
|
2444
2485
|
}
|
2445
|
-
this.workerReadyCapability.reject(
|
2446
|
-
|
2486
|
+
this.workerReadyCapability.reject(
|
2487
|
+
new PasswordException(exception.message, exception.code));
|
2488
|
+
}, this);
|
2489
|
+
|
2490
|
+
messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
|
2491
|
+
this.workerReadyCapability.reject(
|
2492
|
+
new InvalidPDFException(exception.message));
|
2447
2493
|
}, this);
|
2448
2494
|
|
2449
|
-
messageHandler.on('
|
2450
|
-
this.workerReadyCapability.reject(
|
2495
|
+
messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
|
2496
|
+
this.workerReadyCapability.reject(
|
2497
|
+
new MissingPDFException(exception.message));
|
2451
2498
|
}, this);
|
2452
2499
|
|
2453
|
-
messageHandler.on('
|
2454
|
-
|
2455
|
-
|
2500
|
+
messageHandler.on('UnexpectedResponse',
|
2501
|
+
function transportUnexpectedResponse(exception) {
|
2502
|
+
this.workerReadyCapability.reject(
|
2503
|
+
new UnexpectedResponseException(exception.message, exception.status));
|
2456
2504
|
}, this);
|
2457
2505
|
|
2458
|
-
messageHandler.on('UnknownError',
|
2459
|
-
|
2460
|
-
|
2506
|
+
messageHandler.on('UnknownError',
|
2507
|
+
function transportUnknownError(exception) {
|
2508
|
+
this.workerReadyCapability.reject(
|
2509
|
+
new UnknownErrorException(exception.message, exception.details));
|
2461
2510
|
}, this);
|
2462
2511
|
|
2463
2512
|
messageHandler.on('DataLoaded', function transportPage(data) {
|
2464
2513
|
this.downloadInfoCapability.resolve(data);
|
2465
2514
|
}, this);
|
2466
2515
|
|
2516
|
+
messageHandler.on('PDFManagerReady', function transportPage(data) {
|
2517
|
+
if (this.pdfDataRangeTransport) {
|
2518
|
+
this.pdfDataRangeTransport.transportReady();
|
2519
|
+
}
|
2520
|
+
}, this);
|
2521
|
+
|
2467
2522
|
messageHandler.on('StartRenderPage', function transportRender(data) {
|
2468
2523
|
var page = this.pageCache[data.pageIndex];
|
2469
2524
|
|
@@ -2495,7 +2550,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|
2495
2550
|
this.commonObjs.resolve(id, error);
|
2496
2551
|
break;
|
2497
2552
|
} else {
|
2498
|
-
font = new
|
2553
|
+
font = new FontFaceObject(exportedData);
|
2499
2554
|
}
|
2500
2555
|
|
2501
2556
|
FontLoader.bind(
|
@@ -2553,14 +2608,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|
2553
2608
|
}
|
2554
2609
|
}, this);
|
2555
2610
|
|
2556
|
-
messageHandler.on('DocError', function transportDocError(data) {
|
2557
|
-
this.workerReadyCapability.reject(data);
|
2558
|
-
}, this);
|
2559
|
-
|
2560
2611
|
messageHandler.on('PageError', function transportError(data) {
|
2561
2612
|
var page = this.pageCache[data.pageNum - 1];
|
2562
2613
|
var intentState = page.intentStates[data.intent];
|
2563
|
-
if (intentState.displayReadyCapability
|
2614
|
+
if (intentState.displayReadyCapability) {
|
2564
2615
|
intentState.displayReadyCapability.reject(data.error);
|
2565
2616
|
} else {
|
2566
2617
|
error(data.error);
|
@@ -2570,7 +2621,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|
2570
2621
|
messageHandler.on('JpegDecode', function(data) {
|
2571
2622
|
var imageUrl = data[0];
|
2572
2623
|
var components = data[1];
|
2573
|
-
if (components
|
2624
|
+
if (components !== 3 && components !== 1) {
|
2574
2625
|
return Promise.reject(
|
2575
2626
|
new Error('Only 3 components or 1 component can be returned'));
|
2576
2627
|
}
|
@@ -2589,13 +2640,13 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|
2589
2640
|
var data = tmpCtx.getImageData(0, 0, width, height).data;
|
2590
2641
|
var i, j;
|
2591
2642
|
|
2592
|
-
if (components
|
2643
|
+
if (components === 3) {
|
2593
2644
|
for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
|
2594
2645
|
buf[j] = data[i];
|
2595
2646
|
buf[j + 1] = data[i + 1];
|
2596
2647
|
buf[j + 2] = data[i + 2];
|
2597
2648
|
}
|
2598
|
-
} else if (components
|
2649
|
+
} else if (components === 1) {
|
2599
2650
|
for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
|
2600
2651
|
buf[j] = data[i];
|
2601
2652
|
}
|
@@ -2612,6 +2663,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|
2612
2663
|
|
2613
2664
|
fetchDocument: function WorkerTransport_fetchDocument(source) {
|
2614
2665
|
source.disableAutoFetch = PDFJS.disableAutoFetch;
|
2666
|
+
source.disableStream = PDFJS.disableStream;
|
2615
2667
|
source.chunkedViewerLoading = !!this.pdfDataRangeTransport;
|
2616
2668
|
this.messageHandler.send('GetDocRequest', {
|
2617
2669
|
source: source,
|
@@ -2663,6 +2715,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|
2663
2715
|
return this.messageHandler.sendWithPromise('GetDestinations', null);
|
2664
2716
|
},
|
2665
2717
|
|
2718
|
+
getDestination: function WorkerTransport_getDestination(id) {
|
2719
|
+
return this.messageHandler.sendWithPromise('GetDestination', { id: id } );
|
2720
|
+
},
|
2721
|
+
|
2666
2722
|
getAttachments: function WorkerTransport_getAttachments() {
|
2667
2723
|
return this.messageHandler.sendWithPromise('GetAttachments', null);
|
2668
2724
|
},
|
@@ -2979,8 +3035,8 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
|
|
2979
3035
|
var chars = '';
|
2980
3036
|
for (var i = 0; i < bytes.length; i += 2) {
|
2981
3037
|
var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
|
2982
|
-
chars += code >= 32 && code < 127 && code
|
2983
|
-
code
|
3038
|
+
chars += code >= 32 && code < 127 && code !== 60 && code !== 62 &&
|
3039
|
+
code !== 38 && false ? String.fromCharCode(code) :
|
2984
3040
|
'&#x' + (0x10000 + code).toString(16).substring(1) + ';';
|
2985
3041
|
}
|
2986
3042
|
return '>' + chars;
|
@@ -3055,9 +3111,17 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
|
|
3055
3111
|
|
3056
3112
|
// Minimal font size that would be used during canvas fillText operations.
|
3057
3113
|
var MIN_FONT_SIZE = 16;
|
3114
|
+
// Maximum font size that would be used during canvas fillText operations.
|
3115
|
+
var MAX_FONT_SIZE = 100;
|
3058
3116
|
var MAX_GROUP_SIZE = 4096;
|
3059
3117
|
|
3118
|
+
// Heuristic value used when enforcing minimum line widths.
|
3119
|
+
var MIN_WIDTH_FACTOR = 0.65;
|
3120
|
+
|
3060
3121
|
var COMPILE_TYPE3_GLYPHS = true;
|
3122
|
+
var MAX_SIZE_TO_COMPILE = 1000;
|
3123
|
+
|
3124
|
+
var FULL_CHUNK_HEIGHT = 16;
|
3061
3125
|
|
3062
3126
|
function createScratchCanvas(width, height) {
|
3063
3127
|
var canvas = document.createElement('canvas');
|
@@ -3191,7 +3255,7 @@ var CachedCanvases = (function CachedCanvasesClosure() {
|
|
3191
3255
|
getCanvas: function CachedCanvases_getCanvas(id, width, height,
|
3192
3256
|
trackTransform) {
|
3193
3257
|
var canvasEntry;
|
3194
|
-
if (id
|
3258
|
+
if (cache[id] !== undefined) {
|
3195
3259
|
canvasEntry = cache[id];
|
3196
3260
|
canvasEntry.canvas.width = width;
|
3197
3261
|
canvasEntry.canvas.height = height;
|
@@ -3405,6 +3469,7 @@ var CanvasExtraState = (function CanvasExtraStateClosure() {
|
|
3405
3469
|
// Default fore and background colors
|
3406
3470
|
this.fillColor = '#000000';
|
3407
3471
|
this.strokeColor = '#000000';
|
3472
|
+
this.patternFill = false;
|
3408
3473
|
// Note: fill alpha applies to all non-stroking operations
|
3409
3474
|
this.fillAlpha = 1;
|
3410
3475
|
this.strokeAlpha = 1;
|
@@ -3457,6 +3522,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3457
3522
|
if (canvasCtx) {
|
3458
3523
|
addContextCurrentTransform(canvasCtx);
|
3459
3524
|
}
|
3525
|
+
this.cachedGetSinglePixelWidth = null;
|
3460
3526
|
}
|
3461
3527
|
|
3462
3528
|
function putBinaryImageData(ctx, imgData) {
|
@@ -3477,13 +3543,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3477
3543
|
// that's ok; any such pixels are ignored.
|
3478
3544
|
|
3479
3545
|
var height = imgData.height, width = imgData.width;
|
3480
|
-
var
|
3481
|
-
var
|
3482
|
-
var
|
3483
|
-
var totalChunks = Math.ceil(fracChunks);
|
3484
|
-
var partialChunkHeight = height - fullChunks * fullChunkHeight;
|
3546
|
+
var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
|
3547
|
+
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
|
3548
|
+
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
|
3485
3549
|
|
3486
|
-
var chunkImgData = ctx.createImageData(width,
|
3550
|
+
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
|
3487
3551
|
var srcPos = 0, destPos;
|
3488
3552
|
var src = imgData.data;
|
3489
3553
|
var dest = chunkImgData.data;
|
@@ -3503,7 +3567,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3503
3567
|
0xFF000000 : 0x000000FF;
|
3504
3568
|
for (i = 0; i < totalChunks; i++) {
|
3505
3569
|
thisChunkHeight =
|
3506
|
-
(i < fullChunks) ?
|
3570
|
+
(i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
3507
3571
|
destPos = 0;
|
3508
3572
|
for (j = 0; j < thisChunkHeight; j++) {
|
3509
3573
|
var srcDiff = srcLength - srcPos;
|
@@ -3538,19 +3602,19 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3538
3602
|
dest32[destPos++] = 0;
|
3539
3603
|
}
|
3540
3604
|
|
3541
|
-
ctx.putImageData(chunkImgData, 0, i *
|
3605
|
+
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
3542
3606
|
}
|
3543
3607
|
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
|
3544
3608
|
// RGBA, 32-bits per pixel.
|
3545
3609
|
|
3546
3610
|
j = 0;
|
3547
|
-
elemsInThisChunk = width *
|
3611
|
+
elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
|
3548
3612
|
for (i = 0; i < fullChunks; i++) {
|
3549
3613
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
3550
3614
|
srcPos += elemsInThisChunk;
|
3551
3615
|
|
3552
3616
|
ctx.putImageData(chunkImgData, 0, j);
|
3553
|
-
j +=
|
3617
|
+
j += FULL_CHUNK_HEIGHT;
|
3554
3618
|
}
|
3555
3619
|
if (i < totalChunks) {
|
3556
3620
|
elemsInThisChunk = width * partialChunkHeight * 4;
|
@@ -3560,11 +3624,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3560
3624
|
|
3561
3625
|
} else if (imgData.kind === ImageKind.RGB_24BPP) {
|
3562
3626
|
// RGB, 24-bits per pixel.
|
3563
|
-
thisChunkHeight =
|
3627
|
+
thisChunkHeight = FULL_CHUNK_HEIGHT;
|
3564
3628
|
elemsInThisChunk = width * thisChunkHeight;
|
3565
3629
|
for (i = 0; i < totalChunks; i++) {
|
3566
3630
|
if (i >= fullChunks) {
|
3567
|
-
thisChunkHeight =partialChunkHeight;
|
3631
|
+
thisChunkHeight = partialChunkHeight;
|
3568
3632
|
elemsInThisChunk = width * thisChunkHeight;
|
3569
3633
|
}
|
3570
3634
|
|
@@ -3575,7 +3639,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3575
3639
|
dest[destPos++] = src[srcPos++];
|
3576
3640
|
dest[destPos++] = 255;
|
3577
3641
|
}
|
3578
|
-
ctx.putImageData(chunkImgData, 0, i *
|
3642
|
+
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
3579
3643
|
}
|
3580
3644
|
} else {
|
3581
3645
|
error('bad image kind: ' + imgData.kind);
|
@@ -3584,20 +3648,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3584
3648
|
|
3585
3649
|
function putBinaryImageMask(ctx, imgData) {
|
3586
3650
|
var height = imgData.height, width = imgData.width;
|
3587
|
-
var
|
3588
|
-
var
|
3589
|
-
var
|
3590
|
-
var totalChunks = Math.ceil(fracChunks);
|
3591
|
-
var partialChunkHeight = height - fullChunks * fullChunkHeight;
|
3651
|
+
var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
|
3652
|
+
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
|
3653
|
+
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
|
3592
3654
|
|
3593
|
-
var chunkImgData = ctx.createImageData(width,
|
3655
|
+
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
|
3594
3656
|
var srcPos = 0;
|
3595
3657
|
var src = imgData.data;
|
3596
3658
|
var dest = chunkImgData.data;
|
3597
3659
|
|
3598
3660
|
for (var i = 0; i < totalChunks; i++) {
|
3599
3661
|
var thisChunkHeight =
|
3600
|
-
(i < fullChunks) ?
|
3662
|
+
(i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
3601
3663
|
|
3602
3664
|
// Expand the mask so it can be used by the canvas. Any required
|
3603
3665
|
// inversion has already been handled.
|
@@ -3614,7 +3676,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3614
3676
|
mask >>= 1;
|
3615
3677
|
}
|
3616
3678
|
}
|
3617
|
-
ctx.putImageData(chunkImgData, 0, i *
|
3679
|
+
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
3618
3680
|
}
|
3619
3681
|
}
|
3620
3682
|
|
@@ -3624,14 +3686,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3624
3686
|
'globalCompositeOperation', 'font'];
|
3625
3687
|
for (var i = 0, ii = properties.length; i < ii; i++) {
|
3626
3688
|
var property = properties[i];
|
3627
|
-
if (property
|
3689
|
+
if (sourceCtx[property] !== undefined) {
|
3628
3690
|
destCtx[property] = sourceCtx[property];
|
3629
3691
|
}
|
3630
3692
|
}
|
3631
|
-
if (
|
3693
|
+
if (sourceCtx.setLineDash !== undefined) {
|
3632
3694
|
destCtx.setLineDash(sourceCtx.getLineDash());
|
3633
3695
|
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
|
3634
|
-
} else if (
|
3696
|
+
} else if (sourceCtx.mozDashOffset !== undefined) {
|
3635
3697
|
destCtx.mozDash = sourceCtx.mozDash;
|
3636
3698
|
destCtx.mozDashOffset = sourceCtx.mozDashOffset;
|
3637
3699
|
}
|
@@ -3666,9 +3728,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3666
3728
|
function composeSMaskLuminosity(maskData, layerData) {
|
3667
3729
|
var length = maskData.length;
|
3668
3730
|
for (var i = 3; i < length; i += 4) {
|
3669
|
-
var y = (
|
3670
|
-
|
3671
|
-
|
3731
|
+
var y = (maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000
|
3732
|
+
(maskData[i - 2] * 152) + // * 0.59 ....
|
3733
|
+
(maskData[i - 1] * 28); // * 0.11 ....
|
3672
3734
|
layerData[i] = (layerData[i] * y) >> 16;
|
3673
3735
|
}
|
3674
3736
|
}
|
@@ -3688,7 +3750,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3688
3750
|
}
|
3689
3751
|
|
3690
3752
|
// processing image in chunks to save memory
|
3691
|
-
var PIXELS_TO_PROCESS =
|
3753
|
+
var PIXELS_TO_PROCESS = 1048576;
|
3692
3754
|
var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
|
3693
3755
|
for (var row = 0; row < height; row += chunkSize) {
|
3694
3756
|
var chunkHeight = Math.min(chunkSize, height - row);
|
@@ -3858,7 +3920,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3858
3920
|
},
|
3859
3921
|
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
|
3860
3922
|
var ctx = this.ctx;
|
3861
|
-
if (
|
3923
|
+
if (ctx.setLineDash !== undefined) {
|
3862
3924
|
ctx.setLineDash(dashArray);
|
3863
3925
|
ctx.lineDashOffset = dashPhase;
|
3864
3926
|
} else {
|
@@ -3993,10 +4055,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
3993
4055
|
|
3994
4056
|
this.current = this.stateStack.pop();
|
3995
4057
|
this.ctx.restore();
|
4058
|
+
|
4059
|
+
this.cachedGetSinglePixelWidth = null;
|
3996
4060
|
}
|
3997
4061
|
},
|
3998
4062
|
transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
|
3999
4063
|
this.ctx.transform(a, b, c, d, e, f);
|
4064
|
+
|
4065
|
+
this.cachedGetSinglePixelWidth = null;
|
4000
4066
|
},
|
4001
4067
|
|
4002
4068
|
// Path
|
@@ -4070,9 +4136,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4070
4136
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
4071
4137
|
var ctx = this.ctx;
|
4072
4138
|
var strokeColor = this.current.strokeColor;
|
4073
|
-
|
4074
|
-
|
4075
|
-
|
4139
|
+
// Prevent drawing too thin lines by enforcing a minimum line width.
|
4140
|
+
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR,
|
4141
|
+
this.current.lineWidth);
|
4076
4142
|
// For stroke we want to temporarily change the global alpha to the
|
4077
4143
|
// stroking alpha.
|
4078
4144
|
ctx.globalAlpha = this.current.strokeAlpha;
|
@@ -4101,10 +4167,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4101
4167
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
4102
4168
|
var ctx = this.ctx;
|
4103
4169
|
var fillColor = this.current.fillColor;
|
4170
|
+
var isPatternFill = this.current.patternFill;
|
4104
4171
|
var needRestore = false;
|
4105
4172
|
|
4106
|
-
if (
|
4107
|
-
fillColor.type === 'Pattern') {
|
4173
|
+
if (isPatternFill) {
|
4108
4174
|
ctx.save();
|
4109
4175
|
ctx.fillStyle = fillColor.getPattern(ctx, this);
|
4110
4176
|
needRestore = true;
|
@@ -4255,9 +4321,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4255
4321
|
// Keeping the font at minimal size and using the fontSizeScale to change
|
4256
4322
|
// the current transformation matrix before the fillText/strokeText.
|
4257
4323
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
|
4258
|
-
var browserFontSize = size
|
4259
|
-
|
4260
|
-
|
4324
|
+
var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE :
|
4325
|
+
size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
|
4326
|
+
this.current.fontSizeScale = size / browserFontSize;
|
4261
4327
|
|
4262
4328
|
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
|
4263
4329
|
this.ctx.font = rule;
|
@@ -4397,12 +4463,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4397
4463
|
var lineWidth = current.lineWidth;
|
4398
4464
|
var scale = current.textMatrixScale;
|
4399
4465
|
if (scale === 0 || lineWidth === 0) {
|
4400
|
-
|
4466
|
+
var fillStrokeMode = current.textRenderingMode &
|
4467
|
+
TextRenderingMode.FILL_STROKE_MASK;
|
4468
|
+
if (fillStrokeMode === TextRenderingMode.STROKE ||
|
4469
|
+
fillStrokeMode === TextRenderingMode.FILL_STROKE) {
|
4470
|
+
this.cachedGetSinglePixelWidth = null;
|
4471
|
+
lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
|
4472
|
+
}
|
4401
4473
|
} else {
|
4402
4474
|
lineWidth /= scale;
|
4403
4475
|
}
|
4404
4476
|
|
4405
|
-
if (fontSizeScale
|
4477
|
+
if (fontSizeScale !== 1.0) {
|
4406
4478
|
ctx.scale(fontSizeScale, fontSizeScale);
|
4407
4479
|
lineWidth /= fontSizeScale;
|
4408
4480
|
}
|
@@ -4492,9 +4564,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4492
4564
|
var textHScale = current.textHScale * fontDirection;
|
4493
4565
|
var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
|
4494
4566
|
var glyphsLength = glyphs.length;
|
4567
|
+
var isTextInvisible =
|
4568
|
+
current.textRenderingMode === TextRenderingMode.INVISIBLE;
|
4495
4569
|
var i, glyph, width;
|
4496
4570
|
|
4497
|
-
if (fontSize === 0) {
|
4571
|
+
if (isTextInvisible || fontSize === 0) {
|
4498
4572
|
return;
|
4499
4573
|
}
|
4500
4574
|
|
@@ -4502,7 +4576,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4502
4576
|
ctx.transform.apply(ctx, current.textMatrix);
|
4503
4577
|
ctx.translate(current.x, current.y);
|
4504
4578
|
|
4505
|
-
ctx.scale(textHScale,
|
4579
|
+
ctx.scale(textHScale, fontDirection);
|
4506
4580
|
|
4507
4581
|
for (i = 0; i < glyphsLength; ++i) {
|
4508
4582
|
glyph = glyphs[i];
|
@@ -4518,16 +4592,21 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4518
4592
|
continue;
|
4519
4593
|
}
|
4520
4594
|
|
4595
|
+
var operatorList = font.charProcOperatorList[glyph.operatorListId];
|
4596
|
+
if (!operatorList) {
|
4597
|
+
warn('Type3 character \"' + glyph.operatorListId +
|
4598
|
+
'\" is not available');
|
4599
|
+
continue;
|
4600
|
+
}
|
4521
4601
|
this.processingType3 = glyph;
|
4522
4602
|
this.save();
|
4523
4603
|
ctx.scale(fontSize, fontSize);
|
4524
4604
|
ctx.transform.apply(ctx, fontMatrix);
|
4525
|
-
var operatorList = font.charProcOperatorList[glyph.operatorListId];
|
4526
4605
|
this.executeOperatorList(operatorList);
|
4527
4606
|
this.restore();
|
4528
4607
|
|
4529
4608
|
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
4530
|
-
width =
|
4609
|
+
width = transformed[0] * fontSize + charSpacing;
|
4531
4610
|
|
4532
4611
|
ctx.translate(width, 0);
|
4533
4612
|
current.x += width * textHScale;
|
@@ -4571,16 +4650,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4571
4650
|
},
|
4572
4651
|
setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) {
|
4573
4652
|
this.current.fillColor = this.getColorN_Pattern(arguments);
|
4653
|
+
this.current.patternFill = true;
|
4574
4654
|
},
|
4575
4655
|
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
|
4576
|
-
var color = Util.makeCssRgb(
|
4656
|
+
var color = Util.makeCssRgb(r, g, b);
|
4577
4657
|
this.ctx.strokeStyle = color;
|
4578
4658
|
this.current.strokeColor = color;
|
4579
4659
|
},
|
4580
4660
|
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
|
4581
|
-
var color = Util.makeCssRgb(
|
4661
|
+
var color = Util.makeCssRgb(r, g, b);
|
4582
4662
|
this.ctx.fillStyle = color;
|
4583
4663
|
this.current.fillColor = color;
|
4664
|
+
this.current.patternFill = false;
|
4584
4665
|
},
|
4585
4666
|
|
4586
4667
|
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
|
@@ -4839,11 +4920,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4839
4920
|
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
|
4840
4921
|
var ctx = this.ctx;
|
4841
4922
|
var width = img.width, height = img.height;
|
4923
|
+
var fillColor = this.current.fillColor;
|
4924
|
+
var isPatternFill = this.current.patternFill;
|
4842
4925
|
|
4843
4926
|
var glyph = this.processingType3;
|
4844
4927
|
|
4845
|
-
if (COMPILE_TYPE3_GLYPHS && glyph &&
|
4846
|
-
var MAX_SIZE_TO_COMPILE = 1000;
|
4928
|
+
if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
|
4847
4929
|
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
|
4848
4930
|
glyph.compiled =
|
4849
4931
|
compileType3Glyph({data: img.data, width: width, height: height});
|
@@ -4865,9 +4947,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4865
4947
|
|
4866
4948
|
maskCtx.globalCompositeOperation = 'source-in';
|
4867
4949
|
|
4868
|
-
|
4869
|
-
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
|
4870
|
-
fillColor.type === 'Pattern') ?
|
4950
|
+
maskCtx.fillStyle = isPatternFill ?
|
4871
4951
|
fillColor.getPattern(maskCtx, this) : fillColor;
|
4872
4952
|
maskCtx.fillRect(0, 0, width, height);
|
4873
4953
|
|
@@ -4881,7 +4961,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4881
4961
|
scaleY, positions) {
|
4882
4962
|
var width = imgData.width;
|
4883
4963
|
var height = imgData.height;
|
4884
|
-
var
|
4964
|
+
var fillColor = this.current.fillColor;
|
4965
|
+
var isPatternFill = this.current.patternFill;
|
4885
4966
|
|
4886
4967
|
var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height);
|
4887
4968
|
var maskCtx = maskCanvas.context;
|
@@ -4891,14 +4972,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4891
4972
|
|
4892
4973
|
maskCtx.globalCompositeOperation = 'source-in';
|
4893
4974
|
|
4894
|
-
|
4895
|
-
|
4896
|
-
fillColor.type === 'Pattern') ?
|
4897
|
-
fillColor.getPattern(maskCtx, this) : fillColor;
|
4975
|
+
maskCtx.fillStyle = isPatternFill ?
|
4976
|
+
fillColor.getPattern(maskCtx, this) : fillColor;
|
4898
4977
|
maskCtx.fillRect(0, 0, width, height);
|
4899
4978
|
|
4900
4979
|
maskCtx.restore();
|
4901
4980
|
|
4981
|
+
var ctx = this.ctx;
|
4902
4982
|
for (var i = 0, ii = positions.length; i < ii; i += 2) {
|
4903
4983
|
ctx.save();
|
4904
4984
|
ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
|
@@ -4913,6 +4993,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4913
4993
|
function CanvasGraphics_paintImageMaskXObjectGroup(images) {
|
4914
4994
|
var ctx = this.ctx;
|
4915
4995
|
|
4996
|
+
var fillColor = this.current.fillColor;
|
4997
|
+
var isPatternFill = this.current.patternFill;
|
4916
4998
|
for (var i = 0, ii = images.length; i < ii; i++) {
|
4917
4999
|
var image = images[i];
|
4918
5000
|
var width = image.width, height = image.height;
|
@@ -4925,9 +5007,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
4925
5007
|
|
4926
5008
|
maskCtx.globalCompositeOperation = 'source-in';
|
4927
5009
|
|
4928
|
-
|
4929
|
-
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
|
4930
|
-
fillColor.type === 'Pattern') ?
|
5010
|
+
maskCtx.fillStyle = isPatternFill ?
|
4931
5011
|
fillColor.getPattern(maskCtx, this) : fillColor;
|
4932
5012
|
maskCtx.fillRect(0, 0, width, height);
|
4933
5013
|
|
@@ -5130,11 +5210,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
5130
5210
|
ctx.beginPath();
|
5131
5211
|
},
|
5132
5212
|
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5137
|
-
|
5213
|
+
if (this.cachedGetSinglePixelWidth === null) {
|
5214
|
+
var inverse = this.ctx.mozCurrentTransformInverse;
|
5215
|
+
// max of the current horizontal and vertical scale
|
5216
|
+
this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(
|
5217
|
+
(inverse[0] * inverse[0] + inverse[1] * inverse[1]),
|
5218
|
+
(inverse[2] * inverse[2] + inverse[3] * inverse[3])));
|
5219
|
+
}
|
5220
|
+
return this.cachedGetSinglePixelWidth;
|
5138
5221
|
},
|
5139
5222
|
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
|
5140
5223
|
var transform = this.ctx.mozCurrentTransform;
|
@@ -5202,7 +5285,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|
5202
5285
|
}
|
5203
5286
|
|
5204
5287
|
var currentGL, currentCanvas;
|
5205
|
-
function
|
5288
|
+
function generateGL() {
|
5206
5289
|
if (currentGL) {
|
5207
5290
|
return;
|
5208
5291
|
}
|
@@ -5260,7 +5343,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|
5260
5343
|
function initSmaskGL() {
|
5261
5344
|
var canvas, gl;
|
5262
5345
|
|
5263
|
-
|
5346
|
+
generateGL();
|
5264
5347
|
canvas = currentCanvas;
|
5265
5348
|
currentCanvas = null;
|
5266
5349
|
gl = currentGL;
|
@@ -5392,7 +5475,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|
5392
5475
|
function initFiguresGL() {
|
5393
5476
|
var canvas, gl;
|
5394
5477
|
|
5395
|
-
|
5478
|
+
generateGL();
|
5396
5479
|
canvas = currentCanvas;
|
5397
5480
|
currentCanvas = null;
|
5398
5481
|
gl = currentGL;
|
@@ -5560,7 +5643,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|
5560
5643
|
}
|
5561
5644
|
var enabled = false;
|
5562
5645
|
try {
|
5563
|
-
|
5646
|
+
generateGL();
|
5564
5647
|
enabled = !!currentGL;
|
5565
5648
|
} catch (e) { }
|
5566
5649
|
return shadow(this, 'isEnabled', enabled);
|
@@ -5935,7 +6018,7 @@ var TilingPattern = (function TilingPatternClosure() {
|
|
5935
6018
|
},
|
5936
6019
|
|
5937
6020
|
clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
|
5938
|
-
if (bbox && isArray(bbox) &&
|
6021
|
+
if (bbox && isArray(bbox) && bbox.length === 4) {
|
5939
6022
|
var bboxWidth = x1 - x0;
|
5940
6023
|
var bboxHeight = y1 - y0;
|
5941
6024
|
graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
|
@@ -5953,7 +6036,7 @@ var TilingPattern = (function TilingPatternClosure() {
|
|
5953
6036
|
context.strokeStyle = ctx.strokeStyle;
|
5954
6037
|
break;
|
5955
6038
|
case PaintType.UNCOLORED:
|
5956
|
-
var cssColor = Util.makeCssRgb(color);
|
6039
|
+
var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
|
5957
6040
|
context.fillStyle = cssColor;
|
5958
6041
|
context.strokeStyle = cssColor;
|
5959
6042
|
break;
|
@@ -5999,6 +6082,10 @@ var FontLoader = {
|
|
5999
6082
|
if (styleElement) {
|
6000
6083
|
styleElement.parentNode.removeChild(styleElement);
|
6001
6084
|
}
|
6085
|
+
this.nativeFontFaces.forEach(function(nativeFontFace) {
|
6086
|
+
document.fonts.delete(nativeFontFace);
|
6087
|
+
});
|
6088
|
+
this.nativeFontFaces.length = 0;
|
6002
6089
|
},
|
6003
6090
|
get loadTestFont() {
|
6004
6091
|
// This is a CFF font with 1 glyph for '.' that fills its entire width and
|
@@ -6049,13 +6136,27 @@ var FontLoader = {
|
|
6049
6136
|
return true;
|
6050
6137
|
}
|
6051
6138
|
// TODO other browsers
|
6139
|
+
if (userAgent === 'node') {
|
6140
|
+
return true;
|
6141
|
+
}
|
6052
6142
|
return false;
|
6053
6143
|
})(),
|
6054
6144
|
|
6145
|
+
nativeFontFaces: [],
|
6146
|
+
|
6147
|
+
isFontLoadingAPISupported: !isWorker && !!document.fonts,
|
6148
|
+
|
6149
|
+
addNativeFontFace: function fontLoader_addNativeFontFace(nativeFontFace) {
|
6150
|
+
this.nativeFontFaces.push(nativeFontFace);
|
6151
|
+
document.fonts.add(nativeFontFace);
|
6152
|
+
},
|
6153
|
+
|
6055
6154
|
bind: function fontLoaderBind(fonts, callback) {
|
6056
6155
|
assert(!isWorker, 'bind() shall be called from main thread');
|
6057
6156
|
|
6058
|
-
var rules = []
|
6157
|
+
var rules = [];
|
6158
|
+
var fontsToLoad = [];
|
6159
|
+
var fontLoadPromises = [];
|
6059
6160
|
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
6060
6161
|
var font = fonts[i];
|
6061
6162
|
|
@@ -6066,15 +6167,26 @@ var FontLoader = {
|
|
6066
6167
|
}
|
6067
6168
|
font.attached = true;
|
6068
6169
|
|
6069
|
-
|
6070
|
-
|
6071
|
-
|
6072
|
-
|
6170
|
+
if (this.isFontLoadingAPISupported) {
|
6171
|
+
var nativeFontFace = font.createNativeFontFace();
|
6172
|
+
if (nativeFontFace) {
|
6173
|
+
fontLoadPromises.push(nativeFontFace.loaded);
|
6174
|
+
}
|
6175
|
+
} else {
|
6176
|
+
var rule = font.bindDOM();
|
6177
|
+
if (rule) {
|
6178
|
+
rules.push(rule);
|
6179
|
+
fontsToLoad.push(font);
|
6180
|
+
}
|
6073
6181
|
}
|
6074
6182
|
}
|
6075
6183
|
|
6076
6184
|
var request = FontLoader.queueLoadingCallback(callback);
|
6077
|
-
if (
|
6185
|
+
if (this.isFontLoadingAPISupported) {
|
6186
|
+
Promise.all(fontsToLoad).then(function() {
|
6187
|
+
request.complete();
|
6188
|
+
});
|
6189
|
+
} else if (rules.length > 0 && !this.isSyncFontLoadingSupported) {
|
6078
6190
|
FontLoader.prepareFontLoadEvent(rules, fontsToLoad, request);
|
6079
6191
|
} else {
|
6080
6192
|
request.complete();
|
@@ -6209,8 +6321,8 @@ var FontLoader = {
|
|
6209
6321
|
}
|
6210
6322
|
};
|
6211
6323
|
|
6212
|
-
var
|
6213
|
-
function
|
6324
|
+
var FontFaceObject = (function FontFaceObjectClosure() {
|
6325
|
+
function FontFaceObject(name, file, properties) {
|
6214
6326
|
this.compiledGlyphs = {};
|
6215
6327
|
if (arguments.length === 1) {
|
6216
6328
|
// importing translated data
|
@@ -6221,8 +6333,29 @@ var FontFace = (function FontFaceClosure() {
|
|
6221
6333
|
return;
|
6222
6334
|
}
|
6223
6335
|
}
|
6224
|
-
|
6225
|
-
|
6336
|
+
FontFaceObject.prototype = {
|
6337
|
+
createNativeFontFace: function FontFaceObject_createNativeFontFace() {
|
6338
|
+
if (!this.data) {
|
6339
|
+
return null;
|
6340
|
+
}
|
6341
|
+
|
6342
|
+
if (PDFJS.disableFontFace) {
|
6343
|
+
this.disableFontFace = true;
|
6344
|
+
return null;
|
6345
|
+
}
|
6346
|
+
|
6347
|
+
var nativeFontFace = new FontFace(this.loadedName, this.data, {});
|
6348
|
+
|
6349
|
+
FontLoader.addNativeFontFace(nativeFontFace);
|
6350
|
+
|
6351
|
+
if (PDFJS.pdfBug && 'FontInspector' in globalScope &&
|
6352
|
+
globalScope['FontInspector'].enabled) {
|
6353
|
+
globalScope['FontInspector'].fontAdded(this);
|
6354
|
+
}
|
6355
|
+
return nativeFontFace;
|
6356
|
+
},
|
6357
|
+
|
6358
|
+
bindDOM: function FontFaceObject_bindDOM() {
|
6226
6359
|
if (!this.data) {
|
6227
6360
|
return null;
|
6228
6361
|
}
|
@@ -6249,7 +6382,7 @@ var FontFace = (function FontFaceClosure() {
|
|
6249
6382
|
return rule;
|
6250
6383
|
},
|
6251
6384
|
|
6252
|
-
getPathGenerator: function (objs, character) {
|
6385
|
+
getPathGenerator: function FontLoader_getPathGenerator(objs, character) {
|
6253
6386
|
if (!(character in this.compiledGlyphs)) {
|
6254
6387
|
var js = objs.get(this.loadedName + '_path_' + character);
|
6255
6388
|
/*jshint -W054 */
|
@@ -6258,11 +6391,10 @@ var FontFace = (function FontFaceClosure() {
|
|
6258
6391
|
return this.compiledGlyphs[character];
|
6259
6392
|
}
|
6260
6393
|
};
|
6261
|
-
return
|
6394
|
+
return FontFaceObject;
|
6262
6395
|
})();
|
6263
6396
|
|
6264
6397
|
|
6265
|
-
var HIGHLIGHT_OFFSET = 4; // px
|
6266
6398
|
var ANNOT_MIN_SIZE = 10; // px
|
6267
6399
|
|
6268
6400
|
var AnnotationUtils = (function AnnotationUtilsClosure() {
|
@@ -6289,43 +6421,36 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
6289
6421
|
style.fontFamily = fontFamily + fallbackName;
|
6290
6422
|
}
|
6291
6423
|
|
6292
|
-
|
6293
|
-
|
6294
|
-
var
|
6295
|
-
var
|
6296
|
-
|
6297
|
-
|
6298
|
-
var
|
6299
|
-
|
6300
|
-
|
6301
|
-
|
6302
|
-
|
6303
|
-
|
6304
|
-
|
6305
|
-
|
6306
|
-
|
6307
|
-
|
6308
|
-
|
6309
|
-
|
6310
|
-
for (var i = 0; i < 3; ++i) {
|
6311
|
-
rgb[i] = Math.round(color[i] * 255);
|
6424
|
+
function initContainer(item, drawBorder) {
|
6425
|
+
var container = document.createElement('section');
|
6426
|
+
var cstyle = container.style;
|
6427
|
+
var width = item.rect[2] - item.rect[0];
|
6428
|
+
var height = item.rect[3] - item.rect[1];
|
6429
|
+
|
6430
|
+
var bWidth = item.borderWidth || 0;
|
6431
|
+
if (bWidth) {
|
6432
|
+
width = width - 2 * bWidth;
|
6433
|
+
height = height - 2 * bWidth;
|
6434
|
+
cstyle.borderWidth = bWidth + 'px';
|
6435
|
+
var color = item.color;
|
6436
|
+
if (drawBorder && color) {
|
6437
|
+
cstyle.borderStyle = 'solid';
|
6438
|
+
cstyle.borderColor = Util.makeCssRgb(Math.round(color[0] * 255),
|
6439
|
+
Math.round(color[1] * 255),
|
6440
|
+
Math.round(color[2] * 255));
|
6441
|
+
}
|
6312
6442
|
}
|
6313
|
-
|
6314
|
-
|
6315
|
-
var highlight = document.createElement('div');
|
6316
|
-
highlight.className = 'annotationHighlight';
|
6317
|
-
highlight.style.left = highlight.style.top = -HIGHLIGHT_OFFSET + 'px';
|
6318
|
-
highlight.style.right = highlight.style.bottom = -HIGHLIGHT_OFFSET + 'px';
|
6319
|
-
highlight.setAttribute('hidden', true);
|
6320
|
-
|
6321
|
-
item.highlightElement = highlight;
|
6322
|
-
container.appendChild(item.highlightElement);
|
6323
|
-
|
6443
|
+
cstyle.width = width + 'px';
|
6444
|
+
cstyle.height = height + 'px';
|
6324
6445
|
return container;
|
6325
6446
|
}
|
6326
6447
|
|
6327
6448
|
function getHtmlElementForTextWidgetAnnotation(item, commonObjs) {
|
6328
|
-
var element =
|
6449
|
+
var element = document.createElement('div');
|
6450
|
+
var width = item.rect[2] - item.rect[0];
|
6451
|
+
var height = item.rect[3] - item.rect[1];
|
6452
|
+
element.style.width = width + 'px';
|
6453
|
+
element.style.height = height + 'px';
|
6329
6454
|
element.style.display = 'table';
|
6330
6455
|
|
6331
6456
|
var content = document.createElement('div');
|
@@ -6344,7 +6469,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
6344
6469
|
return element;
|
6345
6470
|
}
|
6346
6471
|
|
6347
|
-
function getHtmlElementForTextAnnotation(item
|
6472
|
+
function getHtmlElementForTextAnnotation(item) {
|
6348
6473
|
var rect = item.rect;
|
6349
6474
|
|
6350
6475
|
// sanity check because of OOo-generated PDFs
|
@@ -6355,7 +6480,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
6355
6480
|
rect[2] = rect[0] + (rect[3] - rect[1]); // make it square
|
6356
6481
|
}
|
6357
6482
|
|
6358
|
-
var container = initContainer(item);
|
6483
|
+
var container = initContainer(item, false);
|
6359
6484
|
container.className = 'annotText';
|
6360
6485
|
|
6361
6486
|
var image = document.createElement('img');
|
@@ -6380,13 +6505,15 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
6380
6505
|
var i, ii;
|
6381
6506
|
if (item.hasBgColor) {
|
6382
6507
|
var color = item.color;
|
6383
|
-
|
6384
|
-
|
6385
|
-
|
6386
|
-
|
6387
|
-
|
6388
|
-
|
6389
|
-
content.style.backgroundColor = Util.makeCssRgb(
|
6508
|
+
|
6509
|
+
// Enlighten the color (70%)
|
6510
|
+
var BACKGROUND_ENLIGHT = 0.7;
|
6511
|
+
var r = BACKGROUND_ENLIGHT * (1.0 - color[0]) + color[0];
|
6512
|
+
var g = BACKGROUND_ENLIGHT * (1.0 - color[1]) + color[1];
|
6513
|
+
var b = BACKGROUND_ENLIGHT * (1.0 - color[2]) + color[2];
|
6514
|
+
content.style.backgroundColor = Util.makeCssRgb((r * 255) | 0,
|
6515
|
+
(g * 255) | 0,
|
6516
|
+
(b * 255) | 0);
|
6390
6517
|
}
|
6391
6518
|
|
6392
6519
|
var title = document.createElement('h1');
|
@@ -6461,14 +6588,10 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
6461
6588
|
return container;
|
6462
6589
|
}
|
6463
6590
|
|
6464
|
-
function getHtmlElementForLinkAnnotation(item
|
6465
|
-
|
6466
|
-
var container = initContainer(item);
|
6591
|
+
function getHtmlElementForLinkAnnotation(item) {
|
6592
|
+
var container = initContainer(item, true);
|
6467
6593
|
container.className = 'annotLink';
|
6468
6594
|
|
6469
|
-
container.style.borderColor = item.colorCssRgb;
|
6470
|
-
container.style.borderStyle = 'solid';
|
6471
|
-
|
6472
6595
|
var link = document.createElement('a');
|
6473
6596
|
link.href = link.title = item.url || '';
|
6474
6597
|
|
@@ -6482,9 +6605,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
6482
6605
|
case AnnotationType.WIDGET:
|
6483
6606
|
return getHtmlElementForTextWidgetAnnotation(data, objs);
|
6484
6607
|
case AnnotationType.TEXT:
|
6485
|
-
return getHtmlElementForTextAnnotation(data
|
6608
|
+
return getHtmlElementForTextAnnotation(data);
|
6486
6609
|
case AnnotationType.LINK:
|
6487
|
-
return getHtmlElementForLinkAnnotation(data
|
6610
|
+
return getHtmlElementForLinkAnnotation(data);
|
6488
6611
|
default:
|
6489
6612
|
throw new Error('Unsupported annotationType: ' + data.annotationType);
|
6490
6613
|
}
|
@@ -6497,15 +6620,1187 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
6497
6620
|
PDFJS.AnnotationUtils = AnnotationUtils;
|
6498
6621
|
|
6499
6622
|
|
6500
|
-
|
6623
|
+
var SVG_DEFAULTS = {
|
6624
|
+
fontStyle: 'normal',
|
6625
|
+
fontWeight: 'normal',
|
6626
|
+
fillColor: '#000000'
|
6627
|
+
};
|
6628
|
+
|
6629
|
+
var convertImgDataToPng = (function convertImgDataToPngClosure() {
|
6630
|
+
var PNG_HEADER =
|
6631
|
+
new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
6632
|
+
|
6633
|
+
var CHUNK_WRAPPER_SIZE = 12;
|
6634
|
+
|
6635
|
+
var crcTable = new Int32Array(256);
|
6636
|
+
for (var i = 0; i < 256; i++) {
|
6637
|
+
var c = i;
|
6638
|
+
for (var h = 0; h < 8; h++) {
|
6639
|
+
if (c & 1) {
|
6640
|
+
c = 0xedB88320 ^ ((c >> 1) & 0x7fffffff);
|
6641
|
+
} else {
|
6642
|
+
c = (c >> 1) & 0x7fffffff;
|
6643
|
+
}
|
6644
|
+
}
|
6645
|
+
crcTable[i] = c;
|
6646
|
+
}
|
6647
|
+
|
6648
|
+
function crc32(data, start, end) {
|
6649
|
+
var crc = -1;
|
6650
|
+
for (var i = start; i < end; i++) {
|
6651
|
+
var a = (crc ^ data[i]) & 0xff;
|
6652
|
+
var b = crcTable[a];
|
6653
|
+
crc = (crc >>> 8) ^ b;
|
6654
|
+
}
|
6655
|
+
return crc ^ -1;
|
6656
|
+
}
|
6657
|
+
|
6658
|
+
function writePngChunk(type, body, data, offset) {
|
6659
|
+
var p = offset;
|
6660
|
+
var len = body.length;
|
6661
|
+
|
6662
|
+
data[p] = len >> 24 & 0xff;
|
6663
|
+
data[p + 1] = len >> 16 & 0xff;
|
6664
|
+
data[p + 2] = len >> 8 & 0xff;
|
6665
|
+
data[p + 3] = len & 0xff;
|
6666
|
+
p += 4;
|
6667
|
+
|
6668
|
+
data[p] = type.charCodeAt(0) & 0xff;
|
6669
|
+
data[p + 1] = type.charCodeAt(1) & 0xff;
|
6670
|
+
data[p + 2] = type.charCodeAt(2) & 0xff;
|
6671
|
+
data[p + 3] = type.charCodeAt(3) & 0xff;
|
6672
|
+
p += 4;
|
6673
|
+
|
6674
|
+
data.set(body, p);
|
6675
|
+
p += body.length;
|
6676
|
+
|
6677
|
+
var crc = crc32(data, offset + 4, p);
|
6678
|
+
|
6679
|
+
data[p] = crc >> 24 & 0xff;
|
6680
|
+
data[p + 1] = crc >> 16 & 0xff;
|
6681
|
+
data[p + 2] = crc >> 8 & 0xff;
|
6682
|
+
data[p + 3] = crc & 0xff;
|
6683
|
+
}
|
6684
|
+
|
6685
|
+
function adler32(data, start, end) {
|
6686
|
+
var a = 1;
|
6687
|
+
var b = 0;
|
6688
|
+
for (var i = start; i < end; ++i) {
|
6689
|
+
a = (a + (data[i] & 0xff)) % 65521;
|
6690
|
+
b = (b + a) % 65521;
|
6691
|
+
}
|
6692
|
+
return (b << 16) | a;
|
6693
|
+
}
|
6694
|
+
|
6695
|
+
function encode(imgData, kind) {
|
6696
|
+
var width = imgData.width;
|
6697
|
+
var height = imgData.height;
|
6698
|
+
var bitDepth, colorType, lineSize;
|
6699
|
+
var bytes = imgData.data;
|
6700
|
+
|
6701
|
+
switch (kind) {
|
6702
|
+
case ImageKind.GRAYSCALE_1BPP:
|
6703
|
+
colorType = 0;
|
6704
|
+
bitDepth = 1;
|
6705
|
+
lineSize = (width + 7) >> 3;
|
6706
|
+
break;
|
6707
|
+
case ImageKind.RGB_24BPP:
|
6708
|
+
colorType = 2;
|
6709
|
+
bitDepth = 8;
|
6710
|
+
lineSize = width * 3;
|
6711
|
+
break;
|
6712
|
+
case ImageKind.RGBA_32BPP:
|
6713
|
+
colorType = 6;
|
6714
|
+
bitDepth = 8;
|
6715
|
+
lineSize = width * 4;
|
6716
|
+
break;
|
6717
|
+
default:
|
6718
|
+
throw new Error('invalid format');
|
6719
|
+
}
|
6720
|
+
|
6721
|
+
// prefix every row with predictor 0
|
6722
|
+
var literals = new Uint8Array((1 + lineSize) * height);
|
6723
|
+
var offsetLiterals = 0, offsetBytes = 0;
|
6724
|
+
var y, i;
|
6725
|
+
for (y = 0; y < height; ++y) {
|
6726
|
+
literals[offsetLiterals++] = 0; // no prediction
|
6727
|
+
literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize),
|
6728
|
+
offsetLiterals);
|
6729
|
+
offsetBytes += lineSize;
|
6730
|
+
offsetLiterals += lineSize;
|
6731
|
+
}
|
6732
|
+
|
6733
|
+
if (kind === ImageKind.GRAYSCALE_1BPP) {
|
6734
|
+
// inverting for B/W
|
6735
|
+
offsetLiterals = 0;
|
6736
|
+
for (y = 0; y < height; y++) {
|
6737
|
+
offsetLiterals++; // skipping predictor
|
6738
|
+
for (i = 0; i < lineSize; i++) {
|
6739
|
+
literals[offsetLiterals++] ^= 0xFF;
|
6740
|
+
}
|
6741
|
+
}
|
6742
|
+
}
|
6743
|
+
|
6744
|
+
var ihdr = new Uint8Array([
|
6745
|
+
width >> 24 & 0xff,
|
6746
|
+
width >> 16 & 0xff,
|
6747
|
+
width >> 8 & 0xff,
|
6748
|
+
width & 0xff,
|
6749
|
+
height >> 24 & 0xff,
|
6750
|
+
height >> 16 & 0xff,
|
6751
|
+
height >> 8 & 0xff,
|
6752
|
+
height & 0xff,
|
6753
|
+
bitDepth, // bit depth
|
6754
|
+
colorType, // color type
|
6755
|
+
0x00, // compression method
|
6756
|
+
0x00, // filter method
|
6757
|
+
0x00 // interlace method
|
6758
|
+
]);
|
6759
|
+
|
6760
|
+
var len = literals.length;
|
6761
|
+
var maxBlockLength = 0xFFFF;
|
6762
|
+
|
6763
|
+
var deflateBlocks = Math.ceil(len / maxBlockLength);
|
6764
|
+
var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
|
6765
|
+
var pi = 0;
|
6766
|
+
idat[pi++] = 0x78; // compression method and flags
|
6767
|
+
idat[pi++] = 0x9c; // flags
|
6768
|
+
|
6769
|
+
var pos = 0;
|
6770
|
+
while (len > maxBlockLength) {
|
6771
|
+
// writing non-final DEFLATE blocks type 0 and length of 65535
|
6772
|
+
idat[pi++] = 0x00;
|
6773
|
+
idat[pi++] = 0xff;
|
6774
|
+
idat[pi++] = 0xff;
|
6775
|
+
idat[pi++] = 0x00;
|
6776
|
+
idat[pi++] = 0x00;
|
6777
|
+
idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
|
6778
|
+
pi += maxBlockLength;
|
6779
|
+
pos += maxBlockLength;
|
6780
|
+
len -= maxBlockLength;
|
6781
|
+
}
|
6782
|
+
|
6783
|
+
// writing non-final DEFLATE blocks type 0
|
6784
|
+
idat[pi++] = 0x01;
|
6785
|
+
idat[pi++] = len & 0xff;
|
6786
|
+
idat[pi++] = len >> 8 & 0xff;
|
6787
|
+
idat[pi++] = (~len & 0xffff) & 0xff;
|
6788
|
+
idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
|
6789
|
+
idat.set(literals.subarray(pos), pi);
|
6790
|
+
pi += literals.length - pos;
|
6791
|
+
|
6792
|
+
var adler = adler32(literals, 0, literals.length); // checksum
|
6793
|
+
idat[pi++] = adler >> 24 & 0xff;
|
6794
|
+
idat[pi++] = adler >> 16 & 0xff;
|
6795
|
+
idat[pi++] = adler >> 8 & 0xff;
|
6796
|
+
idat[pi++] = adler & 0xff;
|
6797
|
+
|
6798
|
+
// PNG will consists: header, IHDR+data, IDAT+data, and IEND.
|
6799
|
+
var pngLength = PNG_HEADER.length + (CHUNK_WRAPPER_SIZE * 3) +
|
6800
|
+
ihdr.length + idat.length;
|
6801
|
+
var data = new Uint8Array(pngLength);
|
6802
|
+
var offset = 0;
|
6803
|
+
data.set(PNG_HEADER, offset);
|
6804
|
+
offset += PNG_HEADER.length;
|
6805
|
+
writePngChunk('IHDR', ihdr, data, offset);
|
6806
|
+
offset += CHUNK_WRAPPER_SIZE + ihdr.length;
|
6807
|
+
writePngChunk('IDATA', idat, data, offset);
|
6808
|
+
offset += CHUNK_WRAPPER_SIZE + idat.length;
|
6809
|
+
writePngChunk('IEND', new Uint8Array(0), data, offset);
|
6810
|
+
|
6811
|
+
return PDFJS.createObjectURL(data, 'image/png');
|
6812
|
+
}
|
6813
|
+
|
6814
|
+
return function convertImgDataToPng(imgData) {
|
6815
|
+
var kind = (imgData.kind === undefined ?
|
6816
|
+
ImageKind.GRAYSCALE_1BPP : imgData.kind);
|
6817
|
+
return encode(imgData, kind);
|
6818
|
+
};
|
6819
|
+
})();
|
6820
|
+
|
6821
|
+
var SVGExtraState = (function SVGExtraStateClosure() {
|
6822
|
+
function SVGExtraState() {
|
6823
|
+
this.fontSizeScale = 1;
|
6824
|
+
this.fontWeight = SVG_DEFAULTS.fontWeight;
|
6825
|
+
this.fontSize = 0;
|
6826
|
+
|
6827
|
+
this.textMatrix = IDENTITY_MATRIX;
|
6828
|
+
this.fontMatrix = FONT_IDENTITY_MATRIX;
|
6829
|
+
this.leading = 0;
|
6830
|
+
|
6831
|
+
// Current point (in user coordinates)
|
6832
|
+
this.x = 0;
|
6833
|
+
this.y = 0;
|
6834
|
+
|
6835
|
+
// Start of text line (in text coordinates)
|
6836
|
+
this.lineX = 0;
|
6837
|
+
this.lineY = 0;
|
6838
|
+
|
6839
|
+
// Character and word spacing
|
6840
|
+
this.charSpacing = 0;
|
6841
|
+
this.wordSpacing = 0;
|
6842
|
+
this.textHScale = 1;
|
6843
|
+
this.textRise = 0;
|
6844
|
+
|
6845
|
+
// Default foreground and background colors
|
6846
|
+
this.fillColor = SVG_DEFAULTS.fillColor;
|
6847
|
+
this.strokeColor = '#000000';
|
6848
|
+
|
6849
|
+
this.fillAlpha = 1;
|
6850
|
+
this.strokeAlpha = 1;
|
6851
|
+
this.lineWidth = 1;
|
6852
|
+
this.lineJoin = '';
|
6853
|
+
this.lineCap = '';
|
6854
|
+
this.miterLimit = 0;
|
6855
|
+
|
6856
|
+
this.dashArray = [];
|
6857
|
+
this.dashPhase = 0;
|
6858
|
+
|
6859
|
+
this.dependencies = [];
|
6860
|
+
|
6861
|
+
// Clipping
|
6862
|
+
this.clipId = '';
|
6863
|
+
this.pendingClip = false;
|
6864
|
+
|
6865
|
+
this.maskId = '';
|
6866
|
+
}
|
6867
|
+
|
6868
|
+
SVGExtraState.prototype = {
|
6869
|
+
clone: function SVGExtraState_clone() {
|
6870
|
+
return Object.create(this);
|
6871
|
+
},
|
6872
|
+
setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
|
6873
|
+
this.x = x;
|
6874
|
+
this.y = y;
|
6875
|
+
}
|
6876
|
+
};
|
6877
|
+
return SVGExtraState;
|
6878
|
+
})();
|
6879
|
+
|
6880
|
+
var SVGGraphics = (function SVGGraphicsClosure() {
|
6881
|
+
function createScratchSVG(width, height) {
|
6882
|
+
var NS = 'http://www.w3.org/2000/svg';
|
6883
|
+
var svg = document.createElementNS(NS, 'svg:svg');
|
6884
|
+
svg.setAttributeNS(null, 'version', '1.1');
|
6885
|
+
svg.setAttributeNS(null, 'width', width + 'px');
|
6886
|
+
svg.setAttributeNS(null, 'height', height + 'px');
|
6887
|
+
svg.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height);
|
6888
|
+
return svg;
|
6889
|
+
}
|
6890
|
+
|
6891
|
+
function opListToTree(opList) {
|
6892
|
+
var opTree = [];
|
6893
|
+
var tmp = [];
|
6894
|
+
var opListLen = opList.length;
|
6895
|
+
|
6896
|
+
for (var x = 0; x < opListLen; x++) {
|
6897
|
+
if (opList[x].fn === 'save') {
|
6898
|
+
opTree.push({'fnId': 92, 'fn': 'group', 'items': []});
|
6899
|
+
tmp.push(opTree);
|
6900
|
+
opTree = opTree[opTree.length - 1].items;
|
6901
|
+
continue;
|
6902
|
+
}
|
6903
|
+
|
6904
|
+
if(opList[x].fn === 'restore') {
|
6905
|
+
opTree = tmp.pop();
|
6906
|
+
} else {
|
6907
|
+
opTree.push(opList[x]);
|
6908
|
+
}
|
6909
|
+
}
|
6910
|
+
return opTree;
|
6911
|
+
}
|
6912
|
+
|
6913
|
+
/**
|
6914
|
+
* Formats float number.
|
6915
|
+
* @param value {number} number to format.
|
6916
|
+
* @returns {string}
|
6917
|
+
*/
|
6918
|
+
function pf(value) {
|
6919
|
+
if (value === (value | 0)) { // integer number
|
6920
|
+
return value.toString();
|
6921
|
+
}
|
6922
|
+
var s = value.toFixed(10);
|
6923
|
+
var i = s.length - 1;
|
6924
|
+
if (s[i] !== '0') {
|
6925
|
+
return s;
|
6926
|
+
}
|
6927
|
+
// removing trailing zeros
|
6928
|
+
do {
|
6929
|
+
i--;
|
6930
|
+
} while (s[i] === '0');
|
6931
|
+
return s.substr(0, s[i] === '.' ? i : i + 1);
|
6932
|
+
}
|
6933
|
+
|
6934
|
+
/**
|
6935
|
+
* Formats transform matrix. The standard rotation, scale and translate
|
6936
|
+
* matrices are replaced by their shorter forms, and for identity matrix
|
6937
|
+
* returns empty string to save the memory.
|
6938
|
+
* @param m {Array} matrix to format.
|
6939
|
+
* @returns {string}
|
6940
|
+
*/
|
6941
|
+
function pm(m) {
|
6942
|
+
if (m[4] === 0 && m[5] === 0) {
|
6943
|
+
if (m[1] === 0 && m[2] === 0) {
|
6944
|
+
if (m[0] === 1 && m[3] === 1) {
|
6945
|
+
return '';
|
6946
|
+
}
|
6947
|
+
return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
|
6948
|
+
}
|
6949
|
+
if (m[0] === m[3] && m[1] === -m[2]) {
|
6950
|
+
var a = Math.acos(m[0]) * 180 / Math.PI;
|
6951
|
+
return 'rotate(' + pf(a) + ')';
|
6952
|
+
}
|
6953
|
+
} else {
|
6954
|
+
if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
|
6955
|
+
return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
|
6956
|
+
}
|
6957
|
+
}
|
6958
|
+
return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' +
|
6959
|
+
pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
|
6960
|
+
}
|
6961
|
+
|
6962
|
+
function SVGGraphics(commonObjs, objs) {
|
6963
|
+
this.current = new SVGExtraState();
|
6964
|
+
this.transformMatrix = IDENTITY_MATRIX; // Graphics state matrix
|
6965
|
+
this.transformStack = [];
|
6966
|
+
this.extraStack = [];
|
6967
|
+
this.commonObjs = commonObjs;
|
6968
|
+
this.objs = objs;
|
6969
|
+
this.pendingEOFill = false;
|
6970
|
+
|
6971
|
+
this.embedFonts = false;
|
6972
|
+
this.embeddedFonts = {};
|
6973
|
+
this.cssStyle = null;
|
6974
|
+
}
|
6975
|
+
|
6976
|
+
var NS = 'http://www.w3.org/2000/svg';
|
6977
|
+
var XML_NS = 'http://www.w3.org/XML/1998/namespace';
|
6978
|
+
var XLINK_NS = 'http://www.w3.org/1999/xlink';
|
6979
|
+
var LINE_CAP_STYLES = ['butt', 'round', 'square'];
|
6980
|
+
var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
|
6981
|
+
var clipCount = 0;
|
6982
|
+
var maskCount = 0;
|
6983
|
+
|
6984
|
+
SVGGraphics.prototype = {
|
6985
|
+
save: function SVGGraphics_save() {
|
6986
|
+
this.transformStack.push(this.transformMatrix);
|
6987
|
+
var old = this.current;
|
6988
|
+
this.extraStack.push(old);
|
6989
|
+
this.current = old.clone();
|
6990
|
+
},
|
6991
|
+
|
6992
|
+
restore: function SVGGraphics_restore() {
|
6993
|
+
this.transformMatrix = this.transformStack.pop();
|
6994
|
+
this.current = this.extraStack.pop();
|
6995
|
+
|
6996
|
+
this.tgrp = document.createElementNS(NS, 'svg:g');
|
6997
|
+
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
6998
|
+
this.pgrp.appendChild(this.tgrp);
|
6999
|
+
},
|
7000
|
+
|
7001
|
+
group: function SVGGraphics_group(items) {
|
7002
|
+
this.save();
|
7003
|
+
this.executeOpTree(items);
|
7004
|
+
this.restore();
|
7005
|
+
},
|
7006
|
+
|
7007
|
+
loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
|
7008
|
+
var fnArray = operatorList.fnArray;
|
7009
|
+
var fnArrayLen = fnArray.length;
|
7010
|
+
var argsArray = operatorList.argsArray;
|
7011
|
+
|
7012
|
+
var self = this;
|
7013
|
+
for (var i = 0; i < fnArrayLen; i++) {
|
7014
|
+
if (OPS.dependency === fnArray[i]) {
|
7015
|
+
var deps = argsArray[i];
|
7016
|
+
for (var n = 0, nn = deps.length; n < nn; n++) {
|
7017
|
+
var obj = deps[n];
|
7018
|
+
var common = obj.substring(0, 2) === 'g_';
|
7019
|
+
var promise;
|
7020
|
+
if (common) {
|
7021
|
+
promise = new Promise(function(resolve) {
|
7022
|
+
self.commonObjs.get(obj, resolve);
|
7023
|
+
});
|
7024
|
+
} else {
|
7025
|
+
promise = new Promise(function(resolve) {
|
7026
|
+
self.objs.get(obj, resolve);
|
7027
|
+
});
|
7028
|
+
}
|
7029
|
+
this.current.dependencies.push(promise);
|
7030
|
+
}
|
7031
|
+
}
|
7032
|
+
}
|
7033
|
+
return Promise.all(this.current.dependencies);
|
7034
|
+
},
|
7035
|
+
|
7036
|
+
transform: function SVGGraphics_transform(a, b, c, d, e, f) {
|
7037
|
+
var transformMatrix = [a, b, c, d, e, f];
|
7038
|
+
this.transformMatrix = PDFJS.Util.transform(this.transformMatrix,
|
7039
|
+
transformMatrix);
|
7040
|
+
|
7041
|
+
this.tgrp = document.createElementNS(NS, 'svg:g');
|
7042
|
+
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
7043
|
+
},
|
7044
|
+
|
7045
|
+
getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
|
7046
|
+
this.svg = createScratchSVG(viewport.width, viewport.height);
|
7047
|
+
this.viewport = viewport;
|
7048
|
+
|
7049
|
+
return this.loadDependencies(operatorList).then(function () {
|
7050
|
+
this.transformMatrix = IDENTITY_MATRIX;
|
7051
|
+
this.pgrp = document.createElementNS(NS, 'svg:g'); // Parent group
|
7052
|
+
this.pgrp.setAttributeNS(null, 'transform', pm(viewport.transform));
|
7053
|
+
this.tgrp = document.createElementNS(NS, 'svg:g'); // Transform group
|
7054
|
+
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
7055
|
+
this.defs = document.createElementNS(NS, 'svg:defs');
|
7056
|
+
this.pgrp.appendChild(this.defs);
|
7057
|
+
this.pgrp.appendChild(this.tgrp);
|
7058
|
+
this.svg.appendChild(this.pgrp);
|
7059
|
+
var opTree = this.convertOpList(operatorList);
|
7060
|
+
this.executeOpTree(opTree);
|
7061
|
+
return this.svg;
|
7062
|
+
}.bind(this));
|
7063
|
+
},
|
7064
|
+
|
7065
|
+
convertOpList: function SVGGraphics_convertOpList(operatorList) {
|
7066
|
+
var argsArray = operatorList.argsArray;
|
7067
|
+
var fnArray = operatorList.fnArray;
|
7068
|
+
var fnArrayLen = fnArray.length;
|
7069
|
+
var REVOPS = [];
|
7070
|
+
var opList = [];
|
7071
|
+
|
7072
|
+
for (var op in OPS) {
|
7073
|
+
REVOPS[OPS[op]] = op;
|
7074
|
+
}
|
7075
|
+
|
7076
|
+
for (var x = 0; x < fnArrayLen; x++) {
|
7077
|
+
var fnId = fnArray[x];
|
7078
|
+
opList.push({'fnId' : fnId, 'fn': REVOPS[fnId], 'args': argsArray[x]});
|
7079
|
+
}
|
7080
|
+
return opListToTree(opList);
|
7081
|
+
},
|
7082
|
+
|
7083
|
+
executeOpTree: function SVGGraphics_executeOpTree(opTree) {
|
7084
|
+
var opTreeLen = opTree.length;
|
7085
|
+
for(var x = 0; x < opTreeLen; x++) {
|
7086
|
+
var fn = opTree[x].fn;
|
7087
|
+
var fnId = opTree[x].fnId;
|
7088
|
+
var args = opTree[x].args;
|
7089
|
+
|
7090
|
+
switch (fnId | 0) {
|
7091
|
+
case OPS.beginText:
|
7092
|
+
this.beginText();
|
7093
|
+
break;
|
7094
|
+
case OPS.setLeading:
|
7095
|
+
this.setLeading(args);
|
7096
|
+
break;
|
7097
|
+
case OPS.setLeadingMoveText:
|
7098
|
+
this.setLeadingMoveText(args[0], args[1]);
|
7099
|
+
break;
|
7100
|
+
case OPS.setFont:
|
7101
|
+
this.setFont(args);
|
7102
|
+
break;
|
7103
|
+
case OPS.showText:
|
7104
|
+
this.showText(args[0]);
|
7105
|
+
break;
|
7106
|
+
case OPS.showSpacedText:
|
7107
|
+
this.showText(args[0]);
|
7108
|
+
break;
|
7109
|
+
case OPS.endText:
|
7110
|
+
this.endText();
|
7111
|
+
break;
|
7112
|
+
case OPS.moveText:
|
7113
|
+
this.moveText(args[0], args[1]);
|
7114
|
+
break;
|
7115
|
+
case OPS.setCharSpacing:
|
7116
|
+
this.setCharSpacing(args[0]);
|
7117
|
+
break;
|
7118
|
+
case OPS.setWordSpacing:
|
7119
|
+
this.setWordSpacing(args[0]);
|
7120
|
+
break;
|
7121
|
+
case OPS.setTextMatrix:
|
7122
|
+
this.setTextMatrix(args[0], args[1], args[2],
|
7123
|
+
args[3], args[4], args[5]);
|
7124
|
+
break;
|
7125
|
+
case OPS.setLineWidth:
|
7126
|
+
this.setLineWidth(args[0]);
|
7127
|
+
break;
|
7128
|
+
case OPS.setLineJoin:
|
7129
|
+
this.setLineJoin(args[0]);
|
7130
|
+
break;
|
7131
|
+
case OPS.setLineCap:
|
7132
|
+
this.setLineCap(args[0]);
|
7133
|
+
break;
|
7134
|
+
case OPS.setMiterLimit:
|
7135
|
+
this.setMiterLimit(args[0]);
|
7136
|
+
break;
|
7137
|
+
case OPS.setFillRGBColor:
|
7138
|
+
this.setFillRGBColor(args[0], args[1], args[2]);
|
7139
|
+
break;
|
7140
|
+
case OPS.setStrokeRGBColor:
|
7141
|
+
this.setStrokeRGBColor(args[0], args[1], args[2]);
|
7142
|
+
break;
|
7143
|
+
case OPS.setDash:
|
7144
|
+
this.setDash(args[0], args[1]);
|
7145
|
+
break;
|
7146
|
+
case OPS.setGState:
|
7147
|
+
this.setGState(args[0]);
|
7148
|
+
break;
|
7149
|
+
case OPS.fill:
|
7150
|
+
this.fill();
|
7151
|
+
break;
|
7152
|
+
case OPS.eoFill:
|
7153
|
+
this.eoFill();
|
7154
|
+
break;
|
7155
|
+
case OPS.stroke:
|
7156
|
+
this.stroke();
|
7157
|
+
break;
|
7158
|
+
case OPS.fillStroke:
|
7159
|
+
this.fillStroke();
|
7160
|
+
break;
|
7161
|
+
case OPS.eoFillStroke:
|
7162
|
+
this.eoFillStroke();
|
7163
|
+
break;
|
7164
|
+
case OPS.clip:
|
7165
|
+
this.clip('nonzero');
|
7166
|
+
break;
|
7167
|
+
case OPS.eoClip:
|
7168
|
+
this.clip('evenodd');
|
7169
|
+
break;
|
7170
|
+
case OPS.paintSolidColorImageMask:
|
7171
|
+
this.paintSolidColorImageMask();
|
7172
|
+
break;
|
7173
|
+
case OPS.paintJpegXObject:
|
7174
|
+
this.paintJpegXObject(args[0], args[1], args[2]);
|
7175
|
+
break;
|
7176
|
+
case OPS.paintImageXObject:
|
7177
|
+
this.paintImageXObject(args[0]);
|
7178
|
+
break;
|
7179
|
+
case OPS.paintInlineImageXObject:
|
7180
|
+
this.paintInlineImageXObject(args[0]);
|
7181
|
+
break;
|
7182
|
+
case OPS.paintImageMaskXObject:
|
7183
|
+
this.paintImageMaskXObject(args[0]);
|
7184
|
+
break;
|
7185
|
+
case OPS.paintFormXObjectBegin:
|
7186
|
+
this.paintFormXObjectBegin(args[0], args[1]);
|
7187
|
+
break;
|
7188
|
+
case OPS.paintFormXObjectEnd:
|
7189
|
+
this.paintFormXObjectEnd();
|
7190
|
+
break;
|
7191
|
+
case OPS.closePath:
|
7192
|
+
this.closePath();
|
7193
|
+
break;
|
7194
|
+
case OPS.closeStroke:
|
7195
|
+
this.closeStroke();
|
7196
|
+
break;
|
7197
|
+
case OPS.closeFillStroke:
|
7198
|
+
this.closeFillStroke();
|
7199
|
+
break;
|
7200
|
+
case OPS.nextLine:
|
7201
|
+
this.nextLine();
|
7202
|
+
break;
|
7203
|
+
case OPS.transform:
|
7204
|
+
this.transform(args[0], args[1], args[2], args[3],
|
7205
|
+
args[4], args[5]);
|
7206
|
+
break;
|
7207
|
+
case OPS.constructPath:
|
7208
|
+
this.constructPath(args[0], args[1]);
|
7209
|
+
break;
|
7210
|
+
case OPS.endPath:
|
7211
|
+
this.endPath();
|
7212
|
+
break;
|
7213
|
+
case 92:
|
7214
|
+
this.group(opTree[x].items);
|
7215
|
+
break;
|
7216
|
+
default:
|
7217
|
+
warn('Unimplemented method '+ fn);
|
7218
|
+
break;
|
7219
|
+
}
|
7220
|
+
}
|
7221
|
+
},
|
7222
|
+
|
7223
|
+
setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
|
7224
|
+
this.current.wordSpacing = wordSpacing;
|
7225
|
+
},
|
7226
|
+
|
7227
|
+
setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
|
7228
|
+
this.current.charSpacing = charSpacing;
|
7229
|
+
},
|
7230
|
+
|
7231
|
+
nextLine: function SVGGraphics_nextLine() {
|
7232
|
+
this.moveText(0, this.current.leading);
|
7233
|
+
},
|
7234
|
+
|
7235
|
+
setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
|
7236
|
+
var current = this.current;
|
7237
|
+
this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f];
|
7238
|
+
|
7239
|
+
this.current.x = this.current.lineX = 0;
|
7240
|
+
this.current.y = this.current.lineY = 0;
|
7241
|
+
|
7242
|
+
current.xcoords = [];
|
7243
|
+
current.tspan = document.createElementNS(NS, 'svg:tspan');
|
7244
|
+
current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
|
7245
|
+
current.tspan.setAttributeNS(null, 'font-size',
|
7246
|
+
pf(current.fontSize) + 'px');
|
7247
|
+
current.tspan.setAttributeNS(null, 'y', pf(-current.y));
|
7248
|
+
|
7249
|
+
current.txtElement = document.createElementNS(NS, 'svg:text');
|
7250
|
+
current.txtElement.appendChild(current.tspan);
|
7251
|
+
},
|
7252
|
+
|
7253
|
+
beginText: function SVGGraphics_beginText() {
|
7254
|
+
this.current.x = this.current.lineX = 0;
|
7255
|
+
this.current.y = this.current.lineY = 0;
|
7256
|
+
this.current.textMatrix = IDENTITY_MATRIX;
|
7257
|
+
this.current.lineMatrix = IDENTITY_MATRIX;
|
7258
|
+
this.current.tspan = document.createElementNS(NS, 'svg:tspan');
|
7259
|
+
this.current.txtElement = document.createElementNS(NS, 'svg:text');
|
7260
|
+
this.current.txtgrp = document.createElementNS(NS, 'svg:g');
|
7261
|
+
this.current.xcoords = [];
|
7262
|
+
},
|
7263
|
+
|
7264
|
+
moveText: function SVGGraphics_moveText(x, y) {
|
7265
|
+
var current = this.current;
|
7266
|
+
this.current.x = this.current.lineX += x;
|
7267
|
+
this.current.y = this.current.lineY += y;
|
7268
|
+
|
7269
|
+
current.xcoords = [];
|
7270
|
+
current.tspan = document.createElementNS(NS, 'svg:tspan');
|
7271
|
+
current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
|
7272
|
+
current.tspan.setAttributeNS(null, 'font-size',
|
7273
|
+
pf(current.fontSize) + 'px');
|
7274
|
+
current.tspan.setAttributeNS(null, 'y', pf(-current.y));
|
7275
|
+
},
|
7276
|
+
|
7277
|
+
showText: function SVGGraphics_showText(glyphs) {
|
7278
|
+
var current = this.current;
|
7279
|
+
var font = current.font;
|
7280
|
+
var fontSize = current.fontSize;
|
7281
|
+
|
7282
|
+
if (fontSize === 0) {
|
7283
|
+
return;
|
7284
|
+
}
|
7285
|
+
|
7286
|
+
var charSpacing = current.charSpacing;
|
7287
|
+
var wordSpacing = current.wordSpacing;
|
7288
|
+
var fontDirection = current.fontDirection;
|
7289
|
+
var textHScale = current.textHScale * fontDirection;
|
7290
|
+
var glyphsLength = glyphs.length;
|
7291
|
+
var vertical = font.vertical;
|
7292
|
+
var widthAdvanceScale = fontSize * current.fontMatrix[0];
|
7293
|
+
|
7294
|
+
var x = 0, i;
|
7295
|
+
for (i = 0; i < glyphsLength; ++i) {
|
7296
|
+
var glyph = glyphs[i];
|
7297
|
+
if (glyph === null) {
|
7298
|
+
// word break
|
7299
|
+
x += fontDirection * wordSpacing;
|
7300
|
+
continue;
|
7301
|
+
} else if (isNum(glyph)) {
|
7302
|
+
x += -glyph * fontSize * 0.001;
|
7303
|
+
continue;
|
7304
|
+
}
|
7305
|
+
current.xcoords.push(current.x + x * textHScale);
|
7306
|
+
|
7307
|
+
var width = glyph.width;
|
7308
|
+
var character = glyph.fontChar;
|
7309
|
+
var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
|
7310
|
+
x += charWidth;
|
7311
|
+
|
7312
|
+
current.tspan.textContent += character;
|
7313
|
+
}
|
7314
|
+
if (vertical) {
|
7315
|
+
current.y -= x * textHScale;
|
7316
|
+
} else {
|
7317
|
+
current.x += x * textHScale;
|
7318
|
+
}
|
7319
|
+
|
7320
|
+
current.tspan.setAttributeNS(null, 'x',
|
7321
|
+
current.xcoords.map(pf).join(' '));
|
7322
|
+
current.tspan.setAttributeNS(null, 'y', pf(-current.y));
|
7323
|
+
current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
|
7324
|
+
current.tspan.setAttributeNS(null, 'font-size',
|
7325
|
+
pf(current.fontSize) + 'px');
|
7326
|
+
if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
|
7327
|
+
current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
|
7328
|
+
}
|
7329
|
+
if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
|
7330
|
+
current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
|
7331
|
+
}
|
7332
|
+
if (current.fillColor !== SVG_DEFAULTS.fillColor) {
|
7333
|
+
current.tspan.setAttributeNS(null, 'fill', current.fillColor);
|
7334
|
+
}
|
7335
|
+
|
7336
|
+
current.txtElement.setAttributeNS(null, 'transform',
|
7337
|
+
pm(current.textMatrix) +
|
7338
|
+
' scale(1, -1)' );
|
7339
|
+
current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
|
7340
|
+
current.txtElement.appendChild(current.tspan);
|
7341
|
+
current.txtgrp.appendChild(current.txtElement);
|
7342
|
+
|
7343
|
+
this.tgrp.appendChild(current.txtElement);
|
7344
|
+
|
7345
|
+
},
|
7346
|
+
|
7347
|
+
setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
|
7348
|
+
this.setLeading(-y);
|
7349
|
+
this.moveText(x, y);
|
7350
|
+
},
|
7351
|
+
|
7352
|
+
addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
|
7353
|
+
if (!this.cssStyle) {
|
7354
|
+
this.cssStyle = document.createElementNS(NS, 'svg:style');
|
7355
|
+
this.cssStyle.setAttributeNS(null, 'type', 'text/css');
|
7356
|
+
this.defs.appendChild(this.cssStyle);
|
7357
|
+
}
|
7358
|
+
|
7359
|
+
var url = PDFJS.createObjectURL(fontObj.data, fontObj.mimetype);
|
7360
|
+
this.cssStyle.textContent +=
|
7361
|
+
'@font-face { font-family: "' + fontObj.loadedName + '";' +
|
7362
|
+
' src: url(' + url + '); }\n';
|
7363
|
+
},
|
7364
|
+
|
7365
|
+
setFont: function SVGGraphics_setFont(details) {
|
7366
|
+
var current = this.current;
|
7367
|
+
var fontObj = this.commonObjs.get(details[0]);
|
7368
|
+
var size = details[1];
|
7369
|
+
this.current.font = fontObj;
|
7370
|
+
|
7371
|
+
if (this.embedFonts && fontObj.data &&
|
7372
|
+
!this.embeddedFonts[fontObj.loadedName]) {
|
7373
|
+
this.addFontStyle(fontObj);
|
7374
|
+
this.embeddedFonts[fontObj.loadedName] = fontObj;
|
7375
|
+
}
|
7376
|
+
|
7377
|
+
current.fontMatrix = (fontObj.fontMatrix ?
|
7378
|
+
fontObj.fontMatrix : FONT_IDENTITY_MATRIX);
|
7379
|
+
|
7380
|
+
var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') :
|
7381
|
+
(fontObj.bold ? 'bold' : 'normal');
|
7382
|
+
var italic = fontObj.italic ? 'italic' : 'normal';
|
7383
|
+
|
7384
|
+
if (size < 0) {
|
7385
|
+
size = -size;
|
7386
|
+
current.fontDirection = -1;
|
7387
|
+
} else {
|
7388
|
+
current.fontDirection = 1;
|
7389
|
+
}
|
7390
|
+
current.fontSize = size;
|
7391
|
+
current.fontFamily = fontObj.loadedName;
|
7392
|
+
current.fontWeight = bold;
|
7393
|
+
current.fontStyle = italic;
|
7394
|
+
|
7395
|
+
current.tspan = document.createElementNS(NS, 'svg:tspan');
|
7396
|
+
current.tspan.setAttributeNS(null, 'y', pf(-current.y));
|
7397
|
+
current.xcoords = [];
|
7398
|
+
},
|
7399
|
+
|
7400
|
+
endText: function SVGGraphics_endText() {
|
7401
|
+
if (this.current.pendingClip) {
|
7402
|
+
this.cgrp.appendChild(this.tgrp);
|
7403
|
+
this.pgrp.appendChild(this.cgrp);
|
7404
|
+
} else {
|
7405
|
+
this.pgrp.appendChild(this.tgrp);
|
7406
|
+
}
|
7407
|
+
this.tgrp = document.createElementNS(NS, 'svg:g');
|
7408
|
+
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
7409
|
+
},
|
7410
|
+
|
7411
|
+
// Path properties
|
7412
|
+
setLineWidth: function SVGGraphics_setLineWidth(width) {
|
7413
|
+
this.current.lineWidth = width;
|
7414
|
+
},
|
7415
|
+
setLineCap: function SVGGraphics_setLineCap(style) {
|
7416
|
+
this.current.lineCap = LINE_CAP_STYLES[style];
|
7417
|
+
},
|
7418
|
+
setLineJoin: function SVGGraphics_setLineJoin(style) {
|
7419
|
+
this.current.lineJoin = LINE_JOIN_STYLES[style];
|
7420
|
+
},
|
7421
|
+
setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
|
7422
|
+
this.current.miterLimit = limit;
|
7423
|
+
},
|
7424
|
+
setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
|
7425
|
+
var color = Util.makeCssRgb(r, g, b);
|
7426
|
+
this.current.strokeColor = color;
|
7427
|
+
},
|
7428
|
+
setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
|
7429
|
+
var color = Util.makeCssRgb(r, g, b);
|
7430
|
+
this.current.fillColor = color;
|
7431
|
+
this.current.tspan = document.createElementNS(NS, 'svg:tspan');
|
7432
|
+
this.current.xcoords = [];
|
7433
|
+
},
|
7434
|
+
setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
|
7435
|
+
this.current.dashArray = dashArray;
|
7436
|
+
this.current.dashPhase = dashPhase;
|
7437
|
+
},
|
7438
|
+
|
7439
|
+
constructPath: function SVGGraphics_constructPath(ops, args) {
|
7440
|
+
var current = this.current;
|
7441
|
+
var x = current.x, y = current.y;
|
7442
|
+
current.path = document.createElementNS(NS, 'svg:path');
|
7443
|
+
var d = [];
|
7444
|
+
var opLength = ops.length;
|
7445
|
+
|
7446
|
+
for (var i = 0, j = 0; i < opLength; i++) {
|
7447
|
+
switch (ops[i] | 0) {
|
7448
|
+
case OPS.rectangle:
|
7449
|
+
x = args[j++];
|
7450
|
+
y = args[j++];
|
7451
|
+
var width = args[j++];
|
7452
|
+
var height = args[j++];
|
7453
|
+
var xw = x + width;
|
7454
|
+
var yh = y + height;
|
7455
|
+
d.push('M', pf(x), pf(y), 'L', pf(xw) , pf(y), 'L', pf(xw), pf(yh),
|
7456
|
+
'L', pf(x), pf(yh), 'Z');
|
7457
|
+
break;
|
7458
|
+
case OPS.moveTo:
|
7459
|
+
x = args[j++];
|
7460
|
+
y = args[j++];
|
7461
|
+
d.push('M', pf(x), pf(y));
|
7462
|
+
break;
|
7463
|
+
case OPS.lineTo:
|
7464
|
+
x = args[j++];
|
7465
|
+
y = args[j++];
|
7466
|
+
d.push('L', pf(x) , pf(y));
|
7467
|
+
break;
|
7468
|
+
case OPS.curveTo:
|
7469
|
+
x = args[j + 4];
|
7470
|
+
y = args[j + 5];
|
7471
|
+
d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]),
|
7472
|
+
pf(args[j + 3]), pf(x), pf(y));
|
7473
|
+
j += 6;
|
7474
|
+
break;
|
7475
|
+
case OPS.curveTo2:
|
7476
|
+
x = args[j + 2];
|
7477
|
+
y = args[j + 3];
|
7478
|
+
d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]),
|
7479
|
+
pf(args[j + 2]), pf(args[j + 3]));
|
7480
|
+
j += 4;
|
7481
|
+
break;
|
7482
|
+
case OPS.curveTo3:
|
7483
|
+
x = args[j + 2];
|
7484
|
+
y = args[j + 3];
|
7485
|
+
d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y),
|
7486
|
+
pf(x), pf(y));
|
7487
|
+
j += 4;
|
7488
|
+
break;
|
7489
|
+
case OPS.closePath:
|
7490
|
+
d.push('Z');
|
7491
|
+
break;
|
7492
|
+
}
|
7493
|
+
}
|
7494
|
+
current.path.setAttributeNS(null, 'd', d.join(' '));
|
7495
|
+
current.path.setAttributeNS(null, 'stroke-miterlimit',
|
7496
|
+
pf(current.miterLimit));
|
7497
|
+
current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
|
7498
|
+
current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
|
7499
|
+
current.path.setAttributeNS(null, 'stroke-width',
|
7500
|
+
pf(current.lineWidth) + 'px');
|
7501
|
+
current.path.setAttributeNS(null, 'stroke-dasharray',
|
7502
|
+
current.dashArray.map(pf).join(' '));
|
7503
|
+
current.path.setAttributeNS(null, 'stroke-dashoffset',
|
7504
|
+
pf(current.dashPhase) + 'px');
|
7505
|
+
current.path.setAttributeNS(null, 'fill', 'none');
|
7506
|
+
|
7507
|
+
this.tgrp.appendChild(current.path);
|
7508
|
+
if (current.pendingClip) {
|
7509
|
+
this.cgrp.appendChild(this.tgrp);
|
7510
|
+
this.pgrp.appendChild(this.cgrp);
|
7511
|
+
} else {
|
7512
|
+
this.pgrp.appendChild(this.tgrp);
|
7513
|
+
}
|
7514
|
+
// Saving a reference in current.element so that it can be addressed
|
7515
|
+
// in 'fill' and 'stroke'
|
7516
|
+
current.element = current.path;
|
7517
|
+
current.setCurrentPoint(x, y);
|
7518
|
+
},
|
7519
|
+
|
7520
|
+
endPath: function SVGGraphics_endPath() {
|
7521
|
+
var current = this.current;
|
7522
|
+
if (current.pendingClip) {
|
7523
|
+
this.cgrp.appendChild(this.tgrp);
|
7524
|
+
this.pgrp.appendChild(this.cgrp);
|
7525
|
+
} else {
|
7526
|
+
this.pgrp.appendChild(this.tgrp);
|
7527
|
+
}
|
7528
|
+
this.tgrp = document.createElementNS(NS, 'svg:g');
|
7529
|
+
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
7530
|
+
},
|
7531
|
+
|
7532
|
+
clip: function SVGGraphics_clip(type) {
|
7533
|
+
var current = this.current;
|
7534
|
+
// Add current path to clipping path
|
7535
|
+
current.clipId = 'clippath' + clipCount;
|
7536
|
+
clipCount++;
|
7537
|
+
this.clippath = document.createElementNS(NS, 'svg:clipPath');
|
7538
|
+
this.clippath.setAttributeNS(null, 'id', current.clipId);
|
7539
|
+
var clipElement = current.element.cloneNode();
|
7540
|
+
if (type === 'evenodd') {
|
7541
|
+
clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
|
7542
|
+
} else {
|
7543
|
+
clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
|
7544
|
+
}
|
7545
|
+
this.clippath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
7546
|
+
this.clippath.appendChild(clipElement);
|
7547
|
+
this.defs.appendChild(this.clippath);
|
7548
|
+
|
7549
|
+
// Create a new group with that attribute
|
7550
|
+
current.pendingClip = true;
|
7551
|
+
this.cgrp = document.createElementNS(NS, 'svg:g');
|
7552
|
+
this.cgrp.setAttributeNS(null, 'clip-path',
|
7553
|
+
'url(#' + current.clipId + ')');
|
7554
|
+
this.pgrp.appendChild(this.cgrp);
|
7555
|
+
},
|
7556
|
+
|
7557
|
+
closePath: function SVGGraphics_closePath() {
|
7558
|
+
var current = this.current;
|
7559
|
+
var d = current.path.getAttributeNS(null, 'd');
|
7560
|
+
d += 'Z';
|
7561
|
+
current.path.setAttributeNS(null, 'd', d);
|
7562
|
+
},
|
7563
|
+
|
7564
|
+
setLeading: function SVGGraphics_setLeading(leading) {
|
7565
|
+
this.current.leading = -leading;
|
7566
|
+
},
|
7567
|
+
|
7568
|
+
setTextRise: function SVGGraphics_setTextRise(textRise) {
|
7569
|
+
this.current.textRise = textRise;
|
7570
|
+
},
|
7571
|
+
|
7572
|
+
setHScale: function SVGGraphics_setHScale(scale) {
|
7573
|
+
this.current.textHScale = scale / 100;
|
7574
|
+
},
|
7575
|
+
|
7576
|
+
setGState: function SVGGraphics_setGState(states) {
|
7577
|
+
for (var i = 0, ii = states.length; i < ii; i++) {
|
7578
|
+
var state = states[i];
|
7579
|
+
var key = state[0];
|
7580
|
+
var value = state[1];
|
7581
|
+
|
7582
|
+
switch (key) {
|
7583
|
+
case 'LW':
|
7584
|
+
this.setLineWidth(value);
|
7585
|
+
break;
|
7586
|
+
case 'LC':
|
7587
|
+
this.setLineCap(value);
|
7588
|
+
break;
|
7589
|
+
case 'LJ':
|
7590
|
+
this.setLineJoin(value);
|
7591
|
+
break;
|
7592
|
+
case 'ML':
|
7593
|
+
this.setMiterLimit(value);
|
7594
|
+
break;
|
7595
|
+
case 'D':
|
7596
|
+
this.setDash(value[0], value[1]);
|
7597
|
+
break;
|
7598
|
+
case 'RI':
|
7599
|
+
break;
|
7600
|
+
case 'FL':
|
7601
|
+
break;
|
7602
|
+
case 'Font':
|
7603
|
+
this.setFont(value);
|
7604
|
+
break;
|
7605
|
+
case 'CA':
|
7606
|
+
break;
|
7607
|
+
case 'ca':
|
7608
|
+
break;
|
7609
|
+
case 'BM':
|
7610
|
+
break;
|
7611
|
+
case 'SMask':
|
7612
|
+
break;
|
7613
|
+
}
|
7614
|
+
}
|
7615
|
+
},
|
7616
|
+
|
7617
|
+
fill: function SVGGraphics_fill() {
|
7618
|
+
var current = this.current;
|
7619
|
+
current.element.setAttributeNS(null, 'fill', current.fillColor);
|
7620
|
+
},
|
7621
|
+
|
7622
|
+
stroke: function SVGGraphics_stroke() {
|
7623
|
+
var current = this.current;
|
7624
|
+
current.element.setAttributeNS(null, 'stroke', current.strokeColor);
|
7625
|
+
current.element.setAttributeNS(null, 'fill', 'none');
|
7626
|
+
},
|
7627
|
+
|
7628
|
+
eoFill: function SVGGraphics_eoFill() {
|
7629
|
+
var current = this.current;
|
7630
|
+
current.element.setAttributeNS(null, 'fill', current.fillColor);
|
7631
|
+
current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
|
7632
|
+
},
|
7633
|
+
|
7634
|
+
fillStroke: function SVGGraphics_fillStroke() {
|
7635
|
+
// Order is important since stroke wants fill to be none.
|
7636
|
+
// First stroke, then if fill needed, it will be overwritten.
|
7637
|
+
this.stroke();
|
7638
|
+
this.fill();
|
7639
|
+
},
|
7640
|
+
|
7641
|
+
eoFillStroke: function SVGGraphics_eoFillStroke() {
|
7642
|
+
this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
|
7643
|
+
this.fillStroke();
|
7644
|
+
},
|
7645
|
+
|
7646
|
+
closeStroke: function SVGGraphics_closeStroke() {
|
7647
|
+
this.closePath();
|
7648
|
+
this.stroke();
|
7649
|
+
},
|
7650
|
+
|
7651
|
+
closeFillStroke: function SVGGraphics_closeFillStroke() {
|
7652
|
+
this.closePath();
|
7653
|
+
this.fillStroke();
|
7654
|
+
},
|
7655
|
+
|
7656
|
+
paintSolidColorImageMask:
|
7657
|
+
function SVGGraphics_paintSolidColorImageMask() {
|
7658
|
+
var current = this.current;
|
7659
|
+
var rect = document.createElementNS(NS, 'svg:rect');
|
7660
|
+
rect.setAttributeNS(null, 'x', '0');
|
7661
|
+
rect.setAttributeNS(null, 'y', '0');
|
7662
|
+
rect.setAttributeNS(null, 'width', '1px');
|
7663
|
+
rect.setAttributeNS(null, 'height', '1px');
|
7664
|
+
rect.setAttributeNS(null, 'fill', current.fillColor);
|
7665
|
+
this.tgrp.appendChild(rect);
|
7666
|
+
},
|
7667
|
+
|
7668
|
+
paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
|
7669
|
+
var current = this.current;
|
7670
|
+
var imgObj = this.objs.get(objId);
|
7671
|
+
var imgEl = document.createElementNS(NS, 'svg:image');
|
7672
|
+
imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
|
7673
|
+
imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
|
7674
|
+
imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
|
7675
|
+
imgEl.setAttributeNS(null, 'x', '0');
|
7676
|
+
imgEl.setAttributeNS(null, 'y', pf(-h));
|
7677
|
+
imgEl.setAttributeNS(null, 'transform',
|
7678
|
+
'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
|
7679
|
+
|
7680
|
+
this.tgrp.appendChild(imgEl);
|
7681
|
+
if (current.pendingClip) {
|
7682
|
+
this.cgrp.appendChild(this.tgrp);
|
7683
|
+
this.pgrp.appendChild(this.cgrp);
|
7684
|
+
} else {
|
7685
|
+
this.pgrp.appendChild(this.tgrp);
|
7686
|
+
}
|
7687
|
+
},
|
7688
|
+
|
7689
|
+
paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
|
7690
|
+
var imgData = this.objs.get(objId);
|
7691
|
+
if (!imgData) {
|
7692
|
+
warn('Dependent image isn\'t ready yet');
|
7693
|
+
return;
|
7694
|
+
}
|
7695
|
+
this.paintInlineImageXObject(imgData);
|
7696
|
+
},
|
7697
|
+
|
7698
|
+
paintInlineImageXObject:
|
7699
|
+
function SVGGraphics_paintInlineImageXObject(imgData, mask) {
|
7700
|
+
var current = this.current;
|
7701
|
+
var width = imgData.width;
|
7702
|
+
var height = imgData.height;
|
7703
|
+
|
7704
|
+
var imgSrc = convertImgDataToPng(imgData);
|
7705
|
+
var cliprect = document.createElementNS(NS, 'svg:rect');
|
7706
|
+
cliprect.setAttributeNS(null, 'x', '0');
|
7707
|
+
cliprect.setAttributeNS(null, 'y', '0');
|
7708
|
+
cliprect.setAttributeNS(null, 'width', pf(width));
|
7709
|
+
cliprect.setAttributeNS(null, 'height', pf(height));
|
7710
|
+
current.element = cliprect;
|
7711
|
+
this.clip('nonzero');
|
7712
|
+
var imgEl = document.createElementNS(NS, 'svg:image');
|
7713
|
+
imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
|
7714
|
+
imgEl.setAttributeNS(null, 'x', '0');
|
7715
|
+
imgEl.setAttributeNS(null, 'y', pf(-height));
|
7716
|
+
imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
|
7717
|
+
imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
|
7718
|
+
imgEl.setAttributeNS(null, 'transform',
|
7719
|
+
'scale(' + pf(1 / width) + ' ' +
|
7720
|
+
pf(-1 / height) + ')');
|
7721
|
+
if (mask) {
|
7722
|
+
mask.appendChild(imgEl);
|
7723
|
+
} else {
|
7724
|
+
this.tgrp.appendChild(imgEl);
|
7725
|
+
}
|
7726
|
+
if (current.pendingClip) {
|
7727
|
+
this.cgrp.appendChild(this.tgrp);
|
7728
|
+
this.pgrp.appendChild(this.cgrp);
|
7729
|
+
} else {
|
7730
|
+
this.pgrp.appendChild(this.tgrp);
|
7731
|
+
}
|
7732
|
+
},
|
7733
|
+
|
7734
|
+
paintImageMaskXObject:
|
7735
|
+
function SVGGraphics_paintImageMaskXObject(imgData) {
|
7736
|
+
var current = this.current;
|
7737
|
+
var width = imgData.width;
|
7738
|
+
var height = imgData.height;
|
7739
|
+
var fillColor = current.fillColor;
|
7740
|
+
|
7741
|
+
current.maskId = 'mask' + maskCount++;
|
7742
|
+
var mask = document.createElementNS(NS, 'svg:mask');
|
7743
|
+
mask.setAttributeNS(null, 'id', current.maskId);
|
7744
|
+
|
7745
|
+
var rect = document.createElementNS(NS, 'svg:rect');
|
7746
|
+
rect.setAttributeNS(null, 'x', '0');
|
7747
|
+
rect.setAttributeNS(null, 'y', '0');
|
7748
|
+
rect.setAttributeNS(null, 'width', pf(width));
|
7749
|
+
rect.setAttributeNS(null, 'height', pf(height));
|
7750
|
+
rect.setAttributeNS(null, 'fill', fillColor);
|
7751
|
+
rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId +')');
|
7752
|
+
this.defs.appendChild(mask);
|
7753
|
+
this.tgrp.appendChild(rect);
|
7754
|
+
|
7755
|
+
this.paintInlineImageXObject(imgData, mask);
|
7756
|
+
},
|
7757
|
+
|
7758
|
+
paintFormXObjectBegin:
|
7759
|
+
function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
|
7760
|
+
this.save();
|
7761
|
+
|
7762
|
+
if (isArray(matrix) && matrix.length === 6) {
|
7763
|
+
this.transform(matrix[0], matrix[1], matrix[2],
|
7764
|
+
matrix[3], matrix[4], matrix[5]);
|
7765
|
+
}
|
7766
|
+
|
7767
|
+
if (isArray(bbox) && bbox.length === 4) {
|
7768
|
+
var width = bbox[2] - bbox[0];
|
7769
|
+
var height = bbox[3] - bbox[1];
|
7770
|
+
|
7771
|
+
var cliprect = document.createElementNS(NS, 'svg:rect');
|
7772
|
+
cliprect.setAttributeNS(null, 'x', bbox[0]);
|
7773
|
+
cliprect.setAttributeNS(null, 'y', bbox[1]);
|
7774
|
+
cliprect.setAttributeNS(null, 'width', pf(width));
|
7775
|
+
cliprect.setAttributeNS(null, 'height', pf(height));
|
7776
|
+
this.current.element = cliprect;
|
7777
|
+
this.clip('nonzero');
|
7778
|
+
this.endPath();
|
7779
|
+
}
|
7780
|
+
},
|
7781
|
+
|
7782
|
+
paintFormXObjectEnd:
|
7783
|
+
function SVGGraphics_paintFormXObjectEnd() {
|
7784
|
+
this.restore();
|
7785
|
+
}
|
7786
|
+
};
|
7787
|
+
return SVGGraphics;
|
7788
|
+
})();
|
7789
|
+
|
7790
|
+
PDFJS.SVGGraphics = SVGGraphics;
|
7791
|
+
|
7792
|
+
|
7793
|
+
}).call((typeof window === 'undefined') ? this : window);
|
7794
|
+
|
7795
|
+
if (!PDFJS.workerSrc && typeof document !== 'undefined') {
|
7796
|
+
// workerSrc is not set -- using last script url to define default location
|
7797
|
+
PDFJS.workerSrc = (function () {
|
7798
|
+
'use strict';
|
7799
|
+
var scriptTagContainer = document.body ||
|
7800
|
+
document.getElementsByTagName('head')[0];
|
7801
|
+
var pdfjsSrc = scriptTagContainer.lastChild.src;
|
7802
|
+
return pdfjsSrc && pdfjsSrc.replace(/\.js$/i, '.worker.js');
|
7803
|
+
})();
|
7804
|
+
}
|
7805
|
+
|
6501
7806
|
|
6502
|
-
if (!PDFJS.workerSrc && typeof document !== 'undefined') {
|
6503
|
-
// workerSrc is not set -- using last script url to define default location
|
6504
|
-
PDFJS.workerSrc = (function () {
|
6505
|
-
'use strict';
|
6506
|
-
var scriptTagContainer = document.body ||
|
6507
|
-
document.getElementsByTagName('head')[0];
|
6508
|
-
var pdfjsSrc = scriptTagContainer.lastChild.src;
|
6509
|
-
return pdfjsSrc && pdfjsSrc.replace(/\.js$/i, '.worker.js');
|
6510
|
-
})();
|
6511
|
-
}
|