@syncfusion/ej2-pdfviewer 17.3.49-4568 → 17.3.51-4568
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-pdfviewer.umd.min.js +1 -1
- package/dist/ej2-pdfviewer.umd.min.js.map +1 -1
- package/dist/es6/ej2-pdfviewer.es2015.js +267 -5
- package/dist/es6/ej2-pdfviewer.es2015.js.map +1 -1
- package/dist/es6/ej2-pdfviewer.es5.js +274 -5
- package/dist/es6/ej2-pdfviewer.es5.js.map +1 -1
- package/package.json +1 -1
- package/src/pdfviewer/base/pdfviewer-base.d.ts +9 -4
- package/src/pdfviewer/base/pdfviewer-base.js +49 -5
- package/src/pdfviewer/base/text-layer.js +3 -0
- package/src/pdfviewer/index.d.ts +1 -0
- package/src/pdfviewer/index.js +1 -0
- package/src/pdfviewer/magnification/magnification.js +2 -0
- package/src/pdfviewer/pdfviewer-model.d.ts +8 -2
- package/src/pdfviewer/pdfviewer.d.ts +19 -1
- package/src/pdfviewer/pdfviewer.js +22 -0
- package/src/pdfviewer/tagged-pdf/index.d.ts +4 -0
- package/src/pdfviewer/tagged-pdf/index.js +4 -0
- package/src/pdfviewer/tagged-pdf/tagged-pdf.d.ts +26 -0
- package/src/pdfviewer/tagged-pdf/tagged-pdf.js +195 -0
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PdfViewer, TextLayer, ContextMenu, Signature } from '../index';
|
|
1
|
+
import { PdfViewer, TextLayer, ContextMenu, Signature, TaggedPDF } from '../index';
|
|
2
2
|
import { NavigationPane } from './navigation-pane';
|
|
3
3
|
import { TextMarkupAnnotation } from '../annotation';
|
|
4
4
|
import { DrawingElement, PointModel, Matrix } from '@syncfusion/ej2-drawings';
|
|
@@ -76,6 +76,10 @@ export declare class PdfViewerBase {
|
|
|
76
76
|
* @private
|
|
77
77
|
*/
|
|
78
78
|
textLayer: TextLayer;
|
|
79
|
+
/**
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
taggedPdf: TaggedPDF;
|
|
79
83
|
private pdfViewer;
|
|
80
84
|
private unload;
|
|
81
85
|
/**
|
|
@@ -453,9 +457,6 @@ export declare class PdfViewerBase {
|
|
|
453
457
|
* @private
|
|
454
458
|
*/
|
|
455
459
|
zoomInterval: number;
|
|
456
|
-
/**
|
|
457
|
-
* @private
|
|
458
|
-
*/
|
|
459
460
|
/**
|
|
460
461
|
* EJ2CORE-813 - This flag is represent current device is 'iPad' or 'iPhone' or'iPod' device.
|
|
461
462
|
* @private
|
|
@@ -470,6 +471,8 @@ export declare class PdfViewerBase {
|
|
|
470
471
|
*/
|
|
471
472
|
previousContainerHeight: number;
|
|
472
473
|
private isGotoPageEnabled;
|
|
474
|
+
private taggedTextHandler;
|
|
475
|
+
private taggedCollection;
|
|
473
476
|
constructor(viewer: PdfViewer);
|
|
474
477
|
/**
|
|
475
478
|
* @private
|
|
@@ -693,6 +696,8 @@ export declare class PdfViewerBase {
|
|
|
693
696
|
*/
|
|
694
697
|
renderAnnotations(pageIndex: number): void;
|
|
695
698
|
private renderTextContent;
|
|
699
|
+
private renderTaggedTextContentsFromServer;
|
|
700
|
+
private createRequestForTaggedText;
|
|
696
701
|
private renderPageContainer;
|
|
697
702
|
private orderPageDivElements;
|
|
698
703
|
/**
|
|
@@ -35,7 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
};
|
|
36
36
|
import { createElement, Browser, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
37
37
|
import { Dialog, createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
|
|
38
|
-
import { TextLayer, ContextMenu, Signature } from '../index';
|
|
38
|
+
import { TextLayer, ContextMenu, Signature, TaggedPDF } from '../index';
|
|
39
39
|
import { NavigationPane } from './navigation-pane';
|
|
40
40
|
import { NumericTextBox } from '@syncfusion/ej2-inputs';
|
|
41
41
|
import { AjaxHandler } from '../index';
|
|
@@ -357,9 +357,6 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
357
357
|
*/
|
|
358
358
|
// eslint-disable-next-line
|
|
359
359
|
this.zoomInterval = 5;
|
|
360
|
-
/**
|
|
361
|
-
* @private
|
|
362
|
-
*/
|
|
363
360
|
/**
|
|
364
361
|
* EJ2CORE-813 - This flag is represent current device is 'iPad' or 'iPhone' or'iPod' device.
|
|
365
362
|
* @private
|
|
@@ -377,6 +374,8 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
377
374
|
// tslint:disable-next-line
|
|
378
375
|
this.previousContainerHeight = 0;
|
|
379
376
|
this.isGotoPageEnabled = false;
|
|
377
|
+
this.taggedTextHandler = null;
|
|
378
|
+
this.taggedCollection = [];
|
|
380
379
|
this.clearSessionStorage = function () {
|
|
381
380
|
var documentId = window.sessionStorage.getItem('hashId');
|
|
382
381
|
var documentLiveCount = window.sessionStorage.getItem('documentLiveCount');
|
|
@@ -1483,6 +1482,7 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
1483
1482
|
this.pdfViewer = viewer;
|
|
1484
1483
|
this.navigationPane = new NavigationPane(this.pdfViewer, this);
|
|
1485
1484
|
this.textLayer = new TextLayer(this.pdfViewer, this);
|
|
1485
|
+
this.taggedPdf = new TaggedPDF(this.pdfViewer, this);
|
|
1486
1486
|
this.signatureModule = new Signature(this.pdfViewer, this);
|
|
1487
1487
|
// tslint:disable-next-line:max-line-length
|
|
1488
1488
|
this.isWebkitMobile = /Chrome/.test(navigator.userAgent) || /Google Inc/.test(navigator.vendor) || (navigator.userAgent.indexOf('Safari') !== -1);
|
|
@@ -2313,6 +2313,9 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
2313
2313
|
if (this.renderedPagesList) {
|
|
2314
2314
|
this.renderedPagesList = [];
|
|
2315
2315
|
}
|
|
2316
|
+
if (this.taggedCollection) {
|
|
2317
|
+
this.taggedCollection = [];
|
|
2318
|
+
}
|
|
2316
2319
|
if (this.pageContainer) {
|
|
2317
2320
|
while (this.pageContainer.hasChildNodes()) {
|
|
2318
2321
|
this.pageContainer.removeChild(this.pageContainer.lastChild);
|
|
@@ -2959,7 +2962,7 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
2959
2962
|
if (this.isDeviceiOS) {
|
|
2960
2963
|
var obj = findActiveElement(event, this, this.pdfViewer);
|
|
2961
2964
|
// eslint-disable-next-line
|
|
2962
|
-
var isRemoveFocus_1 = !this.pdfViewer.annotation.freeTextAnnotationModule.isNewFreeTextAnnot && (obj && this.pdfViewer.selectedItems.annotations[0] ? obj.id !== this.pdfViewer.selectedItems.annotations[0].id : true) && document.activeElement.classList.contains('free-text-input') && this.isFreeTextAnnotation(this.pdfViewer.selectedItems.annotations);
|
|
2965
|
+
var isRemoveFocus_1 = (!isNullOrUndefined(this.pdfViewer.annotation) && !isNullOrUndefined(this.pdfViewer.annotation.freeTextAnnotationModule) && !this.pdfViewer.annotation.freeTextAnnotationModule.isNewFreeTextAnnot) && (obj && this.pdfViewer.selectedItems.annotations[0] ? obj.id !== this.pdfViewer.selectedItems.annotations[0].id : true) && document.activeElement.classList.contains('free-text-input') && this.isFreeTextAnnotation(this.pdfViewer.selectedItems.annotations);
|
|
2963
2966
|
if (!this.singleTapTimer) {
|
|
2964
2967
|
this.singleTapTimer = setTimeout(function () {
|
|
2965
2968
|
if (isRemoveFocus_1) {
|
|
@@ -2974,6 +2977,9 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
2974
2977
|
else {
|
|
2975
2978
|
if (this.pdfViewer.enablePinchZoom) {
|
|
2976
2979
|
this.tapCount++;
|
|
2980
|
+
if (this.tapCount > 2) {
|
|
2981
|
+
this.tapCount = 2;
|
|
2982
|
+
}
|
|
2977
2983
|
clearTimeout(this.singleTapTimer);
|
|
2978
2984
|
this.singleTapTimer = null;
|
|
2979
2985
|
this.onDoubleTap(touchPoints);
|
|
@@ -2991,6 +2997,9 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
2991
2997
|
else {
|
|
2992
2998
|
if (this.pdfViewer.enablePinchZoom) {
|
|
2993
2999
|
this.tapCount++;
|
|
3000
|
+
if (this.tapCount > 2) {
|
|
3001
|
+
this.tapCount = 2;
|
|
3002
|
+
}
|
|
2994
3003
|
clearTimeout(this.singleTapTimer);
|
|
2995
3004
|
this.singleTapTimer = null;
|
|
2996
3005
|
this.onDoubleTap(touchPoints);
|
|
@@ -3560,6 +3569,14 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
3560
3569
|
if (this.pdfViewer.textSelectionModule && !this.isTextSelectionDisabled) {
|
|
3561
3570
|
this.pdfViewer.textSelectionModule.applySelectionRangeOnScroll(pageIndex);
|
|
3562
3571
|
}
|
|
3572
|
+
if (this.pdfViewer.taggedPDFModule && this.pdfViewer.enableTaggedPDF) {
|
|
3573
|
+
if (this.taggedCollection[pageIndex.toString()]) {
|
|
3574
|
+
this.renderTaggedTextContentsFromServer(pageIndex, this.taggedCollection[pageIndex.toString()]);
|
|
3575
|
+
}
|
|
3576
|
+
else {
|
|
3577
|
+
this.createRequestForTaggedText(pageIndex);
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3563
3580
|
if (this.documentAnnotationCollections) {
|
|
3564
3581
|
var isAnnotationAdded = false;
|
|
3565
3582
|
for (var i = 0; i < this.annotationRenderredList.length; i++) {
|
|
@@ -3754,6 +3771,33 @@ var PdfViewerBase = /** @class */ (function () {
|
|
|
3754
3771
|
}
|
|
3755
3772
|
}
|
|
3756
3773
|
};
|
|
3774
|
+
PdfViewerBase.prototype.renderTaggedTextContentsFromServer = function (pageIndex, taggedTextResponse) {
|
|
3775
|
+
this.taggedPdf.renderTaggedTextContentsFromServer(pageIndex, taggedTextResponse);
|
|
3776
|
+
};
|
|
3777
|
+
PdfViewerBase.prototype.createRequestForTaggedText = function (pageIndex) {
|
|
3778
|
+
var jsonObject;
|
|
3779
|
+
var proxy = this;
|
|
3780
|
+
jsonObject = { action: 'RenderTaggedContent', elementId: this.pdfViewer.element.id, hashId: this.hashId, uniqueId: this.documentId, pageIndex: pageIndex };
|
|
3781
|
+
if (this.jsonDocumentId) {
|
|
3782
|
+
jsonObject.documentId = this.jsonDocumentId;
|
|
3783
|
+
}
|
|
3784
|
+
var url = this.pdfViewer.serviceUrl + '/' + "RenderTaggedContent";
|
|
3785
|
+
this.taggedTextHandler = new AjaxHandler(this.pdfViewer);
|
|
3786
|
+
this.taggedTextHandler.url = url;
|
|
3787
|
+
this.taggedTextHandler.mode = true;
|
|
3788
|
+
this.taggedTextHandler.responseType = 'text';
|
|
3789
|
+
this.taggedTextHandler.send(jsonObject);
|
|
3790
|
+
this.taggedTextHandler.onSuccess = function (result) {
|
|
3791
|
+
var data = JSON.parse(result.data);
|
|
3792
|
+
var pageData = data.filter(function (item) { return (item.PageNumber).toString() === pageIndex.toString(); });
|
|
3793
|
+
proxy.taggedCollection[pageIndex.toString()] = pageData;
|
|
3794
|
+
proxy.renderTaggedTextContentsFromServer(pageIndex, pageData);
|
|
3795
|
+
};
|
|
3796
|
+
this.taggedTextHandler.onFailure = function (result) {
|
|
3797
|
+
console.log("error");
|
|
3798
|
+
};
|
|
3799
|
+
};
|
|
3800
|
+
;
|
|
3757
3801
|
PdfViewerBase.prototype.renderPageContainer = function (pageNumber, pageWidth, pageHeight, topValue) {
|
|
3758
3802
|
// tslint:disable-next-line:max-line-length
|
|
3759
3803
|
var pageDiv = createElement('div', { id: this.pdfViewer.element.id + '_pageDiv_' + pageNumber, className: 'e-pv-page-div', attrs: { 'tabindex': '0' } });
|
|
@@ -33,6 +33,9 @@ var TextLayer = /** @class */ (function () {
|
|
|
33
33
|
textLayer = createElement('div', { id: this.pdfViewer.element.id + '_textLayer_' + pageNumber, className: 'e-pv-text-layer' });
|
|
34
34
|
textLayer.style.width = pageWidth + 'px';
|
|
35
35
|
textLayer.style.height = pageHeight + 'px';
|
|
36
|
+
if (this.pdfViewer.taggedPDFModule && this.pdfViewer.enableTaggedPDF) {
|
|
37
|
+
textLayer.setAttribute('aria-hidden', 'true');
|
|
38
|
+
}
|
|
36
39
|
pageDiv.appendChild(textLayer);
|
|
37
40
|
}
|
|
38
41
|
this.pdfViewerBase.applyElementStyles(textLayer, pageNumber);
|
package/src/pdfviewer/index.d.ts
CHANGED
package/src/pdfviewer/index.js
CHANGED
|
@@ -1065,6 +1065,7 @@ var Magnification = /** @class */ (function () {
|
|
|
1065
1065
|
* @private
|
|
1066
1066
|
*/
|
|
1067
1067
|
Magnification.prototype.onDoubleTapMagnification = function () {
|
|
1068
|
+
var _this = this;
|
|
1068
1069
|
if (this.pdfViewer.toolbarModule) {
|
|
1069
1070
|
this.pdfViewer.toolbarModule.showToolbar(false);
|
|
1070
1071
|
}
|
|
@@ -1084,6 +1085,7 @@ var Magnification = /** @class */ (function () {
|
|
|
1084
1085
|
}
|
|
1085
1086
|
this.calculateScrollValues(scrollValue);
|
|
1086
1087
|
this.isTapToFitZoom = !this.isTapToFitZoom;
|
|
1088
|
+
setTimeout(function () { _this.isMagnified = false; }, 500);
|
|
1087
1089
|
this.isDoubleTapZoom = false;
|
|
1088
1090
|
}
|
|
1089
1091
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, INotifyPropertyChanged, NotifyPropertyChanges, ChildProperty, L10n, Collection, Complex } from '@syncfusion/ej2-base';
|
|
1
|
+
import { Component, INotifyPropertyChanged, NotifyPropertyChanges, ChildProperty, L10n, Collection, Complex } from '@syncfusion/ej2-base';
|
|
2
2
|
import {IAjaxHeaders} from "./pdfviewer";
|
|
3
3
|
import {ComponentModel} from '@syncfusion/ej2-base';
|
|
4
4
|
|
|
@@ -2024,7 +2024,7 @@ export interface PdfViewerModel extends ComponentModel{
|
|
|
2024
2024
|
retryStatusCodes?: number[];
|
|
2025
2025
|
|
|
2026
2026
|
/**
|
|
2027
|
-
*
|
|
2027
|
+
* Gets or sets the timeout for retries in seconds.
|
|
2028
2028
|
*
|
|
2029
2029
|
* @default 0
|
|
2030
2030
|
*/
|
|
@@ -2036,6 +2036,12 @@ export interface PdfViewerModel extends ComponentModel{
|
|
|
2036
2036
|
*/
|
|
2037
2037
|
isExtractText?: boolean;
|
|
2038
2038
|
|
|
2039
|
+
/**
|
|
2040
|
+
*
|
|
2041
|
+
* @default true
|
|
2042
|
+
*/
|
|
2043
|
+
enableTaggedPDF?: boolean;
|
|
2044
|
+
|
|
2039
2045
|
/**
|
|
2040
2046
|
* Defines the settings of the PdfViewer toolbar.
|
|
2041
2047
|
*/
|
|
@@ -17,6 +17,7 @@ import { TextSelection } from './index';
|
|
|
17
17
|
import { TextSearch } from './index';
|
|
18
18
|
import { FormFields } from './index';
|
|
19
19
|
import { Print, CalibrationUnit } from './index';
|
|
20
|
+
import { TaggedPDF } from './index';
|
|
20
21
|
import { UnloadEventArgs, LoadEventArgs, LoadFailedEventArgs, AjaxRequestFailureEventArgs, PageChangeEventArgs, PageClickEventArgs, ZoomChangeEventArgs, HyperlinkClickEventArgs, HyperlinkMouseOverArgs, ImportStartEventArgs, ImportSuccessEventArgs, ImportFailureEventArgs, ExportStartEventArgs, ExportSuccessEventArgs, ExportFailureEventArgs, AjaxRequestInitiateEventArgs, BeforeRenderPdfPageEventArgs, AjaxRequestSuccessEventArgs } from './index';
|
|
21
22
|
import { AnnotationAddEventArgs, AnnotationRemoveEventArgs, AnnotationPropertiesChangeEventArgs, AnnotationResizeEventArgs, AnnotationSelectEventArgs, AnnotationMoveEventArgs, AnnotationDoubleClickEventArgs, AnnotationMouseoverEventArgs, PageMouseoverEventArgs } from './index';
|
|
22
23
|
import { TextSelectionStartEventArgs, TextSelectionEndEventArgs, DownloadStartEventArgs, DownloadEndEventArgs, ExtractTextCompletedEventArgs } from './index';
|
|
@@ -1686,7 +1687,7 @@ export declare class PdfViewer extends Component<HTMLElement> implements INotify
|
|
|
1686
1687
|
*/
|
|
1687
1688
|
retryStatusCodes: number[];
|
|
1688
1689
|
/**
|
|
1689
|
-
*
|
|
1690
|
+
* Gets or sets the timeout for retries in seconds.
|
|
1690
1691
|
*
|
|
1691
1692
|
* @default 0
|
|
1692
1693
|
*/
|
|
@@ -1696,6 +1697,11 @@ export declare class PdfViewer extends Component<HTMLElement> implements INotify
|
|
|
1696
1697
|
* @default false
|
|
1697
1698
|
*/
|
|
1698
1699
|
isExtractText: boolean;
|
|
1700
|
+
/**
|
|
1701
|
+
*
|
|
1702
|
+
* @default true
|
|
1703
|
+
*/
|
|
1704
|
+
enableTaggedPDF: boolean;
|
|
1699
1705
|
/**
|
|
1700
1706
|
* Defines the settings of the PdfViewer toolbar.
|
|
1701
1707
|
*/
|
|
@@ -1884,6 +1890,10 @@ export declare class PdfViewer extends Component<HTMLElement> implements INotify
|
|
|
1884
1890
|
* @private
|
|
1885
1891
|
*/
|
|
1886
1892
|
textSearchModule: TextSearch;
|
|
1893
|
+
/**
|
|
1894
|
+
* @private
|
|
1895
|
+
*/
|
|
1896
|
+
taggedPDFModule: TaggedPDF;
|
|
1887
1897
|
/**
|
|
1888
1898
|
* @private
|
|
1889
1899
|
*/
|
|
@@ -1931,6 +1941,14 @@ export declare class PdfViewer extends Component<HTMLElement> implements INotify
|
|
|
1931
1941
|
* @returns { TextSearch }
|
|
1932
1942
|
*/
|
|
1933
1943
|
readonly textSearch: TextSearch;
|
|
1944
|
+
/**
|
|
1945
|
+
* Gets the tagged layer object of the pdf viewer.
|
|
1946
|
+
*
|
|
1947
|
+
* @asptype TaggedPDF
|
|
1948
|
+
* @blazorType TaggedPDF
|
|
1949
|
+
* @returns { TaggedPDF }
|
|
1950
|
+
*/
|
|
1951
|
+
readonly taggedPdf: TaggedPDF;
|
|
1934
1952
|
/**
|
|
1935
1953
|
* Gets the toolbar object of the pdf viewer.
|
|
1936
1954
|
* @asptype Toolbar
|
|
@@ -1587,6 +1587,20 @@ var PdfViewer = /** @class */ (function (_super) {
|
|
|
1587
1587
|
enumerable: true,
|
|
1588
1588
|
configurable: true
|
|
1589
1589
|
});
|
|
1590
|
+
Object.defineProperty(PdfViewer.prototype, "taggedPdf", {
|
|
1591
|
+
/**
|
|
1592
|
+
* Gets the tagged layer object of the pdf viewer.
|
|
1593
|
+
*
|
|
1594
|
+
* @asptype TaggedPDF
|
|
1595
|
+
* @blazorType TaggedPDF
|
|
1596
|
+
* @returns { TaggedPDF }
|
|
1597
|
+
*/
|
|
1598
|
+
get: function () {
|
|
1599
|
+
return this.taggedPDFModule;
|
|
1600
|
+
},
|
|
1601
|
+
enumerable: true,
|
|
1602
|
+
configurable: true
|
|
1603
|
+
});
|
|
1590
1604
|
Object.defineProperty(PdfViewer.prototype, "toolbar", {
|
|
1591
1605
|
/**
|
|
1592
1606
|
* Gets the toolbar object of the pdf viewer.
|
|
@@ -1821,6 +1835,11 @@ var PdfViewer = /** @class */ (function (_super) {
|
|
|
1821
1835
|
member: 'FormFields', args: [this, this.viewerBase]
|
|
1822
1836
|
});
|
|
1823
1837
|
}
|
|
1838
|
+
if (this.enableTaggedPDF) {
|
|
1839
|
+
modules.push({
|
|
1840
|
+
member: 'TaggedPDF', args: [this, this.viewerBase]
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1824
1843
|
return modules;
|
|
1825
1844
|
};
|
|
1826
1845
|
/**
|
|
@@ -2681,6 +2700,9 @@ var PdfViewer = /** @class */ (function (_super) {
|
|
|
2681
2700
|
__decorate([
|
|
2682
2701
|
Property(false)
|
|
2683
2702
|
], PdfViewer.prototype, "isExtractText", void 0);
|
|
2703
|
+
__decorate([
|
|
2704
|
+
Property(true)
|
|
2705
|
+
], PdfViewer.prototype, "enableTaggedPDF", void 0);
|
|
2684
2706
|
__decorate([
|
|
2685
2707
|
Property({ showTooltip: true, toolbarItems: ['OpenOption', 'UndoRedoTool', 'PageNavigationTool', 'MagnificationTool', 'PanTool', 'SelectionTool', 'CommentTool', 'AnnotationEditTool', 'FreeTextAnnotationOption', 'InkAnnotationOption', 'ShapeAnnotationOption', 'StampAnnotation', 'SignatureOption', 'SearchOption', 'PrintOption', 'DownloadOption'] })
|
|
2686
2708
|
], PdfViewer.prototype, "toolbarSettings", void 0);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PdfViewer, PdfViewerBase } from '../index';
|
|
2
|
+
/**
|
|
3
|
+
* Tagged PDF module is used to handle tagged pdf document
|
|
4
|
+
*
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export declare class TaggedPDF {
|
|
8
|
+
private pdfViewer;
|
|
9
|
+
private pdfViewerBase;
|
|
10
|
+
/**
|
|
11
|
+
* @param {PdfViewer} pdfViewer - The PdfViewer.
|
|
12
|
+
* @param {PdfViewerBase} pdfViewerBase - The PdfViewerBase.
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
constructor(pdfViewer: PdfViewer, pdfViewerBase: PdfViewerBase);
|
|
16
|
+
addTaggedLayer(pageIndex: number): HTMLElement;
|
|
17
|
+
renderTaggedTextContentsFromServer(pageIndex: number, taggedTextResponse: any): void;
|
|
18
|
+
private createTag;
|
|
19
|
+
private getTag;
|
|
20
|
+
private setStyleToTaggedTextDiv;
|
|
21
|
+
private setTextElementProperties;
|
|
22
|
+
/**
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
getModuleName(): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { createElement } from '@syncfusion/ej2-base';
|
|
2
|
+
/**
|
|
3
|
+
* Tagged PDF module is used to handle tagged pdf document
|
|
4
|
+
*
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
var TaggedPDF = /** @class */ (function () {
|
|
8
|
+
/**
|
|
9
|
+
* @param {PdfViewer} pdfViewer - The PdfViewer.
|
|
10
|
+
* @param {PdfViewerBase} pdfViewerBase - The PdfViewerBase.
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
function TaggedPDF(pdfViewer, pdfViewerBase) {
|
|
14
|
+
this.createTag = function (taggedTextResponse) {
|
|
15
|
+
var _this = this;
|
|
16
|
+
var tagType = taggedTextResponse.TagType;
|
|
17
|
+
var parentTagType = taggedTextResponse.ParentTagType;
|
|
18
|
+
var text = taggedTextResponse.Text;
|
|
19
|
+
var altText = taggedTextResponse.AltText;
|
|
20
|
+
var bounds = taggedTextResponse.Bounds;
|
|
21
|
+
var childTags = taggedTextResponse.ChildElements;
|
|
22
|
+
var textTag = document.createElement(this.getTag(tagType));
|
|
23
|
+
textTag.style = "padding:0px;margin:0px";
|
|
24
|
+
if (parentTagType != "Document" && parentTagType != "Part") {
|
|
25
|
+
textTag.style.position = 'absolute';
|
|
26
|
+
}
|
|
27
|
+
if (bounds) {
|
|
28
|
+
this.setStyleToTaggedTextDiv(textTag, bounds);
|
|
29
|
+
this.setTextElementProperties(textTag);
|
|
30
|
+
}
|
|
31
|
+
if (text.trim() != "") {
|
|
32
|
+
textTag.innerText = text;
|
|
33
|
+
}
|
|
34
|
+
if (altText && altText.trim() !== "" && (tagType === "Image" || tagType === "Figure")) {
|
|
35
|
+
textTag.alt = altText;
|
|
36
|
+
textTag.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=";
|
|
37
|
+
}
|
|
38
|
+
if (childTags && childTags.length > 0) {
|
|
39
|
+
childTags.forEach(function (element) {
|
|
40
|
+
if (tagType === "Table") {
|
|
41
|
+
element.ChildElements.forEach(function (newelement) {
|
|
42
|
+
textTag.appendChild(_this.createTag(newelement));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
textTag.appendChild(_this.createTag(element));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return textTag;
|
|
51
|
+
};
|
|
52
|
+
this.pdfViewer = pdfViewer;
|
|
53
|
+
this.pdfViewerBase = pdfViewerBase;
|
|
54
|
+
}
|
|
55
|
+
TaggedPDF.prototype.addTaggedLayer = function (pageIndex) {
|
|
56
|
+
var taggedLayer;
|
|
57
|
+
if (this.pdfViewer.enableTaggedPDF) {
|
|
58
|
+
var pageDiv = document.getElementById(this.pdfViewer.element.id + '_pageDiv_' + pageIndex);
|
|
59
|
+
taggedLayer = document.getElementById(this.pdfViewer.element.id + '_taggedLayer_' + pageIndex);
|
|
60
|
+
if (!taggedLayer) {
|
|
61
|
+
taggedLayer = createElement('div', { id: this.pdfViewer.element.id + '_taggedLayer_' + pageIndex, className: 'e-pv-tagged-layer e-pv-text-layer' });
|
|
62
|
+
}
|
|
63
|
+
taggedLayer.innerHTML = "";
|
|
64
|
+
taggedLayer.style.width = this.pdfViewerBase.pageSize[parseInt(pageIndex.toString(), 10)].width * this.pdfViewerBase.getZoomFactor() + 'px';
|
|
65
|
+
taggedLayer.style.height = this.pdfViewerBase.pageSize[parseInt(pageIndex.toString(), 10)].height * this.pdfViewerBase.getZoomFactor() + 'px';
|
|
66
|
+
taggedLayer.style.pointerEvents = "none";
|
|
67
|
+
if (pageDiv) {
|
|
68
|
+
pageDiv.appendChild(taggedLayer);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return taggedLayer;
|
|
72
|
+
};
|
|
73
|
+
TaggedPDF.prototype.renderTaggedTextContentsFromServer = function (pageIndex, taggedTextResponse) {
|
|
74
|
+
var taggedLayer = this.addTaggedLayer(pageIndex);
|
|
75
|
+
for (var i = 0; i < taggedTextResponse.length; i++) {
|
|
76
|
+
var textDiv = createElement('div', { id: this.pdfViewer.element.id + '_taggedText_' + pageIndex + '_' + i, className: 'e-pv-text', attrs: { 'tabindex': '-1' } });
|
|
77
|
+
var bounds = taggedTextResponse[i].Bounds;
|
|
78
|
+
if (taggedTextResponse[i].TagType === "Paragraph" && taggedTextResponse[i].ChildElements === null && taggedTextResponse[i].Text.trim() === "") {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
textDiv.appendChild(this.createTag(taggedTextResponse[i]));
|
|
83
|
+
}
|
|
84
|
+
textDiv.style.display = "inline";
|
|
85
|
+
this.setStyleToTaggedTextDiv(textDiv, bounds);
|
|
86
|
+
this.setTextElementProperties(textDiv);
|
|
87
|
+
taggedLayer.appendChild(textDiv);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
TaggedPDF.prototype.getTag = function (tagType) {
|
|
91
|
+
switch (tagType) {
|
|
92
|
+
case "Paragraph":
|
|
93
|
+
return "p";
|
|
94
|
+
case "Figure":
|
|
95
|
+
return "img";
|
|
96
|
+
case "Article":
|
|
97
|
+
return "art";
|
|
98
|
+
case "Annotation":
|
|
99
|
+
return "annot";
|
|
100
|
+
case "BibliographyEntry":
|
|
101
|
+
return "bibentry";
|
|
102
|
+
case "BlockQuotation":
|
|
103
|
+
return "blockQuote";
|
|
104
|
+
case "Caption":
|
|
105
|
+
return "caption";
|
|
106
|
+
case "Code":
|
|
107
|
+
return "code";
|
|
108
|
+
case "Division":
|
|
109
|
+
return "div";
|
|
110
|
+
case "Document":
|
|
111
|
+
return "document";
|
|
112
|
+
case "Form":
|
|
113
|
+
return "form";
|
|
114
|
+
case "Formula":
|
|
115
|
+
return "formula";
|
|
116
|
+
case "Index":
|
|
117
|
+
return "index";
|
|
118
|
+
case "Heading":
|
|
119
|
+
return "h";
|
|
120
|
+
case "HeadingLevel1":
|
|
121
|
+
return "h1";
|
|
122
|
+
case "HeadingLevel2":
|
|
123
|
+
return "h2";
|
|
124
|
+
case "HeadingLevel3":
|
|
125
|
+
return "h3";
|
|
126
|
+
case "HeadingLevel4":
|
|
127
|
+
return "h4";
|
|
128
|
+
case "HeadingLevel5":
|
|
129
|
+
return "h5";
|
|
130
|
+
case "HeadingLevel6":
|
|
131
|
+
return "h6";
|
|
132
|
+
case "Label":
|
|
133
|
+
return "label";
|
|
134
|
+
case "Link":
|
|
135
|
+
return "a";
|
|
136
|
+
case "List":
|
|
137
|
+
return "ul";
|
|
138
|
+
case "ListItem":
|
|
139
|
+
return "li";
|
|
140
|
+
case "ListBody":
|
|
141
|
+
return "p";
|
|
142
|
+
case "Note":
|
|
143
|
+
return "note";
|
|
144
|
+
case "Part":
|
|
145
|
+
return "part";
|
|
146
|
+
case "Quotation":
|
|
147
|
+
return "quote";
|
|
148
|
+
case "Reference":
|
|
149
|
+
return "reference";
|
|
150
|
+
case "Section":
|
|
151
|
+
return "sect";
|
|
152
|
+
case "Span":
|
|
153
|
+
return "span";
|
|
154
|
+
case "Table":
|
|
155
|
+
return "table";
|
|
156
|
+
case "TableDataCell":
|
|
157
|
+
return "td";
|
|
158
|
+
case "TableHeader":
|
|
159
|
+
return "th";
|
|
160
|
+
case "TableOfContent":
|
|
161
|
+
return "toc";
|
|
162
|
+
case "TableOfContentItem":
|
|
163
|
+
return "toci";
|
|
164
|
+
case "TableRow":
|
|
165
|
+
return "tr";
|
|
166
|
+
case "Image":
|
|
167
|
+
return "img";
|
|
168
|
+
default:
|
|
169
|
+
return "p";
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
;
|
|
173
|
+
TaggedPDF.prototype.setStyleToTaggedTextDiv = function (textDiv, bounds) {
|
|
174
|
+
textDiv.style.left = bounds.X * (96 / 72) * this.pdfViewerBase.getZoomFactor() + 'px';
|
|
175
|
+
textDiv.style.top = bounds.Y * (96 / 72) * this.pdfViewerBase.getZoomFactor() + 'px';
|
|
176
|
+
textDiv.style.width = bounds.Width * (96 / 72) * this.pdfViewerBase.getZoomFactor() + 'px';
|
|
177
|
+
var textHeight = bounds.Height * (96 / 72) * this.pdfViewerBase.getZoomFactor();
|
|
178
|
+
textDiv.style.height = textHeight + 'px';
|
|
179
|
+
textDiv.style.fontSize = 16 * this.pdfViewerBase.getZoomFactor() + 'px';
|
|
180
|
+
textDiv.style.color = 'transparent';
|
|
181
|
+
};
|
|
182
|
+
;
|
|
183
|
+
TaggedPDF.prototype.setTextElementProperties = function (textDiv) {
|
|
184
|
+
textDiv.style.fontFamily = 'serif';
|
|
185
|
+
textDiv.style.transformOrigin = '0%';
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* @private
|
|
189
|
+
*/
|
|
190
|
+
TaggedPDF.prototype.getModuleName = function () {
|
|
191
|
+
return 'TaggedPDF';
|
|
192
|
+
};
|
|
193
|
+
return TaggedPDF;
|
|
194
|
+
}());
|
|
195
|
+
export { TaggedPDF };
|