@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.
@@ -17807,9 +17807,6 @@ class PdfViewerBase {
17807
17807
  */
17808
17808
  // eslint-disable-next-line
17809
17809
  this.zoomInterval = 5;
17810
- /**
17811
- * @private
17812
- */
17813
17810
  /**
17814
17811
  * EJ2CORE-813 - This flag is represent current device is 'iPad' or 'iPhone' or'iPod' device.
17815
17812
  * @private
@@ -17827,6 +17824,8 @@ class PdfViewerBase {
17827
17824
  // tslint:disable-next-line
17828
17825
  this.previousContainerHeight = 0;
17829
17826
  this.isGotoPageEnabled = false;
17827
+ this.taggedTextHandler = null;
17828
+ this.taggedCollection = [];
17830
17829
  this.clearSessionStorage = () => {
17831
17830
  let documentId = window.sessionStorage.getItem('hashId');
17832
17831
  let documentLiveCount = window.sessionStorage.getItem('documentLiveCount');
@@ -18931,6 +18930,7 @@ class PdfViewerBase {
18931
18930
  this.pdfViewer = viewer;
18932
18931
  this.navigationPane = new NavigationPane(this.pdfViewer, this);
18933
18932
  this.textLayer = new TextLayer(this.pdfViewer, this);
18933
+ this.taggedPdf = new TaggedPDF(this.pdfViewer, this);
18934
18934
  this.signatureModule = new Signature(this.pdfViewer, this);
18935
18935
  // tslint:disable-next-line:max-line-length
18936
18936
  this.isWebkitMobile = /Chrome/.test(navigator.userAgent) || /Google Inc/.test(navigator.vendor) || (navigator.userAgent.indexOf('Safari') !== -1);
@@ -19756,6 +19756,9 @@ class PdfViewerBase {
19756
19756
  if (this.renderedPagesList) {
19757
19757
  this.renderedPagesList = [];
19758
19758
  }
19759
+ if (this.taggedCollection) {
19760
+ this.taggedCollection = [];
19761
+ }
19759
19762
  if (this.pageContainer) {
19760
19763
  while (this.pageContainer.hasChildNodes()) {
19761
19764
  this.pageContainer.removeChild(this.pageContainer.lastChild);
@@ -20397,7 +20400,7 @@ class PdfViewerBase {
20397
20400
  if (this.isDeviceiOS) {
20398
20401
  const obj = findActiveElement(event, this, this.pdfViewer);
20399
20402
  // eslint-disable-next-line
20400
- let isRemoveFocus = !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);
20403
+ let isRemoveFocus = (!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);
20401
20404
  if (!this.singleTapTimer) {
20402
20405
  this.singleTapTimer = setTimeout(() => {
20403
20406
  if (isRemoveFocus) {
@@ -20412,6 +20415,9 @@ class PdfViewerBase {
20412
20415
  else {
20413
20416
  if (this.pdfViewer.enablePinchZoom) {
20414
20417
  this.tapCount++;
20418
+ if (this.tapCount > 2) {
20419
+ this.tapCount = 2;
20420
+ }
20415
20421
  clearTimeout(this.singleTapTimer);
20416
20422
  this.singleTapTimer = null;
20417
20423
  this.onDoubleTap(touchPoints);
@@ -20429,6 +20435,9 @@ class PdfViewerBase {
20429
20435
  else {
20430
20436
  if (this.pdfViewer.enablePinchZoom) {
20431
20437
  this.tapCount++;
20438
+ if (this.tapCount > 2) {
20439
+ this.tapCount = 2;
20440
+ }
20432
20441
  clearTimeout(this.singleTapTimer);
20433
20442
  this.singleTapTimer = null;
20434
20443
  this.onDoubleTap(touchPoints);
@@ -20990,6 +20999,14 @@ class PdfViewerBase {
20990
20999
  if (this.pdfViewer.textSelectionModule && !this.isTextSelectionDisabled) {
20991
21000
  this.pdfViewer.textSelectionModule.applySelectionRangeOnScroll(pageIndex);
20992
21001
  }
21002
+ if (this.pdfViewer.taggedPDFModule && this.pdfViewer.enableTaggedPDF) {
21003
+ if (this.taggedCollection[pageIndex.toString()]) {
21004
+ this.renderTaggedTextContentsFromServer(pageIndex, this.taggedCollection[pageIndex.toString()]);
21005
+ }
21006
+ else {
21007
+ this.createRequestForTaggedText(pageIndex);
21008
+ }
21009
+ }
20993
21010
  if (this.documentAnnotationCollections) {
20994
21011
  let isAnnotationAdded = false;
20995
21012
  for (let i = 0; i < this.annotationRenderredList.length; i++) {
@@ -21184,6 +21201,33 @@ class PdfViewerBase {
21184
21201
  }
21185
21202
  }
21186
21203
  }
21204
+ renderTaggedTextContentsFromServer(pageIndex, taggedTextResponse) {
21205
+ this.taggedPdf.renderTaggedTextContentsFromServer(pageIndex, taggedTextResponse);
21206
+ }
21207
+ createRequestForTaggedText(pageIndex) {
21208
+ let jsonObject;
21209
+ let proxy = this;
21210
+ jsonObject = { action: 'RenderTaggedContent', elementId: this.pdfViewer.element.id, hashId: this.hashId, uniqueId: this.documentId, pageIndex: pageIndex };
21211
+ if (this.jsonDocumentId) {
21212
+ jsonObject.documentId = this.jsonDocumentId;
21213
+ }
21214
+ var url = this.pdfViewer.serviceUrl + '/' + "RenderTaggedContent";
21215
+ this.taggedTextHandler = new AjaxHandler(this.pdfViewer);
21216
+ this.taggedTextHandler.url = url;
21217
+ this.taggedTextHandler.mode = true;
21218
+ this.taggedTextHandler.responseType = 'text';
21219
+ this.taggedTextHandler.send(jsonObject);
21220
+ this.taggedTextHandler.onSuccess = function (result) {
21221
+ var data = JSON.parse(result.data);
21222
+ let pageData = data.filter((item) => (item.PageNumber).toString() === pageIndex.toString());
21223
+ proxy.taggedCollection[pageIndex.toString()] = pageData;
21224
+ proxy.renderTaggedTextContentsFromServer(pageIndex, pageData);
21225
+ };
21226
+ this.taggedTextHandler.onFailure = function (result) {
21227
+ console.log("error");
21228
+ };
21229
+ }
21230
+ ;
21187
21231
  renderPageContainer(pageNumber, pageWidth, pageHeight, topValue) {
21188
21232
  // tslint:disable-next-line:max-line-length
21189
21233
  let pageDiv = createElement('div', { id: this.pdfViewer.element.id + '_pageDiv_' + pageNumber, className: 'e-pv-page-div', attrs: { 'tabindex': '0' } });
@@ -24475,6 +24519,9 @@ class TextLayer {
24475
24519
  textLayer = createElement('div', { id: this.pdfViewer.element.id + '_textLayer_' + pageNumber, className: 'e-pv-text-layer' });
24476
24520
  textLayer.style.width = pageWidth + 'px';
24477
24521
  textLayer.style.height = pageHeight + 'px';
24522
+ if (this.pdfViewer.taggedPDFModule && this.pdfViewer.enableTaggedPDF) {
24523
+ textLayer.setAttribute('aria-hidden', 'true');
24524
+ }
24478
24525
  pageDiv.appendChild(textLayer);
24479
24526
  }
24480
24527
  this.pdfViewerBase.applyElementStyles(textLayer, pageNumber);
@@ -27224,6 +27271,7 @@ class Magnification {
27224
27271
  }
27225
27272
  this.calculateScrollValues(scrollValue);
27226
27273
  this.isTapToFitZoom = !this.isTapToFitZoom;
27274
+ setTimeout(() => { this.isMagnified = false; }, 500);
27227
27275
  this.isDoubleTapZoom = false;
27228
27276
  }
27229
27277
  }
@@ -35676,6 +35724,16 @@ let PdfViewer = class PdfViewer extends Component {
35676
35724
  get textSearch() {
35677
35725
  return this.textSearchModule;
35678
35726
  }
35727
+ /**
35728
+ * Gets the tagged layer object of the pdf viewer.
35729
+ *
35730
+ * @asptype TaggedPDF
35731
+ * @blazorType TaggedPDF
35732
+ * @returns { TaggedPDF }
35733
+ */
35734
+ get taggedPdf() {
35735
+ return this.taggedPDFModule;
35736
+ }
35679
35737
  /**
35680
35738
  * Gets the toolbar object of the pdf viewer.
35681
35739
  * @asptype Toolbar
@@ -35892,6 +35950,11 @@ let PdfViewer = class PdfViewer extends Component {
35892
35950
  member: 'FormFields', args: [this, this.viewerBase]
35893
35951
  });
35894
35952
  }
35953
+ if (this.enableTaggedPDF) {
35954
+ modules.push({
35955
+ member: 'TaggedPDF', args: [this, this.viewerBase]
35956
+ });
35957
+ }
35895
35958
  return modules;
35896
35959
  }
35897
35960
  /**
@@ -36749,6 +36812,9 @@ __decorate$2([
36749
36812
  __decorate$2([
36750
36813
  Property(false)
36751
36814
  ], PdfViewer.prototype, "isExtractText", void 0);
36815
+ __decorate$2([
36816
+ Property(true)
36817
+ ], PdfViewer.prototype, "enableTaggedPDF", void 0);
36752
36818
  __decorate$2([
36753
36819
  Property({ showTooltip: true, toolbarItems: ['OpenOption', 'UndoRedoTool', 'PageNavigationTool', 'MagnificationTool', 'PanTool', 'SelectionTool', 'CommentTool', 'AnnotationEditTool', 'FreeTextAnnotationOption', 'InkAnnotationOption', 'ShapeAnnotationOption', 'StampAnnotation', 'SignatureOption', 'SearchOption', 'PrintOption', 'DownloadOption'] })
36754
36820
  ], PdfViewer.prototype, "toolbarSettings", void 0);
@@ -41592,6 +41658,202 @@ class FormFields {
41592
41658
  }
41593
41659
  }
41594
41660
 
41661
+ /**
41662
+ * export types
41663
+ */
41664
+
41665
+ /**
41666
+ * Tagged PDF module is used to handle tagged pdf document
41667
+ *
41668
+ * @hidden
41669
+ */
41670
+ class TaggedPDF {
41671
+ /**
41672
+ * @param {PdfViewer} pdfViewer - The PdfViewer.
41673
+ * @param {PdfViewerBase} pdfViewerBase - The PdfViewerBase.
41674
+ * @private
41675
+ */
41676
+ constructor(pdfViewer, pdfViewerBase) {
41677
+ this.createTag = function (taggedTextResponse) {
41678
+ let tagType = taggedTextResponse.TagType;
41679
+ let parentTagType = taggedTextResponse.ParentTagType;
41680
+ let text = taggedTextResponse.Text;
41681
+ let altText = taggedTextResponse.AltText;
41682
+ let bounds = taggedTextResponse.Bounds;
41683
+ let childTags = taggedTextResponse.ChildElements;
41684
+ let textTag = document.createElement(this.getTag(tagType));
41685
+ textTag.style = "padding:0px;margin:0px";
41686
+ if (parentTagType != "Document" && parentTagType != "Part") {
41687
+ textTag.style.position = 'absolute';
41688
+ }
41689
+ if (bounds) {
41690
+ this.setStyleToTaggedTextDiv(textTag, bounds);
41691
+ this.setTextElementProperties(textTag);
41692
+ }
41693
+ if (text.trim() != "") {
41694
+ textTag.innerText = text;
41695
+ }
41696
+ if (altText && altText.trim() !== "" && (tagType === "Image" || tagType === "Figure")) {
41697
+ textTag.alt = altText;
41698
+ textTag.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=";
41699
+ }
41700
+ if (childTags && childTags.length > 0) {
41701
+ childTags.forEach((element) => {
41702
+ if (tagType === "Table") {
41703
+ element.ChildElements.forEach((newelement) => {
41704
+ textTag.appendChild(this.createTag(newelement));
41705
+ });
41706
+ }
41707
+ else {
41708
+ textTag.appendChild(this.createTag(element));
41709
+ }
41710
+ });
41711
+ }
41712
+ return textTag;
41713
+ };
41714
+ this.pdfViewer = pdfViewer;
41715
+ this.pdfViewerBase = pdfViewerBase;
41716
+ }
41717
+ addTaggedLayer(pageIndex) {
41718
+ let taggedLayer;
41719
+ if (this.pdfViewer.enableTaggedPDF) {
41720
+ let pageDiv = document.getElementById(this.pdfViewer.element.id + '_pageDiv_' + pageIndex);
41721
+ taggedLayer = document.getElementById(this.pdfViewer.element.id + '_taggedLayer_' + pageIndex);
41722
+ if (!taggedLayer) {
41723
+ taggedLayer = createElement('div', { id: this.pdfViewer.element.id + '_taggedLayer_' + pageIndex, className: 'e-pv-tagged-layer e-pv-text-layer' });
41724
+ }
41725
+ taggedLayer.innerHTML = "";
41726
+ taggedLayer.style.width = this.pdfViewerBase.pageSize[parseInt(pageIndex.toString(), 10)].width * this.pdfViewerBase.getZoomFactor() + 'px';
41727
+ taggedLayer.style.height = this.pdfViewerBase.pageSize[parseInt(pageIndex.toString(), 10)].height * this.pdfViewerBase.getZoomFactor() + 'px';
41728
+ taggedLayer.style.pointerEvents = "none";
41729
+ if (pageDiv) {
41730
+ pageDiv.appendChild(taggedLayer);
41731
+ }
41732
+ }
41733
+ return taggedLayer;
41734
+ }
41735
+ renderTaggedTextContentsFromServer(pageIndex, taggedTextResponse) {
41736
+ let taggedLayer = this.addTaggedLayer(pageIndex);
41737
+ for (let i = 0; i < taggedTextResponse.length; i++) {
41738
+ var textDiv = createElement('div', { id: this.pdfViewer.element.id + '_taggedText_' + pageIndex + '_' + i, className: 'e-pv-text', attrs: { 'tabindex': '-1' } });
41739
+ let bounds = taggedTextResponse[i].Bounds;
41740
+ if (taggedTextResponse[i].TagType === "Paragraph" && taggedTextResponse[i].ChildElements === null && taggedTextResponse[i].Text.trim() === "") {
41741
+ continue;
41742
+ }
41743
+ else {
41744
+ textDiv.appendChild(this.createTag(taggedTextResponse[i]));
41745
+ }
41746
+ textDiv.style.display = "inline";
41747
+ this.setStyleToTaggedTextDiv(textDiv, bounds);
41748
+ this.setTextElementProperties(textDiv);
41749
+ taggedLayer.appendChild(textDiv);
41750
+ }
41751
+ }
41752
+ getTag(tagType) {
41753
+ switch (tagType) {
41754
+ case "Paragraph":
41755
+ return "p";
41756
+ case "Figure":
41757
+ return "img";
41758
+ case "Article":
41759
+ return "art";
41760
+ case "Annotation":
41761
+ return "annot";
41762
+ case "BibliographyEntry":
41763
+ return "bibentry";
41764
+ case "BlockQuotation":
41765
+ return "blockQuote";
41766
+ case "Caption":
41767
+ return "caption";
41768
+ case "Code":
41769
+ return "code";
41770
+ case "Division":
41771
+ return "div";
41772
+ case "Document":
41773
+ return "document";
41774
+ case "Form":
41775
+ return "form";
41776
+ case "Formula":
41777
+ return "formula";
41778
+ case "Index":
41779
+ return "index";
41780
+ case "Heading":
41781
+ return "h";
41782
+ case "HeadingLevel1":
41783
+ return "h1";
41784
+ case "HeadingLevel2":
41785
+ return "h2";
41786
+ case "HeadingLevel3":
41787
+ return "h3";
41788
+ case "HeadingLevel4":
41789
+ return "h4";
41790
+ case "HeadingLevel5":
41791
+ return "h5";
41792
+ case "HeadingLevel6":
41793
+ return "h6";
41794
+ case "Label":
41795
+ return "label";
41796
+ case "Link":
41797
+ return "a";
41798
+ case "List":
41799
+ return "ul";
41800
+ case "ListItem":
41801
+ return "li";
41802
+ case "ListBody":
41803
+ return "p";
41804
+ case "Note":
41805
+ return "note";
41806
+ case "Part":
41807
+ return "part";
41808
+ case "Quotation":
41809
+ return "quote";
41810
+ case "Reference":
41811
+ return "reference";
41812
+ case "Section":
41813
+ return "sect";
41814
+ case "Span":
41815
+ return "span";
41816
+ case "Table":
41817
+ return "table";
41818
+ case "TableDataCell":
41819
+ return "td";
41820
+ case "TableHeader":
41821
+ return "th";
41822
+ case "TableOfContent":
41823
+ return "toc";
41824
+ case "TableOfContentItem":
41825
+ return "toci";
41826
+ case "TableRow":
41827
+ return "tr";
41828
+ case "Image":
41829
+ return "img";
41830
+ default:
41831
+ return "p";
41832
+ }
41833
+ }
41834
+ ;
41835
+ setStyleToTaggedTextDiv(textDiv, bounds) {
41836
+ textDiv.style.left = bounds.X * (96 / 72) * this.pdfViewerBase.getZoomFactor() + 'px';
41837
+ textDiv.style.top = bounds.Y * (96 / 72) * this.pdfViewerBase.getZoomFactor() + 'px';
41838
+ textDiv.style.width = bounds.Width * (96 / 72) * this.pdfViewerBase.getZoomFactor() + 'px';
41839
+ var textHeight = bounds.Height * (96 / 72) * this.pdfViewerBase.getZoomFactor();
41840
+ textDiv.style.height = textHeight + 'px';
41841
+ textDiv.style.fontSize = 16 * this.pdfViewerBase.getZoomFactor() + 'px';
41842
+ textDiv.style.color = 'transparent';
41843
+ }
41844
+ ;
41845
+ setTextElementProperties(textDiv) {
41846
+ textDiv.style.fontFamily = 'serif';
41847
+ textDiv.style.transformOrigin = '0%';
41848
+ }
41849
+ /**
41850
+ * @private
41851
+ */
41852
+ getModuleName() {
41853
+ return 'TaggedPDF';
41854
+ }
41855
+ }
41856
+
41595
41857
  /**
41596
41858
  * export types
41597
41859
  */
@@ -41608,5 +41870,5 @@ class FormFields {
41608
41870
  * export PDF viewer modules
41609
41871
  */
41610
41872
 
41611
- export { Annotation, LinkAnnotation, TextMarkupAnnotation, MeasureAnnotation, ShapeAnnotation, StampAnnotation, StickyNotesAnnotation, FreeTextAnnotation, InputElement, NavigationPane, PdfViewerBase, TextLayer, ContextMenu$1 as ContextMenu, FontStyle, AnnotationResizerLocation, CursorType, AjaxHandler, Signature, Magnification, Navigation, ThumbnailView, Toolbar$1 as Toolbar, AnnotationToolbar, ToolbarSettings, AjaxRequestSettings, CustomStampItem, AnnotationToolbarSettings, ServerActionSettings, StrikethroughSettings, UnderlineSettings, HighlightSettings, LineSettings, ArrowSettings, RectangleSettings, CircleSettings, ShapeLabelSettings, PolygonSettings, StampSettings, CustomStampSettings, DistanceSettings, PerimeterSettings, AreaSettings, RadiusSettings, VolumeSettings, StickyNotesSettings, MeasurementSettings, FreeTextSettings, AnnotationSelectorSettings, TextSearchColorSettings, HandWrittenSignatureSettings, AnnotationSettings, DocumentTextCollectionSettings, TextDataSettings, RectangleBounds, TileRenderingSettings, ScrollSettings, PdfViewer, BookmarkView, TextSelection, TextSearch, Print, FormFields, Drawing, findActiveElement, findObjectsUnderMouse, findObjectUnderMouse, CalculateLeaderPoints, findElementUnderMouse, insertObject, findTargetShapeElement, findObjects, findActivePage, ActiveElements, getConnectorPoints, getSegmentPath, updateSegmentElement, getSegmentElement, updateDecoratorElement, getDecoratorElement, clipDecorators, clipDecorator, initDistanceLabel, updateDistanceLabel, updateRadiusLabel, initPerimeterLabel, updatePerimeterLabel, removePerimeterLabel, updateCalibrateLabel, getPolygonPath, textElement, initLeaders, initLeader, isPointOverConnector, findNearestPoint, getDecoratorShape, renderAdornerLayer, createSvg, isLineShapes, setElementStype, findPointsLength, findPerimeterLength, getBaseShapeAttributes, getFunction, cloneObject, cloneArray, getInternalProperties, isLeader, PdfBounds, PdfFont, PdfAnnotationBase, ZOrderPageTable, Selector, ToolBase, SelectTool, MoveTool, StampTool, ConnectTool, ResizeTool, NodeDrawingTool, PolygonDrawingTool, LineTool, RotateTool };
41873
+ export { Annotation, LinkAnnotation, TextMarkupAnnotation, MeasureAnnotation, ShapeAnnotation, StampAnnotation, StickyNotesAnnotation, FreeTextAnnotation, InputElement, NavigationPane, PdfViewerBase, TextLayer, ContextMenu$1 as ContextMenu, FontStyle, AnnotationResizerLocation, CursorType, AjaxHandler, Signature, Magnification, Navigation, ThumbnailView, Toolbar$1 as Toolbar, AnnotationToolbar, ToolbarSettings, AjaxRequestSettings, CustomStampItem, AnnotationToolbarSettings, ServerActionSettings, StrikethroughSettings, UnderlineSettings, HighlightSettings, LineSettings, ArrowSettings, RectangleSettings, CircleSettings, ShapeLabelSettings, PolygonSettings, StampSettings, CustomStampSettings, DistanceSettings, PerimeterSettings, AreaSettings, RadiusSettings, VolumeSettings, StickyNotesSettings, MeasurementSettings, FreeTextSettings, AnnotationSelectorSettings, TextSearchColorSettings, HandWrittenSignatureSettings, AnnotationSettings, DocumentTextCollectionSettings, TextDataSettings, RectangleBounds, TileRenderingSettings, ScrollSettings, PdfViewer, BookmarkView, TextSelection, TextSearch, Print, FormFields, TaggedPDF, Drawing, findActiveElement, findObjectsUnderMouse, findObjectUnderMouse, CalculateLeaderPoints, findElementUnderMouse, insertObject, findTargetShapeElement, findObjects, findActivePage, ActiveElements, getConnectorPoints, getSegmentPath, updateSegmentElement, getSegmentElement, updateDecoratorElement, getDecoratorElement, clipDecorators, clipDecorator, initDistanceLabel, updateDistanceLabel, updateRadiusLabel, initPerimeterLabel, updatePerimeterLabel, removePerimeterLabel, updateCalibrateLabel, getPolygonPath, textElement, initLeaders, initLeader, isPointOverConnector, findNearestPoint, getDecoratorShape, renderAdornerLayer, createSvg, isLineShapes, setElementStype, findPointsLength, findPerimeterLength, getBaseShapeAttributes, getFunction, cloneObject, cloneArray, getInternalProperties, isLeader, PdfBounds, PdfFont, PdfAnnotationBase, ZOrderPageTable, Selector, ToolBase, SelectTool, MoveTool, StampTool, ConnectTool, ResizeTool, NodeDrawingTool, PolygonDrawingTool, LineTool, RotateTool };
41612
41874
  //# sourceMappingURL=ej2-pdfviewer.es2015.js.map