ng2-pdfjs-viewer 20.0.0 → 25.0.0
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/LICENSE +231 -51
- package/fesm2022/ng2-pdfjs-viewer.mjs +1942 -233
- package/fesm2022/ng2-pdfjs-viewer.mjs.map +1 -1
- package/index.d.ts +342 -28
- package/package.json +29 -26
- package/pdfjs/build/pdf.mjs +22873 -0
- package/pdfjs/build/pdf.mjs.map +1 -0
- package/pdfjs/build/pdf.sandbox.mjs +218 -0
- package/pdfjs/build/pdf.sandbox.mjs.map +1 -0
- package/pdfjs/build/pdf.worker.mjs +58008 -0
- package/pdfjs/build/pdf.worker.mjs.map +1 -0
- package/pdfjs/postmessage-wrapper.js +1467 -0
- package/pdfjs/web/compressed.tracemonkey-pldi-09.pdf +0 -0
- package/pdfjs/web/debugger.css +114 -0
- package/pdfjs/web/debugger.mjs +627 -0
- package/pdfjs/web/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/pdfjs/web/images/altText_add.svg +3 -0
- package/pdfjs/web/images/altText_disclaimer.svg +3 -0
- package/pdfjs/web/images/altText_done.svg +3 -0
- package/pdfjs/web/images/altText_spinner.svg +30 -0
- package/pdfjs/web/images/altText_warning.svg +3 -0
- package/pdfjs/web/images/annotation-check.svg +11 -11
- package/pdfjs/web/images/annotation-comment.svg +16 -16
- package/pdfjs/web/images/annotation-help.svg +26 -26
- package/pdfjs/web/images/annotation-insert.svg +10 -10
- package/pdfjs/web/images/annotation-key.svg +11 -11
- package/pdfjs/web/images/annotation-newparagraph.svg +11 -11
- package/pdfjs/web/images/annotation-noicon.svg +7 -7
- package/pdfjs/web/images/annotation-note.svg +42 -42
- package/pdfjs/web/images/annotation-paperclip.svg +6 -0
- package/pdfjs/web/images/annotation-paragraph.svg +16 -16
- package/pdfjs/web/images/annotation-pushpin.svg +7 -0
- package/pdfjs/web/images/cursor-editorFreeHighlight.svg +6 -0
- package/pdfjs/web/images/cursor-editorFreeText.svg +3 -0
- package/pdfjs/web/images/cursor-editorInk.svg +4 -0
- package/pdfjs/web/images/cursor-editorTextHighlight.svg +8 -0
- package/pdfjs/web/images/editor-toolbar-delete.svg +5 -0
- package/pdfjs/web/images/editor-toolbar-edit.svg +3 -0
- package/pdfjs/web/images/findbarButton-next.svg +3 -0
- package/pdfjs/web/images/findbarButton-previous.svg +3 -0
- package/pdfjs/web/images/gv-toolbarButton-download.svg +3 -0
- package/pdfjs/web/images/loading.svg +1 -0
- package/pdfjs/web/images/messageBar_closingButton.svg +3 -0
- package/pdfjs/web/images/messageBar_info.svg +3 -0
- package/pdfjs/web/images/messageBar_warning.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-documentProperties.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-firstPage.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-handTool.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-lastPage.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-rotateCcw.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-rotateCw.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollHorizontal.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollPage.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollVertical.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollWrapped.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-selectTool.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadEven.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadNone.svg +3 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadOdd.svg +3 -0
- package/pdfjs/web/images/toolbarButton-bookmark.svg +3 -0
- package/pdfjs/web/images/toolbarButton-currentOutlineItem.svg +3 -0
- package/pdfjs/web/images/toolbarButton-download.svg +4 -0
- package/pdfjs/web/images/toolbarButton-editorFreeText.svg +5 -0
- package/pdfjs/web/images/toolbarButton-editorHighlight.svg +6 -0
- package/pdfjs/web/images/toolbarButton-editorInk.svg +4 -0
- package/pdfjs/web/images/toolbarButton-editorSignature.svg +6 -0
- package/pdfjs/web/images/toolbarButton-editorStamp.svg +8 -0
- package/pdfjs/web/images/toolbarButton-menuArrow.svg +3 -0
- package/pdfjs/web/images/toolbarButton-openFile.svg +3 -0
- package/pdfjs/web/images/toolbarButton-pageDown.svg +3 -0
- package/pdfjs/web/images/toolbarButton-pageUp.svg +3 -0
- package/pdfjs/web/images/toolbarButton-presentationMode.svg +3 -0
- package/pdfjs/web/images/toolbarButton-print.svg +3 -0
- package/pdfjs/web/images/toolbarButton-search.svg +3 -0
- package/pdfjs/web/images/toolbarButton-secondaryToolbarToggle.svg +3 -0
- package/pdfjs/web/images/toolbarButton-sidebarToggle.svg +3 -0
- package/pdfjs/web/images/toolbarButton-viewAttachments.svg +3 -0
- package/pdfjs/web/images/toolbarButton-viewLayers.svg +3 -0
- package/pdfjs/web/images/toolbarButton-viewOutline.svg +3 -0
- package/pdfjs/web/images/toolbarButton-viewThumbnail.svg +3 -0
- package/pdfjs/web/images/toolbarButton-zoomIn.svg +3 -0
- package/pdfjs/web/images/toolbarButton-zoomOut.svg +3 -0
- package/pdfjs/web/images/treeitem-collapsed.svg +1 -0
- package/pdfjs/web/images/treeitem-expanded.svg +1 -0
- package/pdfjs/web/locale/ach/viewer.ftl +275 -0
- package/pdfjs/web/locale/af/viewer.ftl +262 -0
- package/pdfjs/web/locale/an/viewer.ftl +307 -0
- package/pdfjs/web/locale/ar/viewer.ftl +627 -0
- package/pdfjs/web/locale/ast/viewer.ftl +251 -0
- package/pdfjs/web/locale/az/viewer.ftl +307 -0
- package/pdfjs/web/locale/be/viewer.ftl +618 -0
- package/pdfjs/web/locale/bg/viewer.ftl +451 -0
- package/pdfjs/web/locale/bn/viewer.ftl +297 -0
- package/pdfjs/web/locale/bo/viewer.ftl +297 -0
- package/pdfjs/web/locale/br/viewer.ftl +370 -0
- package/pdfjs/web/locale/brx/viewer.ftl +268 -0
- package/pdfjs/web/locale/bs/viewer.ftl +273 -0
- package/pdfjs/web/locale/ca/viewer.ftl +343 -0
- package/pdfjs/web/locale/cak/viewer.ftl +341 -0
- package/pdfjs/web/locale/ckb/viewer.ftl +292 -0
- package/pdfjs/web/locale/cs/viewer.ftl +621 -0
- package/pdfjs/web/locale/cy/viewer.ftl +627 -0
- package/pdfjs/web/locale/da/viewer.ftl +615 -0
- package/pdfjs/web/locale/de/viewer.ftl +615 -0
- package/pdfjs/web/locale/dsb/viewer.ftl +621 -0
- package/pdfjs/web/locale/el/viewer.ftl +615 -0
- package/pdfjs/web/locale/en-CA/viewer.ftl +610 -0
- package/pdfjs/web/locale/en-GB/viewer.ftl +615 -0
- package/pdfjs/web/locale/en-US/viewer.ftl +640 -0
- package/pdfjs/web/locale/eo/viewer.ftl +615 -0
- package/pdfjs/web/locale/es-AR/viewer.ftl +615 -0
- package/pdfjs/web/locale/es-CL/viewer.ftl +615 -0
- package/pdfjs/web/locale/es-ES/viewer.ftl +615 -0
- package/pdfjs/web/locale/es-MX/viewer.ftl +580 -0
- package/pdfjs/web/locale/et/viewer.ftl +319 -0
- package/pdfjs/web/locale/eu/viewer.ftl +619 -0
- package/pdfjs/web/locale/fa/viewer.ftl +378 -0
- package/pdfjs/web/locale/ff/viewer.ftl +297 -0
- package/pdfjs/web/locale/fi/viewer.ftl +615 -0
- package/pdfjs/web/locale/fr/viewer.ftl +611 -0
- package/pdfjs/web/locale/fur/viewer.ftl +615 -0
- package/pdfjs/web/locale/fy-NL/viewer.ftl +615 -0
- package/pdfjs/web/locale/ga-IE/viewer.ftl +263 -0
- package/pdfjs/web/locale/gd/viewer.ftl +343 -0
- package/pdfjs/web/locale/gl/viewer.ftl +414 -0
- package/pdfjs/web/locale/gn/viewer.ftl +614 -0
- package/pdfjs/web/locale/gu-IN/viewer.ftl +297 -0
- package/pdfjs/web/locale/he/viewer.ftl +615 -0
- package/pdfjs/web/locale/hi-IN/viewer.ftl +297 -0
- package/pdfjs/web/locale/hr/viewer.ftl +552 -0
- package/pdfjs/web/locale/hsb/viewer.ftl +621 -0
- package/pdfjs/web/locale/hu/viewer.ftl +615 -0
- package/pdfjs/web/locale/hy-AM/viewer.ftl +314 -0
- package/pdfjs/web/locale/hye/viewer.ftl +318 -0
- package/pdfjs/web/locale/ia/viewer.ftl +615 -0
- package/pdfjs/web/locale/id/viewer.ftl +603 -0
- package/pdfjs/web/locale/is/viewer.ftl +600 -0
- package/pdfjs/web/locale/it/viewer.ftl +615 -0
- package/pdfjs/web/locale/ja/viewer.ftl +603 -0
- package/pdfjs/web/locale/ka/viewer.ftl +615 -0
- package/pdfjs/web/locale/kab/viewer.ftl +595 -0
- package/pdfjs/web/locale/kk/viewer.ftl +595 -0
- package/pdfjs/web/locale/km/viewer.ftl +273 -0
- package/pdfjs/web/locale/kn/viewer.ftl +263 -0
- package/pdfjs/web/locale/ko/viewer.ftl +603 -0
- package/pdfjs/web/locale/lij/viewer.ftl +297 -0
- package/pdfjs/web/locale/lo/viewer.ftl +343 -0
- package/pdfjs/web/locale/locale.json +1 -0
- package/pdfjs/web/locale/lt/viewer.ftl +318 -0
- package/pdfjs/web/locale/ltg/viewer.ftl +296 -0
- package/pdfjs/web/locale/lv/viewer.ftl +297 -0
- package/pdfjs/web/locale/meh/viewer.ftl +137 -0
- package/pdfjs/web/locale/mk/viewer.ftl +265 -0
- package/pdfjs/web/locale/ml/viewer.ftl +524 -0
- package/pdfjs/web/locale/mr/viewer.ftl +289 -0
- package/pdfjs/web/locale/ms/viewer.ftl +297 -0
- package/pdfjs/web/locale/my/viewer.ftl +256 -0
- package/pdfjs/web/locale/nb-NO/viewer.ftl +614 -0
- package/pdfjs/web/locale/ne-NP/viewer.ftl +284 -0
- package/pdfjs/web/locale/nl/viewer.ftl +615 -0
- package/pdfjs/web/locale/nn-NO/viewer.ftl +609 -0
- package/pdfjs/web/locale/oc/viewer.ftl +436 -0
- package/pdfjs/web/locale/pa-IN/viewer.ftl +615 -0
- package/pdfjs/web/locale/pl/viewer.ftl +618 -0
- package/pdfjs/web/locale/pt-BR/viewer.ftl +615 -0
- package/pdfjs/web/locale/pt-PT/viewer.ftl +615 -0
- package/pdfjs/web/locale/rm/viewer.ftl +615 -0
- package/pdfjs/web/locale/ro/viewer.ftl +302 -0
- package/pdfjs/web/locale/ru/viewer.ftl +618 -0
- package/pdfjs/web/locale/sat/viewer.ftl +355 -0
- package/pdfjs/web/locale/sc/viewer.ftl +394 -0
- package/pdfjs/web/locale/scn/viewer.ftl +124 -0
- package/pdfjs/web/locale/sco/viewer.ftl +314 -0
- package/pdfjs/web/locale/si/viewer.ftl +301 -0
- package/pdfjs/web/locale/sk/viewer.ftl +621 -0
- package/pdfjs/web/locale/skr/viewer.ftl +524 -0
- package/pdfjs/web/locale/sl/viewer.ftl +621 -0
- package/pdfjs/web/locale/son/viewer.ftl +256 -0
- package/pdfjs/web/locale/sq/viewer.ftl +606 -0
- package/pdfjs/web/locale/sr/viewer.ftl +451 -0
- package/pdfjs/web/locale/sv-SE/viewer.ftl +615 -0
- package/pdfjs/web/locale/szl/viewer.ftl +307 -0
- package/pdfjs/web/locale/ta/viewer.ftl +273 -0
- package/pdfjs/web/locale/te/viewer.ftl +289 -0
- package/pdfjs/web/locale/tg/viewer.ftl +615 -0
- package/pdfjs/web/locale/th/viewer.ftl +603 -0
- package/pdfjs/web/locale/tl/viewer.ftl +307 -0
- package/pdfjs/web/locale/tr/viewer.ftl +615 -0
- package/pdfjs/web/locale/trs/viewer.ftl +247 -0
- package/pdfjs/web/locale/uk/viewer.ftl +618 -0
- package/pdfjs/web/locale/ur/viewer.ftl +298 -0
- package/pdfjs/web/locale/uz/viewer.ftl +237 -0
- package/pdfjs/web/locale/vi/viewer.ftl +603 -0
- package/pdfjs/web/locale/wo/viewer.ftl +177 -0
- package/pdfjs/web/locale/xh/viewer.ftl +262 -0
- package/pdfjs/web/locale/zh-CN/viewer.ftl +603 -0
- package/pdfjs/web/locale/zh-TW/viewer.ftl +603 -0
- package/pdfjs/web/postmessage-wrapper.js +2103 -0
- package/pdfjs/web/standard_fonts/FoxitDingbats.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitFixed.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitSerif.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/pdfjs/web/standard_fonts/FoxitSymbol.pfb +0 -0
- package/pdfjs/web/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/pdfjs/web/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/pdfjs/web/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/pdfjs/web/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/pdfjs/web/viewer.css +5935 -1902
- package/pdfjs/web/viewer.html +636 -288
- package/pdfjs/web/viewer.mjs +17076 -0
- package/pdfjs/web/viewer.mjs.map +1 -0
- package/pdfjs/web/wasm/openjpeg.wasm +0 -0
- package/pdfjs/web/wasm/openjpeg_nowasm_fallback.js +29 -0
- package/pdfjs/web/wasm/qcms_bg.wasm +0 -0
- package/pdfjs/build/pdf.js +0 -24385
- package/pdfjs/build/pdf.js.map +0 -1
- package/pdfjs/build/pdf.worker.js +0 -55973
- package/pdfjs/build/pdf.worker.js.map +0 -1
- package/pdfjs/web/debugger.js +0 -615
- package/pdfjs/web/images/findbarButton-next-rtl.png +0 -0
- package/pdfjs/web/images/findbarButton-next-rtl@2x.png +0 -0
- package/pdfjs/web/images/findbarButton-next.png +0 -0
- package/pdfjs/web/images/findbarButton-next@2x.png +0 -0
- package/pdfjs/web/images/findbarButton-previous-rtl.png +0 -0
- package/pdfjs/web/images/findbarButton-previous-rtl@2x.png +0 -0
- package/pdfjs/web/images/findbarButton-previous.png +0 -0
- package/pdfjs/web/images/findbarButton-previous@2x.png +0 -0
- package/pdfjs/web/images/grab.cur +0 -0
- package/pdfjs/web/images/grabbing.cur +0 -0
- package/pdfjs/web/images/loading-small.png +0 -0
- package/pdfjs/web/images/loading-small@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-documentProperties.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-documentProperties@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-firstPage.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-firstPage@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-handTool.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-handTool@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-lastPage.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-lastPage@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-rotateCcw.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-rotateCcw@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-rotateCw.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-rotateCw@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollHorizontal.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollHorizontal@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollVertical.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollVertical@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollWrapped.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-scrollWrapped@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-selectTool.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-selectTool@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadEven.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadEven@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadNone.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadNone@2x.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadOdd.png +0 -0
- package/pdfjs/web/images/secondaryToolbarButton-spreadOdd@2x.png +0 -0
- package/pdfjs/web/images/shadow.png +0 -0
- package/pdfjs/web/images/texture.png +0 -0
- package/pdfjs/web/images/toolbarButton-bookmark.png +0 -0
- package/pdfjs/web/images/toolbarButton-bookmark@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-download.png +0 -0
- package/pdfjs/web/images/toolbarButton-download@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-menuArrows.png +0 -0
- package/pdfjs/web/images/toolbarButton-menuArrows@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-openFile.png +0 -0
- package/pdfjs/web/images/toolbarButton-openFile@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-pageDown-rtl.png +0 -0
- package/pdfjs/web/images/toolbarButton-pageDown-rtl@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-pageDown.png +0 -0
- package/pdfjs/web/images/toolbarButton-pageDown@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-pageUp-rtl.png +0 -0
- package/pdfjs/web/images/toolbarButton-pageUp-rtl@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-pageUp.png +0 -0
- package/pdfjs/web/images/toolbarButton-pageUp@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-presentationMode.png +0 -0
- package/pdfjs/web/images/toolbarButton-presentationMode@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-print.png +0 -0
- package/pdfjs/web/images/toolbarButton-print@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-search.png +0 -0
- package/pdfjs/web/images/toolbarButton-search@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-secondaryToolbarToggle-rtl.png +0 -0
- package/pdfjs/web/images/toolbarButton-secondaryToolbarToggle-rtl@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-secondaryToolbarToggle.png +0 -0
- package/pdfjs/web/images/toolbarButton-secondaryToolbarToggle@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-sidebarToggle-rtl.png +0 -0
- package/pdfjs/web/images/toolbarButton-sidebarToggle-rtl@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-sidebarToggle.png +0 -0
- package/pdfjs/web/images/toolbarButton-sidebarToggle@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-viewAttachments.png +0 -0
- package/pdfjs/web/images/toolbarButton-viewAttachments@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-viewOutline-rtl.png +0 -0
- package/pdfjs/web/images/toolbarButton-viewOutline-rtl@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-viewOutline.png +0 -0
- package/pdfjs/web/images/toolbarButton-viewOutline@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-viewThumbnail.png +0 -0
- package/pdfjs/web/images/toolbarButton-viewThumbnail@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-zoomIn.png +0 -0
- package/pdfjs/web/images/toolbarButton-zoomIn@2x.png +0 -0
- package/pdfjs/web/images/toolbarButton-zoomOut.png +0 -0
- package/pdfjs/web/images/toolbarButton-zoomOut@2x.png +0 -0
- package/pdfjs/web/images/treeitem-collapsed-rtl.png +0 -0
- package/pdfjs/web/images/treeitem-collapsed-rtl@2x.png +0 -0
- package/pdfjs/web/images/treeitem-collapsed.png +0 -0
- package/pdfjs/web/images/treeitem-collapsed@2x.png +0 -0
- package/pdfjs/web/images/treeitem-expanded.png +0 -0
- package/pdfjs/web/images/treeitem-expanded@2x.png +0 -0
- package/pdfjs/web/locale/ach/viewer.properties +0 -207
- package/pdfjs/web/locale/af/viewer.properties +0 -184
- package/pdfjs/web/locale/ak/viewer.properties +0 -130
- package/pdfjs/web/locale/an/viewer.properties +0 -184
- package/pdfjs/web/locale/ar/viewer.properties +0 -242
- package/pdfjs/web/locale/as/viewer.properties +0 -167
- package/pdfjs/web/locale/ast/viewer.properties +0 -201
- package/pdfjs/web/locale/az/viewer.properties +0 -242
- package/pdfjs/web/locale/be/viewer.properties +0 -242
- package/pdfjs/web/locale/bg/viewer.properties +0 -242
- package/pdfjs/web/locale/bn-BD/viewer.properties +0 -232
- package/pdfjs/web/locale/bn-IN/viewer.properties +0 -242
- package/pdfjs/web/locale/br/viewer.properties +0 -242
- package/pdfjs/web/locale/brx/viewer.properties +0 -167
- package/pdfjs/web/locale/bs/viewer.properties +0 -201
- package/pdfjs/web/locale/ca/viewer.properties +0 -236
- package/pdfjs/web/locale/cak/viewer.properties +0 -242
- package/pdfjs/web/locale/crh/viewer.properties +0 -242
- package/pdfjs/web/locale/cs/viewer.properties +0 -242
- package/pdfjs/web/locale/csb/viewer.properties +0 -134
- package/pdfjs/web/locale/cy/viewer.properties +0 -242
- package/pdfjs/web/locale/da/viewer.properties +0 -242
- package/pdfjs/web/locale/de/viewer.properties +0 -242
- package/pdfjs/web/locale/el/viewer.properties +0 -242
- package/pdfjs/web/locale/en-CA/viewer.properties +0 -242
- package/pdfjs/web/locale/en-GB/viewer.properties +0 -242
- package/pdfjs/web/locale/en-US/viewer.properties +0 -246
- package/pdfjs/web/locale/en-ZA/viewer.properties +0 -170
- package/pdfjs/web/locale/eo/viewer.properties +0 -242
- package/pdfjs/web/locale/es-AR/viewer.properties +0 -242
- package/pdfjs/web/locale/es-CL/viewer.properties +0 -242
- package/pdfjs/web/locale/es-ES/viewer.properties +0 -242
- package/pdfjs/web/locale/es-MX/viewer.properties +0 -242
- package/pdfjs/web/locale/et/viewer.properties +0 -242
- package/pdfjs/web/locale/eu/viewer.properties +0 -242
- package/pdfjs/web/locale/fa/viewer.properties +0 -223
- package/pdfjs/web/locale/ff/viewer.properties +0 -242
- package/pdfjs/web/locale/fi/viewer.properties +0 -242
- package/pdfjs/web/locale/fr/viewer.properties +0 -242
- package/pdfjs/web/locale/fy-NL/viewer.properties +0 -242
- package/pdfjs/web/locale/ga-IE/viewer.properties +0 -184
- package/pdfjs/web/locale/gd/viewer.properties +0 -242
- package/pdfjs/web/locale/gl/viewer.properties +0 -242
- package/pdfjs/web/locale/gn/viewer.properties +0 -242
- package/pdfjs/web/locale/gu-IN/viewer.properties +0 -242
- package/pdfjs/web/locale/he/viewer.properties +0 -240
- package/pdfjs/web/locale/hi-IN/viewer.properties +0 -224
- package/pdfjs/web/locale/hr/viewer.properties +0 -242
- package/pdfjs/web/locale/hsb/viewer.properties +0 -242
- package/pdfjs/web/locale/hto/viewer.properties +0 -127
- package/pdfjs/web/locale/hu/viewer.properties +0 -242
- package/pdfjs/web/locale/hy-AM/viewer.properties +0 -201
- package/pdfjs/web/locale/ia/viewer.properties +0 -242
- package/pdfjs/web/locale/id/viewer.properties +0 -242
- package/pdfjs/web/locale/is/viewer.properties +0 -239
- package/pdfjs/web/locale/it/viewer.properties +0 -157
- package/pdfjs/web/locale/ja/viewer.properties +0 -242
- package/pdfjs/web/locale/ka/viewer.properties +0 -242
- package/pdfjs/web/locale/kab/viewer.properties +0 -242
- package/pdfjs/web/locale/kk/viewer.properties +0 -242
- package/pdfjs/web/locale/km/viewer.properties +0 -184
- package/pdfjs/web/locale/kn/viewer.properties +0 -193
- package/pdfjs/web/locale/ko/viewer.properties +0 -242
- package/pdfjs/web/locale/kok/viewer.properties +0 -167
- package/pdfjs/web/locale/ks/viewer.properties +0 -168
- package/pdfjs/web/locale/ku/viewer.properties +0 -146
- package/pdfjs/web/locale/lg/viewer.properties +0 -112
- package/pdfjs/web/locale/lij/viewer.properties +0 -242
- package/pdfjs/web/locale/lo/viewer.properties +0 -152
- package/pdfjs/web/locale/locale.properties +0 -369
- package/pdfjs/web/locale/lt/viewer.properties +0 -242
- package/pdfjs/web/locale/ltg/viewer.properties +0 -220
- package/pdfjs/web/locale/lv/viewer.properties +0 -242
- package/pdfjs/web/locale/mai/viewer.properties +0 -168
- package/pdfjs/web/locale/meh/viewer.properties +0 -72
- package/pdfjs/web/locale/mk/viewer.properties +0 -145
- package/pdfjs/web/locale/ml/viewer.properties +0 -184
- package/pdfjs/web/locale/mn/viewer.properties +0 -82
- package/pdfjs/web/locale/mr/viewer.properties +0 -227
- package/pdfjs/web/locale/ms/viewer.properties +0 -242
- package/pdfjs/web/locale/my/viewer.properties +0 -198
- package/pdfjs/web/locale/nb-NO/viewer.properties +0 -242
- package/pdfjs/web/locale/ne-NP/viewer.properties +0 -184
- package/pdfjs/web/locale/nl/viewer.properties +0 -246
- package/pdfjs/web/locale/nn-NO/viewer.properties +0 -242
- package/pdfjs/web/locale/nso/viewer.properties +0 -130
- package/pdfjs/web/locale/oc/viewer.properties +0 -210
- package/pdfjs/web/locale/or/viewer.properties +0 -167
- package/pdfjs/web/locale/pa-IN/viewer.properties +0 -225
- package/pdfjs/web/locale/pl/viewer.properties +0 -242
- package/pdfjs/web/locale/pt-BR/viewer.properties +0 -242
- package/pdfjs/web/locale/pt-PT/viewer.properties +0 -242
- package/pdfjs/web/locale/rm/viewer.properties +0 -242
- package/pdfjs/web/locale/ro/viewer.properties +0 -242
- package/pdfjs/web/locale/ru/viewer.properties +0 -242
- package/pdfjs/web/locale/rw/viewer.properties +0 -81
- package/pdfjs/web/locale/sah/viewer.properties +0 -166
- package/pdfjs/web/locale/sat/viewer.properties +0 -134
- package/pdfjs/web/locale/si/viewer.properties +0 -207
- package/pdfjs/web/locale/sk/viewer.properties +0 -242
- package/pdfjs/web/locale/sl/viewer.properties +0 -242
- package/pdfjs/web/locale/son/viewer.properties +0 -180
- package/pdfjs/web/locale/sq/viewer.properties +0 -235
- package/pdfjs/web/locale/sr/viewer.properties +0 -220
- package/pdfjs/web/locale/sv-SE/viewer.properties +0 -242
- package/pdfjs/web/locale/sw/viewer.properties +0 -128
- package/pdfjs/web/locale/ta/viewer.properties +0 -201
- package/pdfjs/web/locale/ta-LK/viewer.properties +0 -77
- package/pdfjs/web/locale/te/viewer.properties +0 -218
- package/pdfjs/web/locale/th/viewer.properties +0 -242
- package/pdfjs/web/locale/tl/viewer.properties +0 -242
- package/pdfjs/web/locale/tn/viewer.properties +0 -83
- package/pdfjs/web/locale/tr/viewer.properties +0 -242
- package/pdfjs/web/locale/tsz/viewer.properties +0 -75
- package/pdfjs/web/locale/uk/viewer.properties +0 -242
- package/pdfjs/web/locale/ur/viewer.properties +0 -207
- package/pdfjs/web/locale/uz/viewer.properties +0 -169
- package/pdfjs/web/locale/vi/viewer.properties +0 -239
- package/pdfjs/web/locale/wo/viewer.properties +0 -124
- package/pdfjs/web/locale/xh/viewer.properties +0 -184
- package/pdfjs/web/locale/zam/viewer.properties +0 -90
- package/pdfjs/web/locale/zh-CN/viewer.properties +0 -242
- package/pdfjs/web/locale/zh-TW/viewer.properties +0 -242
- package/pdfjs/web/locale/zu/viewer.properties +0 -131
- package/pdfjs/web/viewer.js +0 -15877
- package/pdfjs/web/viewer.js.map +0 -1
|
@@ -1,65 +1,758 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter,
|
|
2
|
+
import { EventEmitter, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
3
4
|
import { CommonModule } from '@angular/common';
|
|
4
5
|
|
|
6
|
+
// Simplified Action Queue Manager - Single queue with readiness-based execution
|
|
7
|
+
class ActionQueueManager {
|
|
8
|
+
actionQueue = [];
|
|
9
|
+
executedActions = new Map();
|
|
10
|
+
isDocumentLoaded = false;
|
|
11
|
+
isPostMessageReady = false;
|
|
12
|
+
postMessageReadiness = 0;
|
|
13
|
+
diagnosticLogs = false;
|
|
14
|
+
postMessageExecutor;
|
|
15
|
+
constructor(diagnosticLogs = false) {
|
|
16
|
+
this.diagnosticLogs = diagnosticLogs;
|
|
17
|
+
}
|
|
18
|
+
setPostMessageReady(ready, readiness = 0) {
|
|
19
|
+
this.isPostMessageReady = ready;
|
|
20
|
+
this.postMessageReadiness = readiness;
|
|
21
|
+
if (ready) {
|
|
22
|
+
this.processQueuedActions();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
updateReadiness(readiness) {
|
|
26
|
+
if (this.postMessageReadiness !== readiness) {
|
|
27
|
+
this.postMessageReadiness = readiness;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Simplified queue management - single queue with readiness levels
|
|
31
|
+
queueAction(action, readinessLevel) {
|
|
32
|
+
this.actionQueue.push({ action, readinessLevel });
|
|
33
|
+
}
|
|
34
|
+
// Legacy methods for backward compatibility - now just delegate to main queue
|
|
35
|
+
queueImmediateAction(action) {
|
|
36
|
+
this.queueAction(action, 3);
|
|
37
|
+
}
|
|
38
|
+
queueViewerReadyAction(action) {
|
|
39
|
+
this.queueAction(action, 4);
|
|
40
|
+
}
|
|
41
|
+
queueDocumentLoadedAction(action) {
|
|
42
|
+
this.queueAction(action, 5);
|
|
43
|
+
}
|
|
44
|
+
queueOnDemandAction(action) {
|
|
45
|
+
return this.executeAction(action);
|
|
46
|
+
}
|
|
47
|
+
onDocumentLoaded() {
|
|
48
|
+
this.isDocumentLoaded = true;
|
|
49
|
+
this.processQueuedActions();
|
|
50
|
+
}
|
|
51
|
+
// Process all queued actions that now meet readiness requirements
|
|
52
|
+
processQueuedActions() {
|
|
53
|
+
const executableActions = this.actionQueue.filter((item) => {
|
|
54
|
+
const canExecute = this.postMessageReadiness >= item.readinessLevel &&
|
|
55
|
+
(item.readinessLevel < 5 || this.isDocumentLoaded);
|
|
56
|
+
return canExecute;
|
|
57
|
+
});
|
|
58
|
+
// Remove executable actions from queue
|
|
59
|
+
this.actionQueue = this.actionQueue.filter((item) => {
|
|
60
|
+
return !(this.postMessageReadiness >= item.readinessLevel &&
|
|
61
|
+
(item.readinessLevel < 5 || this.isDocumentLoaded));
|
|
62
|
+
});
|
|
63
|
+
// Execute all ready actions
|
|
64
|
+
executableActions.forEach((item) => {
|
|
65
|
+
this.executeAction(item.action);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async executeAction(action) {
|
|
69
|
+
const result = {
|
|
70
|
+
actionId: action.id,
|
|
71
|
+
success: false,
|
|
72
|
+
timestamp: Date.now(),
|
|
73
|
+
};
|
|
74
|
+
try {
|
|
75
|
+
if (action.condition && !action.condition(null)) {
|
|
76
|
+
result.error = "Condition not met";
|
|
77
|
+
this.executedActions.set(action.id, result);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
const success = await this.executeActionViaPostMessage(action);
|
|
81
|
+
result.success = success;
|
|
82
|
+
// If action has a resolver (from user interaction), call it
|
|
83
|
+
if (action.resolver) {
|
|
84
|
+
action.resolver(result);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
result.error = error instanceof Error ? error.message : String(error);
|
|
89
|
+
if (this.diagnosticLogs) {
|
|
90
|
+
console.error(`🔍 ActionQueueManager: Error executing action ${action.action}:`, error);
|
|
91
|
+
}
|
|
92
|
+
// If action has a resolver (from user interaction), call it with error
|
|
93
|
+
if (action.resolver) {
|
|
94
|
+
action.resolver(result);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this.executedActions.set(action.id, result);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
async executeActionViaPostMessage(action) {
|
|
101
|
+
if (!this.postMessageExecutor) {
|
|
102
|
+
throw new Error("PostMessage executor not set");
|
|
103
|
+
}
|
|
104
|
+
await this.postMessageExecutor(action.action, action.payload);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
setPostMessageExecutor(executor) {
|
|
108
|
+
this.postMessageExecutor = executor;
|
|
109
|
+
}
|
|
110
|
+
getActionStatus(actionId) {
|
|
111
|
+
const result = this.executedActions.get(actionId);
|
|
112
|
+
if (!result) {
|
|
113
|
+
const inQueue = this.actionQueue.some((item) => item.action.id === actionId);
|
|
114
|
+
return inQueue ? "pending" : "not-found";
|
|
115
|
+
}
|
|
116
|
+
return result.success ? "completed" : "failed";
|
|
117
|
+
}
|
|
118
|
+
clearQueues() {
|
|
119
|
+
this.actionQueue = [];
|
|
120
|
+
this.executedActions.clear();
|
|
121
|
+
}
|
|
122
|
+
getQueueStatus() {
|
|
123
|
+
return {
|
|
124
|
+
queuedActions: this.actionQueue.length,
|
|
125
|
+
executedActions: this.executedActions.size,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Property transformation utilities
|
|
131
|
+
class PropertyTransformers {
|
|
132
|
+
static transformZoom = {
|
|
133
|
+
toViewer: (zoom) => {
|
|
134
|
+
if (!zoom)
|
|
135
|
+
return "auto";
|
|
136
|
+
// Convert common zoom values to PDF.js format
|
|
137
|
+
const zoomMappings = {
|
|
138
|
+
auto: "auto",
|
|
139
|
+
"page-fit": "page-fit",
|
|
140
|
+
"page-width": "page-width",
|
|
141
|
+
"page-actual": "page-actual",
|
|
142
|
+
};
|
|
143
|
+
return zoomMappings[zoom.toLowerCase()] || zoom;
|
|
144
|
+
},
|
|
145
|
+
fromViewer: (viewerZoom) => {
|
|
146
|
+
if (typeof viewerZoom === "string")
|
|
147
|
+
return viewerZoom;
|
|
148
|
+
if (typeof viewerZoom === "number") {
|
|
149
|
+
// Convert numeric zoom to string without % to avoid feedback loop
|
|
150
|
+
// PDF.js accepts numeric strings like "1.25" directly
|
|
151
|
+
return viewerZoom.toString();
|
|
152
|
+
}
|
|
153
|
+
return "auto";
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
static transformRotation = {
|
|
157
|
+
toViewer: (rotation) => {
|
|
158
|
+
// Normalize rotation to 0, 90, 180, 270
|
|
159
|
+
return ((rotation % 360) + 360) % 360;
|
|
160
|
+
},
|
|
161
|
+
fromViewer: (viewerRotation) => {
|
|
162
|
+
return typeof viewerRotation === "number" ? viewerRotation : 0;
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
static transformCursor = {
|
|
166
|
+
toViewer: (cursor) => {
|
|
167
|
+
if (!cursor)
|
|
168
|
+
return "select";
|
|
169
|
+
const cursorMappings = {
|
|
170
|
+
select: "select",
|
|
171
|
+
hand: "hand",
|
|
172
|
+
zoom: "zoom",
|
|
173
|
+
};
|
|
174
|
+
return cursorMappings[cursor.toLowerCase()] || "select";
|
|
175
|
+
},
|
|
176
|
+
fromViewer: (viewerCursor) => {
|
|
177
|
+
return typeof viewerCursor === "string" ? viewerCursor : "select";
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
static transformScroll = {
|
|
181
|
+
toViewer: (scroll) => {
|
|
182
|
+
if (!scroll)
|
|
183
|
+
return "vertical";
|
|
184
|
+
const scrollMappings = {
|
|
185
|
+
vertical: "vertical",
|
|
186
|
+
horizontal: "horizontal",
|
|
187
|
+
wrapped: "wrapped",
|
|
188
|
+
page: "page",
|
|
189
|
+
};
|
|
190
|
+
return scrollMappings[scroll.toLowerCase()] || "vertical";
|
|
191
|
+
},
|
|
192
|
+
fromViewer: (viewerScroll) => {
|
|
193
|
+
const scrollModes = ["vertical", "horizontal", "wrapped", "page"];
|
|
194
|
+
if (typeof viewerScroll === "number") {
|
|
195
|
+
return scrollModes[viewerScroll] || "vertical";
|
|
196
|
+
}
|
|
197
|
+
return typeof viewerScroll === "string" ? viewerScroll : "vertical";
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
static transformSpread = {
|
|
201
|
+
toViewer: (spread) => {
|
|
202
|
+
if (!spread)
|
|
203
|
+
return "none";
|
|
204
|
+
const spreadMappings = {
|
|
205
|
+
none: "none",
|
|
206
|
+
odd: "odd",
|
|
207
|
+
even: "even",
|
|
208
|
+
};
|
|
209
|
+
return spreadMappings[spread.toLowerCase()] || "none";
|
|
210
|
+
},
|
|
211
|
+
fromViewer: (viewerSpread) => {
|
|
212
|
+
const spreadModes = ["none", "odd", "even"];
|
|
213
|
+
if (typeof viewerSpread === "number") {
|
|
214
|
+
return spreadModes[viewerSpread] || "none";
|
|
215
|
+
}
|
|
216
|
+
return typeof viewerSpread === "string" ? viewerSpread : "none";
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
static transformPageMode = {
|
|
220
|
+
toViewer: (pageMode) => {
|
|
221
|
+
if (!pageMode)
|
|
222
|
+
return "none";
|
|
223
|
+
const pageModeMapping = {
|
|
224
|
+
none: "none",
|
|
225
|
+
thumbs: "thumbs",
|
|
226
|
+
bookmarks: "bookmarks",
|
|
227
|
+
attachments: "attachments",
|
|
228
|
+
};
|
|
229
|
+
return pageModeMapping[pageMode.toLowerCase()] || "none";
|
|
230
|
+
},
|
|
231
|
+
fromViewer: (viewerPageMode) => {
|
|
232
|
+
return typeof viewerPageMode === "string" ? viewerPageMode : "none";
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Common utility functions for the PDF viewer component
|
|
238
|
+
class ComponentUtils {
|
|
239
|
+
// Common PostMessage action mapping
|
|
240
|
+
static getActionForProperty(propertyName) {
|
|
241
|
+
const propertyActionMap = {
|
|
242
|
+
// Control visibility
|
|
243
|
+
showOpenFile: "show-openfile",
|
|
244
|
+
showDownload: "show-download",
|
|
245
|
+
showPrint: "show-print",
|
|
246
|
+
showFullScreen: "show-fullscreen",
|
|
247
|
+
showFind: "show-find",
|
|
248
|
+
showViewBookmark: "show-bookmark",
|
|
249
|
+
showAnnotations: "show-annotations",
|
|
250
|
+
// Mode controls
|
|
251
|
+
cursor: "set-cursor",
|
|
252
|
+
scroll: "set-scroll",
|
|
253
|
+
spread: "set-spread",
|
|
254
|
+
zoom: "set-zoom",
|
|
255
|
+
pageMode: "update-page-mode",
|
|
256
|
+
// Navigation
|
|
257
|
+
page: "set-page",
|
|
258
|
+
rotation: "set-rotation",
|
|
259
|
+
namedDest: "go-to-named-dest",
|
|
260
|
+
// Auto-actions
|
|
261
|
+
downloadOnLoad: "trigger-download",
|
|
262
|
+
printOnLoad: "trigger-print",
|
|
263
|
+
showLastPageOnLoad: "go-to-last-page",
|
|
264
|
+
rotateCW: "trigger-rotate-cw",
|
|
265
|
+
rotateCCW: "trigger-rotate-ccw",
|
|
266
|
+
// Error handling
|
|
267
|
+
errorMessage: "set-error-message",
|
|
268
|
+
errorOverride: "set-error-override",
|
|
269
|
+
errorAppend: "set-error-append",
|
|
270
|
+
// Configuration
|
|
271
|
+
locale: "set-locale",
|
|
272
|
+
useOnlyCssZoom: "set-css-zoom",
|
|
273
|
+
downloadFileName: "set-download-filename",
|
|
274
|
+
// Theme & Visual Customization
|
|
275
|
+
theme: "set-theme",
|
|
276
|
+
primaryColor: "set-primary-color",
|
|
277
|
+
backgroundColor: "set-background-color",
|
|
278
|
+
pageBorderColor: "set-page-border-color",
|
|
279
|
+
toolbarColor: "set-toolbar-color",
|
|
280
|
+
textColor: "set-text-color",
|
|
281
|
+
borderRadius: "set-border-radius",
|
|
282
|
+
customCSS: "set-custom-css",
|
|
283
|
+
};
|
|
284
|
+
// Toolbar/Sidebar group visibility
|
|
285
|
+
const groupVisibilityMap = {
|
|
286
|
+
showToolbarLeft: "show-toolbar-left",
|
|
287
|
+
showToolbarMiddle: "show-toolbar-middle",
|
|
288
|
+
showToolbarRight: "show-toolbar-right",
|
|
289
|
+
showSecondaryToolbarToggle: "show-secondary-toolbar-toggle",
|
|
290
|
+
showSidebar: "show-sidebar",
|
|
291
|
+
showSidebarLeft: "show-sidebar-left",
|
|
292
|
+
showSidebarRight: "show-sidebar-right",
|
|
293
|
+
};
|
|
294
|
+
// Layout & responsive customization
|
|
295
|
+
const layoutMap = {
|
|
296
|
+
toolbarDensity: "set-toolbar-density",
|
|
297
|
+
sidebarWidth: "set-sidebar-width",
|
|
298
|
+
toolbarPosition: "set-toolbar-position",
|
|
299
|
+
sidebarPosition: "set-sidebar-position",
|
|
300
|
+
responsiveBreakpoint: "set-responsive-breakpoint",
|
|
301
|
+
};
|
|
302
|
+
return (propertyActionMap[propertyName] ||
|
|
303
|
+
groupVisibilityMap[propertyName] ||
|
|
304
|
+
layoutMap[propertyName] ||
|
|
305
|
+
null);
|
|
306
|
+
}
|
|
307
|
+
// Event handler cleanup utility
|
|
308
|
+
static cleanupEventHandlers(component) {
|
|
309
|
+
// Clean up webviewerloaded handler
|
|
310
|
+
if (component._webviewerLoadedHandler) {
|
|
311
|
+
document.removeEventListener("webviewerloaded", component._webviewerLoadedHandler);
|
|
312
|
+
}
|
|
313
|
+
// Clean up PDF.js event handlers
|
|
314
|
+
if (component._pdfEventHandlers) {
|
|
315
|
+
const handlers = component._pdfEventHandlers;
|
|
316
|
+
const eventBus = component.PDFViewerApplication?.eventBus;
|
|
317
|
+
if (eventBus) {
|
|
318
|
+
Object.keys(handlers).forEach((eventName) => {
|
|
319
|
+
eventBus.off(eventName, handlers[eventName]);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Change origin tracking for two-way binding circular update prevention
|
|
327
|
+
class ChangeOriginTracker {
|
|
328
|
+
userInitiatedChanges = new Set();
|
|
329
|
+
programmaticChanges = new Set();
|
|
330
|
+
markUserInitiated(property) {
|
|
331
|
+
this.userInitiatedChanges.add(property);
|
|
332
|
+
setTimeout(() => this.userInitiatedChanges.delete(property), 0);
|
|
333
|
+
}
|
|
334
|
+
markProgrammatic(property) {
|
|
335
|
+
this.programmaticChanges.add(property);
|
|
336
|
+
setTimeout(() => this.programmaticChanges.delete(property), 0);
|
|
337
|
+
}
|
|
338
|
+
isUserInitiated(property) {
|
|
339
|
+
return this.userInitiatedChanges.has(property);
|
|
340
|
+
}
|
|
341
|
+
isProgrammatic(property) {
|
|
342
|
+
return this.programmaticChanges.has(property);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
5
346
|
class PdfJsViewerComponent {
|
|
347
|
+
// #region Component Properties
|
|
6
348
|
iframe;
|
|
7
349
|
static lastID = 0;
|
|
8
350
|
viewerId = `ng2-pdfjs-viewer-ID${++PdfJsViewerComponent.lastID}`;
|
|
351
|
+
// #region Event Outputs
|
|
9
352
|
onBeforePrint = new EventEmitter();
|
|
10
353
|
onAfterPrint = new EventEmitter();
|
|
11
354
|
onDocumentLoad = new EventEmitter();
|
|
12
355
|
onPageChange = new EventEmitter();
|
|
356
|
+
onScaleChange = new EventEmitter();
|
|
357
|
+
onRotationChange = new EventEmitter();
|
|
358
|
+
// New high-value events for enhanced PDF viewer functionality
|
|
359
|
+
onDocumentError = new EventEmitter();
|
|
360
|
+
onDocumentInit = new EventEmitter();
|
|
361
|
+
onPagesInit = new EventEmitter();
|
|
362
|
+
onPresentationModeChanged = new EventEmitter();
|
|
363
|
+
onOpenFile = new EventEmitter();
|
|
364
|
+
onFind = new EventEmitter();
|
|
365
|
+
onUpdateFindMatchesCount = new EventEmitter();
|
|
366
|
+
onMetadataLoaded = new EventEmitter();
|
|
367
|
+
onOutlineLoaded = new EventEmitter();
|
|
368
|
+
onPageRendered = new EventEmitter();
|
|
369
|
+
// New high-value events
|
|
370
|
+
onAnnotationLayerRendered = new EventEmitter();
|
|
371
|
+
onBookmarkClick = new EventEmitter();
|
|
372
|
+
onIdle = new EventEmitter();
|
|
373
|
+
// #endregion
|
|
374
|
+
// #region Basic Configuration Properties
|
|
13
375
|
viewerFolder;
|
|
14
376
|
externalWindow = false;
|
|
15
|
-
target =
|
|
377
|
+
target = "_blank";
|
|
16
378
|
showSpinner = true;
|
|
17
379
|
downloadFileName;
|
|
18
|
-
openFile = true;
|
|
19
|
-
download = true;
|
|
20
|
-
startDownload;
|
|
21
|
-
viewBookmark = true;
|
|
22
|
-
print = true;
|
|
23
|
-
startPrint;
|
|
24
|
-
fullScreen = true;
|
|
25
|
-
//@Input() public showFullScreen: boolean;
|
|
26
|
-
find = true;
|
|
27
|
-
zoom;
|
|
28
|
-
nameddest;
|
|
29
|
-
pagemode;
|
|
30
|
-
lastPage;
|
|
31
|
-
rotatecw;
|
|
32
|
-
rotateccw;
|
|
33
|
-
cursor;
|
|
34
|
-
scroll;
|
|
35
|
-
spread;
|
|
36
380
|
locale;
|
|
37
381
|
useOnlyCssZoom = false;
|
|
382
|
+
diagnosticLogs = false;
|
|
383
|
+
// #endregion
|
|
384
|
+
// #region Control Visibility Properties
|
|
385
|
+
showOpenFile = true;
|
|
386
|
+
showAnnotations = false;
|
|
387
|
+
showDownload = true;
|
|
388
|
+
showViewBookmark = true;
|
|
389
|
+
showPrint = true;
|
|
390
|
+
showFullScreen = true;
|
|
391
|
+
showFind = true;
|
|
392
|
+
// #endregion
|
|
393
|
+
// #region Auto-Action Properties
|
|
394
|
+
downloadOnLoad = false;
|
|
395
|
+
printOnLoad = false;
|
|
396
|
+
rotateCW = false;
|
|
397
|
+
rotateCCW = false;
|
|
398
|
+
showLastPageOnLoad = false;
|
|
399
|
+
// #endregion
|
|
400
|
+
// #region Navigation Properties
|
|
401
|
+
namedDest;
|
|
402
|
+
// #endregion
|
|
403
|
+
// #region Error Handling Properties
|
|
38
404
|
errorOverride = false;
|
|
39
405
|
errorAppend = true;
|
|
40
406
|
errorMessage;
|
|
41
|
-
|
|
407
|
+
// #endregion
|
|
408
|
+
// #region Theme & Visual Customization Properties
|
|
409
|
+
theme = "light";
|
|
410
|
+
primaryColor;
|
|
411
|
+
backgroundColor;
|
|
412
|
+
pageBorderColor;
|
|
413
|
+
toolbarColor;
|
|
414
|
+
textColor;
|
|
415
|
+
borderRadius;
|
|
416
|
+
customCSS;
|
|
417
|
+
// #endregion
|
|
418
|
+
// #region Loading & Spinner Customization
|
|
419
|
+
customSpinnerTpl;
|
|
420
|
+
spinnerClass;
|
|
421
|
+
// #endregion
|
|
422
|
+
// #region Error Display Customization
|
|
423
|
+
customErrorTpl;
|
|
424
|
+
errorClass;
|
|
425
|
+
// #endregion
|
|
426
|
+
// #region Toolbar/Sidebar Group Visibility
|
|
427
|
+
showToolbarLeft = true;
|
|
428
|
+
showToolbarMiddle = true;
|
|
429
|
+
showToolbarRight = true;
|
|
430
|
+
showSecondaryToolbarToggle = true;
|
|
431
|
+
showSidebar = true;
|
|
432
|
+
showSidebarLeft = true;
|
|
433
|
+
showSidebarRight = true;
|
|
434
|
+
// #endregion
|
|
435
|
+
// #region Layout & Responsive Customization
|
|
436
|
+
toolbarDensity = "default";
|
|
437
|
+
sidebarWidth; // e.g., '280px'
|
|
438
|
+
toolbarPosition = "top";
|
|
439
|
+
sidebarPosition = "left";
|
|
440
|
+
responsiveBreakpoint;
|
|
441
|
+
// #endregion
|
|
442
|
+
// Internal loading state for overlay control
|
|
443
|
+
isLoading = true;
|
|
444
|
+
hasFirstRender = false;
|
|
445
|
+
// Internal error state for error display
|
|
446
|
+
hasError = false;
|
|
447
|
+
currentErrorMessage = "";
|
|
448
|
+
errorTemplateData = {};
|
|
449
|
+
// Helper method to get error template data
|
|
450
|
+
getErrorTemplateData() {
|
|
451
|
+
return {
|
|
452
|
+
errorMessage: this.currentErrorMessage,
|
|
453
|
+
errorClass: this.errorClass,
|
|
454
|
+
...this.errorTemplateData,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
// Error template button actions
|
|
458
|
+
reloadViewer() {
|
|
459
|
+
this.refresh();
|
|
460
|
+
}
|
|
461
|
+
goBack() {
|
|
462
|
+
if (window.history.length > 1) {
|
|
463
|
+
window.history.back();
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
window.close();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
closeViewer() {
|
|
470
|
+
window.close();
|
|
471
|
+
}
|
|
472
|
+
// #region Convenience Configuration Setters
|
|
473
|
+
set controlVisibility(config) {
|
|
474
|
+
if (config.download !== undefined)
|
|
475
|
+
this.showDownload = config.download;
|
|
476
|
+
if (config.print !== undefined)
|
|
477
|
+
this.showPrint = config.print;
|
|
478
|
+
if (config.find !== undefined)
|
|
479
|
+
this.showFind = config.find;
|
|
480
|
+
if (config.fullScreen !== undefined)
|
|
481
|
+
this.showFullScreen = config.fullScreen;
|
|
482
|
+
if (config.openFile !== undefined)
|
|
483
|
+
this.showOpenFile = config.openFile;
|
|
484
|
+
if (config.viewBookmark !== undefined)
|
|
485
|
+
this.showViewBookmark = config.viewBookmark;
|
|
486
|
+
if (config.annotations !== undefined)
|
|
487
|
+
this.showAnnotations = config.annotations;
|
|
488
|
+
}
|
|
489
|
+
set autoActions(config) {
|
|
490
|
+
if (config.downloadOnLoad !== undefined)
|
|
491
|
+
this.downloadOnLoad = config.downloadOnLoad;
|
|
492
|
+
if (config.printOnLoad !== undefined)
|
|
493
|
+
this.printOnLoad = config.printOnLoad;
|
|
494
|
+
if (config.showLastPageOnLoad !== undefined)
|
|
495
|
+
this.showLastPageOnLoad = config.showLastPageOnLoad;
|
|
496
|
+
if (config.rotateCW !== undefined)
|
|
497
|
+
this.rotateCW = config.rotateCW;
|
|
498
|
+
if (config.rotateCCW !== undefined)
|
|
499
|
+
this.rotateCCW = config.rotateCCW;
|
|
500
|
+
}
|
|
501
|
+
set errorHandling(config) {
|
|
502
|
+
if (config.override !== undefined)
|
|
503
|
+
this.errorOverride = config.override;
|
|
504
|
+
if (config.append !== undefined)
|
|
505
|
+
this.errorAppend = config.append;
|
|
506
|
+
if (config.message !== undefined)
|
|
507
|
+
this.errorMessage = config.message;
|
|
508
|
+
}
|
|
509
|
+
set viewerConfig(config) {
|
|
510
|
+
if (config.showSpinner !== undefined)
|
|
511
|
+
this.showSpinner = config.showSpinner;
|
|
512
|
+
if (config.useOnlyCssZoom !== undefined)
|
|
513
|
+
this.useOnlyCssZoom = config.useOnlyCssZoom;
|
|
514
|
+
if (config.diagnosticLogs !== undefined)
|
|
515
|
+
this.diagnosticLogs = config.diagnosticLogs;
|
|
516
|
+
if (config.locale !== undefined)
|
|
517
|
+
this.locale = config.locale;
|
|
518
|
+
}
|
|
519
|
+
set themeConfig(config) {
|
|
520
|
+
if (config.theme !== undefined)
|
|
521
|
+
this.theme = config.theme;
|
|
522
|
+
if (config.primaryColor !== undefined)
|
|
523
|
+
this.primaryColor = config.primaryColor;
|
|
524
|
+
if (config.backgroundColor !== undefined)
|
|
525
|
+
this.backgroundColor = config.backgroundColor;
|
|
526
|
+
if (config.pageBorderColor !== undefined)
|
|
527
|
+
this.pageBorderColor = config.pageBorderColor;
|
|
528
|
+
if (config.toolbarColor !== undefined)
|
|
529
|
+
this.toolbarColor = config.toolbarColor;
|
|
530
|
+
if (config.textColor !== undefined)
|
|
531
|
+
this.textColor = config.textColor;
|
|
532
|
+
if (config.borderRadius !== undefined)
|
|
533
|
+
this.borderRadius = config.borderRadius;
|
|
534
|
+
if (config.customCSS !== undefined)
|
|
535
|
+
this.customCSS = config.customCSS;
|
|
536
|
+
}
|
|
537
|
+
set groupVisibility(config) {
|
|
538
|
+
if (config.toolbarLeft !== undefined)
|
|
539
|
+
this.showToolbarLeft = config.toolbarLeft;
|
|
540
|
+
if (config.toolbarMiddle !== undefined)
|
|
541
|
+
this.showToolbarMiddle = config.toolbarMiddle;
|
|
542
|
+
if (config.toolbarRight !== undefined)
|
|
543
|
+
this.showToolbarRight = config.toolbarRight;
|
|
544
|
+
if (config.secondaryToolbarToggle !== undefined)
|
|
545
|
+
this.showSecondaryToolbarToggle = config.secondaryToolbarToggle;
|
|
546
|
+
if (config.sidebar !== undefined)
|
|
547
|
+
this.showSidebar = config.sidebar;
|
|
548
|
+
if (config.sidebarLeft !== undefined)
|
|
549
|
+
this.showSidebarLeft = config.sidebarLeft;
|
|
550
|
+
if (config.sidebarRight !== undefined)
|
|
551
|
+
this.showSidebarRight = config.sidebarRight;
|
|
552
|
+
}
|
|
553
|
+
set layoutConfig(config) {
|
|
554
|
+
if (config.toolbarDensity !== undefined)
|
|
555
|
+
this.toolbarDensity = config.toolbarDensity;
|
|
556
|
+
if (config.sidebarWidth !== undefined)
|
|
557
|
+
this.sidebarWidth = config.sidebarWidth;
|
|
558
|
+
if (config.toolbarPosition !== undefined)
|
|
559
|
+
this.toolbarPosition = config.toolbarPosition;
|
|
560
|
+
if (config.sidebarPosition !== undefined)
|
|
561
|
+
this.sidebarPosition = config.sidebarPosition;
|
|
562
|
+
if (config.responsiveBreakpoint !== undefined)
|
|
563
|
+
this.responsiveBreakpoint = config.responsiveBreakpoint;
|
|
564
|
+
}
|
|
565
|
+
// #endregion
|
|
566
|
+
// #region Helper function for deprecated properties
|
|
567
|
+
setDeprecatedProperty(oldName, newProperty, value) {
|
|
568
|
+
console.warn(`⚠️ DEPRECATED: Property "${oldName}" is deprecated. Use "${newProperty}" instead.`);
|
|
569
|
+
this[newProperty] = value;
|
|
570
|
+
}
|
|
571
|
+
// #endregion
|
|
572
|
+
// #region Deprecated Properties (Simplified)
|
|
573
|
+
/** @deprecated Use `downloadOnLoad` instead. This property will be removed in a future version. */
|
|
574
|
+
set startDownload(value) {
|
|
575
|
+
this.setDeprecatedProperty("startDownload", "downloadOnLoad", value);
|
|
576
|
+
}
|
|
577
|
+
/** @deprecated Use `printOnLoad` instead. This property will be removed in a future version. */
|
|
578
|
+
set startPrint(value) {
|
|
579
|
+
this.setDeprecatedProperty("startPrint", "printOnLoad", value);
|
|
580
|
+
}
|
|
581
|
+
/** @deprecated Use `showOpenFile` instead. This property will be removed in a future version. */
|
|
582
|
+
set openFile(value) {
|
|
583
|
+
this.setDeprecatedProperty("openFile", "showOpenFile", value);
|
|
584
|
+
}
|
|
585
|
+
/** @deprecated Use `showDownload` instead. This property will be removed in a future version. */
|
|
586
|
+
set download(value) {
|
|
587
|
+
this.setDeprecatedProperty("download", "showDownload", value);
|
|
588
|
+
}
|
|
589
|
+
/** @deprecated Use `showPrint` instead. This property will be removed in a future version. */
|
|
590
|
+
set print(value) {
|
|
591
|
+
this.setDeprecatedProperty("print", "showPrint", value);
|
|
592
|
+
}
|
|
593
|
+
/** @deprecated Use `showFullScreen` instead. This property will be removed in a future version. */
|
|
594
|
+
set fullScreen(value) {
|
|
595
|
+
this.setDeprecatedProperty("fullScreen", "showFullScreen", value);
|
|
596
|
+
}
|
|
597
|
+
/** @deprecated Use `showFind` instead. This property will be removed in a future version. */
|
|
598
|
+
set find(value) {
|
|
599
|
+
this.setDeprecatedProperty("find", "showFind", value);
|
|
600
|
+
}
|
|
601
|
+
/** @deprecated Use `showViewBookmark` instead. This property will be removed in a future version. */
|
|
602
|
+
set viewBookmark(value) {
|
|
603
|
+
this.setDeprecatedProperty("viewBookmark", "showViewBookmark", value);
|
|
604
|
+
}
|
|
605
|
+
/** @deprecated Use `showLastPageOnLoad` instead. This property will be removed in a future version. */
|
|
606
|
+
set lastPage(value) {
|
|
607
|
+
this.setDeprecatedProperty("lastPage", "showLastPageOnLoad", value);
|
|
608
|
+
}
|
|
609
|
+
// #endregion
|
|
610
|
+
// #region External Window Properties
|
|
42
611
|
externalWindowOptions;
|
|
43
612
|
viewerTab;
|
|
613
|
+
// #endregion
|
|
614
|
+
// #region Private Properties
|
|
44
615
|
_src;
|
|
45
616
|
_page;
|
|
617
|
+
isPostMessageReady = false;
|
|
618
|
+
postMessageReadiness = 0;
|
|
619
|
+
pendingInitialConfig = true;
|
|
620
|
+
initialConfigQueued = false;
|
|
621
|
+
actionQueueManager;
|
|
622
|
+
changeOriginTracker = new ChangeOriginTracker();
|
|
623
|
+
messageIdCounter = 0;
|
|
624
|
+
pendingMessages = new Map();
|
|
625
|
+
pendingChanges = [];
|
|
626
|
+
relaseUrl;
|
|
627
|
+
// #endregion
|
|
628
|
+
// #region Two-Way Binding Properties
|
|
629
|
+
// Private backing fields for two-way binding properties
|
|
630
|
+
_zoom = "auto";
|
|
631
|
+
_rotation = 0;
|
|
632
|
+
_cursor = "select";
|
|
633
|
+
_scroll = "vertical";
|
|
634
|
+
_spread = "none";
|
|
635
|
+
_pageMode = "none";
|
|
636
|
+
// Two-way binding Output events
|
|
637
|
+
zoomChange = new EventEmitter();
|
|
638
|
+
cursorChange = new EventEmitter();
|
|
639
|
+
scrollChange = new EventEmitter();
|
|
640
|
+
spreadChange = new EventEmitter();
|
|
641
|
+
pageModeChange = new EventEmitter();
|
|
642
|
+
/**
|
|
643
|
+
* Two-way binding for zoom level
|
|
644
|
+
* Supports: auto, page-fit, page-width, page-actual, percentage values (e.g., "150%")
|
|
645
|
+
*/
|
|
646
|
+
get zoom() {
|
|
647
|
+
return this._zoom;
|
|
648
|
+
}
|
|
649
|
+
set zoom(value) {
|
|
650
|
+
const normalizedValue = PropertyTransformers.transformZoom.toViewer(value);
|
|
651
|
+
if (this._zoom !== normalizedValue) {
|
|
652
|
+
this.changeOriginTracker.markProgrammatic("zoom");
|
|
653
|
+
this._zoom = normalizedValue;
|
|
654
|
+
this.applyZoomToViewer(this._zoom);
|
|
655
|
+
this.zoomChange.emit(this._zoom);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* One-way binding for document rotation
|
|
660
|
+
* Supports: 0, 90, 180, 270 degrees
|
|
661
|
+
*/
|
|
662
|
+
set rotation(value) {
|
|
663
|
+
const normalizedValue = PropertyTransformers.transformRotation.toViewer(value);
|
|
664
|
+
if (this._rotation !== normalizedValue) {
|
|
665
|
+
this._rotation = normalizedValue;
|
|
666
|
+
this.applyRotationToViewer(this._rotation);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
get rotation() {
|
|
670
|
+
return this._rotation;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Two-way binding for cursor mode
|
|
674
|
+
* Supports: select, hand, zoom
|
|
675
|
+
*/
|
|
676
|
+
get cursor() {
|
|
677
|
+
return this._cursor;
|
|
678
|
+
}
|
|
679
|
+
set cursor(value) {
|
|
680
|
+
const normalizedValue = PropertyTransformers.transformCursor.toViewer(value);
|
|
681
|
+
if (this._cursor !== normalizedValue) {
|
|
682
|
+
this.changeOriginTracker.markProgrammatic("cursor");
|
|
683
|
+
this._cursor = normalizedValue;
|
|
684
|
+
this.applyCursorToViewer(this._cursor);
|
|
685
|
+
this.cursorChange.emit(this._cursor);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Two-way binding for scroll mode
|
|
690
|
+
* Supports: vertical, horizontal, wrapped, page
|
|
691
|
+
*/
|
|
692
|
+
get scroll() {
|
|
693
|
+
return this._scroll;
|
|
694
|
+
}
|
|
695
|
+
set scroll(value) {
|
|
696
|
+
const normalizedValue = PropertyTransformers.transformScroll.toViewer(value);
|
|
697
|
+
if (this._scroll !== normalizedValue) {
|
|
698
|
+
this.changeOriginTracker.markProgrammatic("scroll");
|
|
699
|
+
this._scroll = normalizedValue;
|
|
700
|
+
this.applyScrollToViewer(this._scroll);
|
|
701
|
+
this.scrollChange.emit(this._scroll);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Two-way binding for spread mode
|
|
706
|
+
* Supports: none, odd, even
|
|
707
|
+
*/
|
|
708
|
+
get spread() {
|
|
709
|
+
return this._spread;
|
|
710
|
+
}
|
|
711
|
+
set spread(value) {
|
|
712
|
+
const normalizedValue = PropertyTransformers.transformSpread.toViewer(value);
|
|
713
|
+
if (this._spread !== normalizedValue) {
|
|
714
|
+
this.changeOriginTracker.markProgrammatic("spread");
|
|
715
|
+
this._spread = normalizedValue;
|
|
716
|
+
this.applySpreadToViewer(this._spread);
|
|
717
|
+
this.spreadChange.emit(this._spread);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Two-way binding for page mode (sidebar state)
|
|
722
|
+
* Supports: none, thumbs, bookmarks, attachments
|
|
723
|
+
*/
|
|
724
|
+
get pageMode() {
|
|
725
|
+
return this._pageMode;
|
|
726
|
+
}
|
|
727
|
+
set pageMode(value) {
|
|
728
|
+
const normalizedValue = PropertyTransformers.transformPageMode.toViewer(value);
|
|
729
|
+
if (this._pageMode !== normalizedValue) {
|
|
730
|
+
this.changeOriginTracker.markProgrammatic("pageMode");
|
|
731
|
+
this._pageMode = normalizedValue;
|
|
732
|
+
this.applyPageModeToViewer(this._pageMode);
|
|
733
|
+
this.pageModeChange.emit(this._pageMode);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
46
736
|
set page(_page) {
|
|
47
737
|
this._page = _page;
|
|
48
|
-
if (this.PDFViewerApplication) {
|
|
738
|
+
if (this.PDFViewerApplication && this.PDFViewerApplication.initialized) {
|
|
49
739
|
this.PDFViewerApplication.page = this._page;
|
|
50
740
|
}
|
|
51
741
|
else {
|
|
52
|
-
if (this.diagnosticLogs)
|
|
742
|
+
if (this.diagnosticLogs) {
|
|
53
743
|
console.warn("Document is not loaded yet!!!. Try to set page# after full load. Ignore this warning if you are not setting page# using '.' notation. (E.g. pdfViewer.page = 5;)");
|
|
744
|
+
}
|
|
54
745
|
}
|
|
55
746
|
}
|
|
56
747
|
get page() {
|
|
57
|
-
if (this.PDFViewerApplication) {
|
|
748
|
+
if (this.PDFViewerApplication && this.PDFViewerApplication.initialized) {
|
|
58
749
|
return this.PDFViewerApplication.page;
|
|
59
750
|
}
|
|
60
751
|
else {
|
|
61
|
-
if (this.diagnosticLogs)
|
|
752
|
+
if (this.diagnosticLogs) {
|
|
62
753
|
console.warn("Document is not loaded yet!!!. Try to retrieve page# after full load.");
|
|
754
|
+
}
|
|
755
|
+
return this._page || 1;
|
|
63
756
|
}
|
|
64
757
|
}
|
|
65
758
|
set pdfSrc(_src) {
|
|
@@ -68,6 +761,8 @@ class PdfJsViewerComponent {
|
|
|
68
761
|
get pdfSrc() {
|
|
69
762
|
return this._src;
|
|
70
763
|
}
|
|
764
|
+
// #endregion
|
|
765
|
+
// #region PDF.js Application Access Properties
|
|
71
766
|
get PDFViewerApplicationOptions() {
|
|
72
767
|
let pdfViewerOptions = null;
|
|
73
768
|
if (this.externalWindow) {
|
|
@@ -77,7 +772,8 @@ class PdfJsViewerComponent {
|
|
|
77
772
|
}
|
|
78
773
|
else {
|
|
79
774
|
if (this.iframe.nativeElement.contentWindow) {
|
|
80
|
-
pdfViewerOptions =
|
|
775
|
+
pdfViewerOptions =
|
|
776
|
+
this.iframe.nativeElement.contentWindow.PDFViewerApplicationOptions;
|
|
81
777
|
}
|
|
82
778
|
}
|
|
83
779
|
return pdfViewerOptions;
|
|
@@ -91,59 +787,767 @@ class PdfJsViewerComponent {
|
|
|
91
787
|
}
|
|
92
788
|
else {
|
|
93
789
|
if (this.iframe.nativeElement.contentWindow) {
|
|
94
|
-
pdfViewer =
|
|
790
|
+
pdfViewer =
|
|
791
|
+
this.iframe.nativeElement.contentWindow.PDFViewerApplication;
|
|
95
792
|
}
|
|
96
793
|
}
|
|
794
|
+
if (this.diagnosticLogs)
|
|
795
|
+
console.debug("PdfJsViewer: Viewer ->", pdfViewer);
|
|
97
796
|
return pdfViewer;
|
|
98
797
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
798
|
+
// #endregion
|
|
799
|
+
// #endregion
|
|
800
|
+
// #region Lifecycle Methods
|
|
801
|
+
ngOnInit() {
|
|
802
|
+
// 🟢 TEST LOG - Build verification (BUILD_ID from separate file)
|
|
803
|
+
console.log("🟢 ng2-pdfjs-viewer.component.ts: TEST LOG - BUILD_ID:", window.NG2_PDF_VIEWER_BUILD_ID || "BUILD_ID_NOT_LOADED");
|
|
804
|
+
// Configure action queue manager with diagnostic logs
|
|
805
|
+
this.actionQueueManager = new ActionQueueManager(this.diagnosticLogs);
|
|
806
|
+
// Connect action queue manager to PostMessage system
|
|
807
|
+
this.actionQueueManager.setPostMessageExecutor((action, payload) => this.sendControlMessage(action, payload));
|
|
808
|
+
// Set up PostMessage listener
|
|
809
|
+
this.setupMessageListener();
|
|
810
|
+
// Load PDF for embedded views.
|
|
811
|
+
if (!this.externalWindow) {
|
|
812
|
+
this.loadPdf();
|
|
813
|
+
}
|
|
814
|
+
// Bind events.
|
|
815
|
+
this.bindToPdfJsEventBus();
|
|
816
|
+
}
|
|
817
|
+
ngAfterViewInit() {
|
|
818
|
+
// Minimal initialization - rely on event-driven readiness notifications
|
|
819
|
+
}
|
|
820
|
+
ngOnChanges(changes) {
|
|
821
|
+
if (this.PDFViewerApplication) {
|
|
822
|
+
// Only apply changes if PostMessage API is ready and viewer is initialized
|
|
823
|
+
if (this.isPostMessageReady && this.PDFViewerApplication.initialized) {
|
|
824
|
+
this.applyChanges(changes);
|
|
825
|
+
}
|
|
826
|
+
else {
|
|
827
|
+
this.pendingChanges.push(changes);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
this.pendingChanges.push(changes);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
ngOnDestroy() {
|
|
835
|
+
// Clean up pending messages
|
|
836
|
+
this.pendingMessages.clear();
|
|
837
|
+
// Clean up event listeners
|
|
838
|
+
ComponentUtils.cleanupEventHandlers(this);
|
|
839
|
+
// Reset state flags
|
|
840
|
+
this.initialConfigQueued = false;
|
|
841
|
+
// Clean up URL
|
|
842
|
+
this.relaseUrl?.();
|
|
843
|
+
}
|
|
844
|
+
// #endregion
|
|
845
|
+
// #region Message Handling Methods
|
|
846
|
+
generateMessageId() {
|
|
847
|
+
return `msg_${++this.messageIdCounter}_${Date.now()}`;
|
|
848
|
+
}
|
|
849
|
+
sendControlMessage(action, payload) {
|
|
850
|
+
return new Promise((resolve, reject) => {
|
|
851
|
+
const messageId = this.generateMessageId();
|
|
852
|
+
const message = {
|
|
853
|
+
type: "control-update",
|
|
854
|
+
action,
|
|
855
|
+
payload,
|
|
856
|
+
id: messageId,
|
|
857
|
+
timestamp: Date.now(),
|
|
858
|
+
};
|
|
859
|
+
this.pendingMessages.set(messageId, { resolve, reject });
|
|
860
|
+
// Send message to iframe
|
|
861
|
+
if (this.iframe &&
|
|
862
|
+
this.iframe.nativeElement &&
|
|
863
|
+
this.iframe.nativeElement.contentWindow) {
|
|
864
|
+
this.iframe.nativeElement.contentWindow.postMessage(message, "*");
|
|
865
|
+
}
|
|
866
|
+
else {
|
|
867
|
+
this.pendingMessages.delete(messageId);
|
|
868
|
+
reject(new Error("Iframe not available"));
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
handleControlResponse(response) {
|
|
873
|
+
const pendingMessage = this.pendingMessages.get(response.id);
|
|
874
|
+
if (pendingMessage) {
|
|
875
|
+
this.pendingMessages.delete(response.id);
|
|
876
|
+
if (response.success) {
|
|
877
|
+
pendingMessage.resolve(response);
|
|
878
|
+
}
|
|
879
|
+
else {
|
|
880
|
+
pendingMessage.reject(new Error(response.error || "Unknown error"));
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
setupMessageListener() {
|
|
885
|
+
window.addEventListener("message", (event) => {
|
|
886
|
+
// Handle control responses from the viewer
|
|
887
|
+
if (event.data && event.data.type === "control-response") {
|
|
888
|
+
this.handleControlResponse(event.data);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
// Handle PostMessage API ready notification
|
|
892
|
+
if (event.data && event.data.type === "postmessage-ready") {
|
|
893
|
+
this.isPostMessageReady = true;
|
|
894
|
+
this.postMessageReadiness = event.data.readiness || 0;
|
|
895
|
+
// CRITICAL FIX: Process queued actions when readiness level increases
|
|
896
|
+
if (this.actionQueueManager) {
|
|
897
|
+
this.actionQueueManager.updateReadiness(this.postMessageReadiness);
|
|
898
|
+
this.actionQueueManager.processQueuedActions();
|
|
107
899
|
}
|
|
108
|
-
|
|
109
|
-
|
|
900
|
+
// Queue all initial configurations now that PostMessage API is ready (only once)
|
|
901
|
+
if (!this.initialConfigQueued) {
|
|
902
|
+
this.queueAllConfigurations();
|
|
903
|
+
this.initialConfigQueued = true;
|
|
110
904
|
}
|
|
111
|
-
|
|
112
|
-
|
|
905
|
+
// Apply any pending changes that occurred before PostMessage API was ready
|
|
906
|
+
this.applyPendingChanges();
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
// Handle state change notifications from PostMessage wrapper
|
|
910
|
+
if (event.data && event.data.type === "state-change") {
|
|
911
|
+
this.handleStateChangeNotification(event.data);
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
// Handle event notifications from PostMessage wrapper
|
|
915
|
+
if (event.data && event.data.type === "event-notification") {
|
|
916
|
+
this.handleEventNotification(event.data);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
handleStateChangeNotification(notification) {
|
|
922
|
+
const { property, value, source } = notification;
|
|
923
|
+
// Internal loading overlay control is system-driven and must be handled unconditionally
|
|
924
|
+
if (property === "loading") {
|
|
925
|
+
this.isLoading = !!value;
|
|
926
|
+
// Clear error state when loading starts
|
|
927
|
+
if (value) {
|
|
928
|
+
this.hasError = false;
|
|
929
|
+
this.currentErrorMessage = "";
|
|
930
|
+
}
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
// Internal error state management
|
|
934
|
+
if (property === "error") {
|
|
935
|
+
this.hasError = !!value;
|
|
936
|
+
if (value && typeof value === "string") {
|
|
937
|
+
this.currentErrorMessage = value;
|
|
938
|
+
this.errorTemplateData = this.getErrorTemplateData();
|
|
939
|
+
}
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
// Only process user-initiated changes to avoid infinite loops
|
|
943
|
+
if (source === "user" &&
|
|
944
|
+
!this.changeOriginTracker.isProgrammatic(property)) {
|
|
945
|
+
this.changeOriginTracker.markUserInitiated(property);
|
|
946
|
+
switch (property) {
|
|
947
|
+
case "cursor":
|
|
948
|
+
if (this._cursor !== value) {
|
|
949
|
+
this._cursor =
|
|
950
|
+
PropertyTransformers.transformCursor.fromViewer(value);
|
|
951
|
+
this.cursorChange.emit(this._cursor);
|
|
952
|
+
}
|
|
953
|
+
break;
|
|
954
|
+
case "scroll":
|
|
955
|
+
if (this._scroll !== value) {
|
|
956
|
+
this._scroll =
|
|
957
|
+
PropertyTransformers.transformScroll.fromViewer(value);
|
|
958
|
+
this.scrollChange.emit(this._scroll);
|
|
959
|
+
}
|
|
960
|
+
break;
|
|
961
|
+
case "spread":
|
|
962
|
+
if (this._spread !== value) {
|
|
963
|
+
this._spread =
|
|
964
|
+
PropertyTransformers.transformSpread.fromViewer(value);
|
|
965
|
+
this.spreadChange.emit(this._spread);
|
|
966
|
+
}
|
|
967
|
+
break;
|
|
968
|
+
case "pageMode":
|
|
969
|
+
if (this._pageMode !== value) {
|
|
970
|
+
this._pageMode =
|
|
971
|
+
PropertyTransformers.transformPageMode.fromViewer(value);
|
|
972
|
+
this.pageModeChange.emit(this._pageMode);
|
|
973
|
+
}
|
|
974
|
+
break;
|
|
975
|
+
case "zoom":
|
|
976
|
+
if (this._zoom !== value) {
|
|
977
|
+
this._zoom = PropertyTransformers.transformZoom.fromViewer(value);
|
|
978
|
+
this.zoomChange.emit(this._zoom);
|
|
979
|
+
}
|
|
980
|
+
break;
|
|
981
|
+
case "rotation":
|
|
982
|
+
if (this._rotation !== value) {
|
|
983
|
+
this._rotation =
|
|
984
|
+
PropertyTransformers.transformRotation.fromViewer(value);
|
|
985
|
+
}
|
|
986
|
+
break;
|
|
987
|
+
// Note: namedDest is now a simple input property, not a two-way binding
|
|
988
|
+
default:
|
|
989
|
+
if (this.diagnosticLogs) {
|
|
990
|
+
console.log(`🔍 PdfJsViewer: Unknown state change property: ${property}`);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
handleEventNotification(notification) {
|
|
996
|
+
const { eventName, eventData } = notification;
|
|
997
|
+
// Emit the appropriate event based on the event name
|
|
998
|
+
switch (eventName) {
|
|
999
|
+
case "documentError":
|
|
1000
|
+
this.onDocumentError.emit(eventData);
|
|
1001
|
+
break;
|
|
1002
|
+
case "documentInit":
|
|
1003
|
+
this.onDocumentInit.emit();
|
|
1004
|
+
break;
|
|
1005
|
+
case "pagesInit":
|
|
1006
|
+
this.onPagesInit.emit(eventData);
|
|
1007
|
+
break;
|
|
1008
|
+
case "presentationModeChanged":
|
|
1009
|
+
this.onPresentationModeChanged.emit(eventData);
|
|
1010
|
+
break;
|
|
1011
|
+
case "openFile":
|
|
1012
|
+
this.onOpenFile.emit();
|
|
1013
|
+
break;
|
|
1014
|
+
case "find":
|
|
1015
|
+
this.onFind.emit(eventData);
|
|
1016
|
+
break;
|
|
1017
|
+
case "updateFindMatchesCount":
|
|
1018
|
+
this.onUpdateFindMatchesCount.emit(eventData);
|
|
1019
|
+
break;
|
|
1020
|
+
case "metadataLoaded":
|
|
1021
|
+
this.onMetadataLoaded.emit(eventData);
|
|
1022
|
+
break;
|
|
1023
|
+
case "outlineLoaded":
|
|
1024
|
+
this.onOutlineLoaded.emit(eventData);
|
|
1025
|
+
break;
|
|
1026
|
+
case "pageRendered":
|
|
1027
|
+
this.onPageRendered.emit(eventData);
|
|
1028
|
+
break;
|
|
1029
|
+
case "annotationLayerRendered":
|
|
1030
|
+
this.onAnnotationLayerRendered.emit(eventData);
|
|
1031
|
+
break;
|
|
1032
|
+
case "bookmarkClick":
|
|
1033
|
+
this.onBookmarkClick.emit(eventData);
|
|
1034
|
+
break;
|
|
1035
|
+
case "idle":
|
|
1036
|
+
this.onIdle.emit();
|
|
1037
|
+
break;
|
|
1038
|
+
default:
|
|
1039
|
+
if (this.diagnosticLogs) {
|
|
1040
|
+
console.log(`🔍 PdfJsViewer: Unknown event notification: ${eventName}`);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
// #endregion
|
|
1045
|
+
// #region Property Mapping and Update Methods
|
|
1046
|
+
mapPropertyToAction(propertyName) {
|
|
1047
|
+
return ComponentUtils.getActionForProperty(propertyName);
|
|
1048
|
+
}
|
|
1049
|
+
updateViewerControl(propertyName, value) {
|
|
1050
|
+
const action = this.mapPropertyToAction(propertyName);
|
|
1051
|
+
if (action) {
|
|
1052
|
+
// Use universal dispatcher instead of direct PostMessage
|
|
1053
|
+
this.dispatchAction(action, value, "property-change");
|
|
1054
|
+
}
|
|
1055
|
+
else {
|
|
1056
|
+
// Property is intentionally not mapped (handled via query parameters or direct API)
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
applyChanges(changes) {
|
|
1060
|
+
Object.keys(changes).forEach((propertyName) => {
|
|
1061
|
+
const change = changes[propertyName];
|
|
1062
|
+
if (change.currentValue !== change.previousValue) {
|
|
1063
|
+
// Handle auto-actions - queue for document load, don't execute immediately
|
|
1064
|
+
const autoActions = [
|
|
1065
|
+
"downloadOnLoad",
|
|
1066
|
+
"printOnLoad",
|
|
1067
|
+
"showLastPageOnLoad",
|
|
1068
|
+
"rotateCW",
|
|
1069
|
+
"rotateCCW",
|
|
1070
|
+
];
|
|
1071
|
+
if (autoActions.includes(propertyName)) {
|
|
1072
|
+
// Re-queue all configurations when auto-actions change
|
|
1073
|
+
this.initialConfigQueued = false;
|
|
1074
|
+
if (this.isPostMessageReady) {
|
|
1075
|
+
this.queueAllConfigurations();
|
|
1076
|
+
this.initialConfigQueued = true;
|
|
1077
|
+
}
|
|
1078
|
+
return;
|
|
113
1079
|
}
|
|
114
|
-
|
|
115
|
-
|
|
1080
|
+
// Use universal dispatcher for ALL actions - pure event-driven approach
|
|
1081
|
+
const action = this.mapPropertyToAction(propertyName);
|
|
1082
|
+
if (action) {
|
|
1083
|
+
this.dispatchAction(action, change.currentValue, "property-change");
|
|
116
1084
|
}
|
|
117
1085
|
}
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
applyPendingChanges() {
|
|
1089
|
+
// Only apply pending changes if PostMessage API is ready
|
|
1090
|
+
if (!this.isPostMessageReady) {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
if (this.pendingChanges.length > 0) {
|
|
1094
|
+
this.pendingChanges.forEach((changes, index) => {
|
|
1095
|
+
this.processChangesForQueuing(changes);
|
|
1096
|
+
});
|
|
1097
|
+
this.pendingChanges = [];
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
118
1100
|
}
|
|
119
1101
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
1102
|
+
processChangesForQueuing(changes) {
|
|
1103
|
+
Object.keys(changes).forEach((propertyName) => {
|
|
1104
|
+
const change = changes[propertyName];
|
|
1105
|
+
if (change.currentValue !== change.previousValue) {
|
|
1106
|
+
// Handle auto-actions - queue for document load, don't execute immediately
|
|
1107
|
+
const autoActions = [
|
|
1108
|
+
"downloadOnLoad",
|
|
1109
|
+
"printOnLoad",
|
|
1110
|
+
"showLastPageOnLoad",
|
|
1111
|
+
"rotateCW",
|
|
1112
|
+
"rotateCCW",
|
|
1113
|
+
];
|
|
1114
|
+
if (autoActions.includes(propertyName)) {
|
|
1115
|
+
// Re-queue all configurations when auto-actions change
|
|
1116
|
+
this.initialConfigQueued = false;
|
|
1117
|
+
if (this.isPostMessageReady) {
|
|
1118
|
+
this.queueAllConfigurations();
|
|
1119
|
+
this.initialConfigQueued = true;
|
|
1120
|
+
}
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
// Use universal dispatcher for ALL actions - pure event-driven approach
|
|
1124
|
+
const action = this.mapPropertyToAction(propertyName);
|
|
1125
|
+
if (action) {
|
|
1126
|
+
this.dispatchAction(action, change.currentValue, "property-change");
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
// #endregion
|
|
1132
|
+
// #region PDF.js Event Binding Methods
|
|
1133
|
+
/**
|
|
1134
|
+
* Waits for the PDF.js viewer to be ready, and binds the the event bus.
|
|
1135
|
+
*/
|
|
1136
|
+
bindToPdfJsEventBus() {
|
|
1137
|
+
// Store the event listener reference so we can remove it later
|
|
1138
|
+
const webviewerLoadedHandler = () => {
|
|
1139
|
+
if (this.diagnosticLogs)
|
|
1140
|
+
console.debug("PdfJsViewer: webviewerloaded event received");
|
|
1141
|
+
// Set locale immediately when PDF.js is loaded but before it initializes
|
|
1142
|
+
// https://github.com/mozilla/pdf.js/issues/11829#issuecomment-617668679
|
|
1143
|
+
if (this.locale && this.iframe?.nativeElement?.contentWindow) {
|
|
1144
|
+
try {
|
|
1145
|
+
const iframeWindow = this.iframe.nativeElement.contentWindow;
|
|
1146
|
+
if (iframeWindow.PDFViewerApplicationOptions) {
|
|
1147
|
+
iframeWindow.PDFViewerApplicationOptions.set("localeProperties", {
|
|
1148
|
+
lang: this.locale,
|
|
1149
|
+
});
|
|
1150
|
+
if (this.diagnosticLogs)
|
|
1151
|
+
console.debug(`PdfJsViewer: Locale set to ${this.locale} before initialization`);
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
catch (error) {
|
|
1155
|
+
if (this.diagnosticLogs)
|
|
1156
|
+
console.debug("PdfJsViewer: Could not set locale before initialization:", error);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
if (!this.PDFViewerApplication) {
|
|
1160
|
+
if (this.diagnosticLogs)
|
|
1161
|
+
console.debug("PdfJsViewer: Viewer not yet (or no longer) available, events can not yet be bound.");
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
// https://github.com/mozilla/pdf.js/issues/9527
|
|
1165
|
+
this.PDFViewerApplication.initializedPromise.then(() => {
|
|
1166
|
+
// All configurations are now handled via PostMessage system
|
|
1167
|
+
// No need to call configureVisibleFeatures() anymore
|
|
1168
|
+
// Apply any pending changes that occurred before initialization
|
|
1169
|
+
this.applyPendingChanges();
|
|
1170
|
+
const app = this.PDFViewerApplication;
|
|
1171
|
+
const eventBus = app.eventBus;
|
|
1172
|
+
// Store event handler references for cleanup
|
|
1173
|
+
const documentLoadedHandler = () => {
|
|
1174
|
+
if (this.diagnosticLogs)
|
|
1175
|
+
console.debug("PdfJsViewer: The document has now been loaded!");
|
|
1176
|
+
this.onDocumentLoad.emit();
|
|
1177
|
+
// Queue auto-actions for this document load (not from component initialization)
|
|
1178
|
+
this.queueAutoActionsForDocumentLoad();
|
|
1179
|
+
// Execute all queued auto-actions
|
|
1180
|
+
this.actionQueueManager.onDocumentLoaded();
|
|
1181
|
+
};
|
|
1182
|
+
// Note: pagesInit event is now handled via the PostMessage wrapper event system
|
|
1183
|
+
const pagesLoadedHandler = () => {
|
|
1184
|
+
if (this.diagnosticLogs)
|
|
1185
|
+
console.debug("PdfJsViewer: All pages have been fully loaded!");
|
|
1186
|
+
// Execute auto-print on pages loaded (ensures PDF is fully ready for printing)
|
|
1187
|
+
if (this.printOnLoad === true) {
|
|
1188
|
+
this.dispatchAction("trigger-print", true, "initial-load");
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
const beforePrintHandler = () => {
|
|
1192
|
+
if (this.diagnosticLogs)
|
|
1193
|
+
console.debug("PdfJsViewer: The document is about to be printed!");
|
|
1194
|
+
this.onBeforePrint.emit();
|
|
1195
|
+
};
|
|
1196
|
+
const afterPrintHandler = () => {
|
|
1197
|
+
if (this.diagnosticLogs)
|
|
1198
|
+
console.debug("PdfJsViewer: The document has been printed!");
|
|
1199
|
+
this.onAfterPrint.emit();
|
|
1200
|
+
};
|
|
1201
|
+
const pageChangingHandler = (event) => {
|
|
1202
|
+
if (this.diagnosticLogs)
|
|
1203
|
+
console.debug("PdfJsViewer: The page has changed:", event.pageNumber);
|
|
1204
|
+
// Update two-way binding for page
|
|
1205
|
+
if (this._page !== event.pageNumber &&
|
|
1206
|
+
!this.changeOriginTracker.isProgrammatic("page")) {
|
|
1207
|
+
this.changeOriginTracker.markUserInitiated("page");
|
|
1208
|
+
this._page = event.pageNumber;
|
|
1209
|
+
// Note: page property uses existing setter/getter, no need to emit pageChange here
|
|
1210
|
+
}
|
|
1211
|
+
this.onPageChange.emit(event.pageNumber);
|
|
1212
|
+
};
|
|
1213
|
+
const rotationChangingHandler = (event) => {
|
|
1214
|
+
const newRotation = {
|
|
1215
|
+
rotation: event.pagesRotation,
|
|
1216
|
+
page: event.pageNumber,
|
|
1217
|
+
};
|
|
1218
|
+
if (this.diagnosticLogs)
|
|
1219
|
+
console.debug("PdfJsViewer: The rotation has changed!", event);
|
|
1220
|
+
// Update two-way binding for rotation
|
|
1221
|
+
const normalizedRotation = PropertyTransformers.transformRotation.fromViewer(event.pagesRotation);
|
|
1222
|
+
if (this._rotation !== normalizedRotation &&
|
|
1223
|
+
!this.changeOriginTracker.isProgrammatic("rotation")) {
|
|
1224
|
+
this.changeOriginTracker.markUserInitiated("rotation");
|
|
1225
|
+
this._rotation = normalizedRotation;
|
|
1226
|
+
}
|
|
1227
|
+
this.onRotationChange.emit(newRotation);
|
|
1228
|
+
};
|
|
1229
|
+
const scaleChangingHandler = (event) => {
|
|
1230
|
+
const newScale = event.scale;
|
|
1231
|
+
if (this.diagnosticLogs)
|
|
1232
|
+
console.debug("PdfJsViewer: The document has scale has changed!", newScale);
|
|
1233
|
+
// Update two-way binding for zoom
|
|
1234
|
+
const normalizedZoom = PropertyTransformers.transformZoom.fromViewer(event.scale);
|
|
1235
|
+
if (this._zoom !== normalizedZoom &&
|
|
1236
|
+
!this.changeOriginTracker.isProgrammatic("zoom")) {
|
|
1237
|
+
this.changeOriginTracker.markUserInitiated("zoom");
|
|
1238
|
+
this._zoom = normalizedZoom;
|
|
1239
|
+
this.zoomChange.emit(normalizedZoom);
|
|
1240
|
+
}
|
|
1241
|
+
this.onScaleChange.emit(newScale);
|
|
1242
|
+
};
|
|
1243
|
+
// Store handlers for cleanup
|
|
1244
|
+
this._pdfEventHandlers = {
|
|
1245
|
+
documentloaded: documentLoadedHandler,
|
|
1246
|
+
pagesloaded: pagesLoadedHandler,
|
|
1247
|
+
beforeprint: beforePrintHandler,
|
|
1248
|
+
afterprint: afterPrintHandler,
|
|
1249
|
+
pagechanging: pageChangingHandler,
|
|
1250
|
+
rotationchanging: rotationChangingHandler,
|
|
1251
|
+
scalechanging: scaleChangingHandler,
|
|
1252
|
+
};
|
|
1253
|
+
// Attach event listeners
|
|
1254
|
+
eventBus.on("documentloaded", documentLoadedHandler);
|
|
1255
|
+
eventBus.on("pagesloaded", pagesLoadedHandler);
|
|
1256
|
+
eventBus.on("beforeprint", beforePrintHandler);
|
|
1257
|
+
eventBus.on("afterprint", afterPrintHandler);
|
|
1258
|
+
eventBus.on("pagechanging", pageChangingHandler);
|
|
1259
|
+
eventBus.on("rotationchanging", rotationChangingHandler);
|
|
1260
|
+
eventBus.on("scalechanging", scaleChangingHandler);
|
|
1261
|
+
});
|
|
1262
|
+
};
|
|
1263
|
+
// Store the handler reference for cleanup
|
|
1264
|
+
this._webviewerLoadedHandler = webviewerLoadedHandler;
|
|
1265
|
+
document.addEventListener("webviewerloaded", webviewerLoadedHandler);
|
|
1266
|
+
}
|
|
1267
|
+
// #endregion
|
|
1268
|
+
// #region Configuration and Action Queue Methods
|
|
1269
|
+
queueAllConfigurations() {
|
|
1270
|
+
// Queue control visibility configurations (immediate actions)
|
|
1271
|
+
this.queueConfiguration("showOpenFile", this.showOpenFile, "show-openfile");
|
|
1272
|
+
this.queueConfiguration("showDownload", this.showDownload, "show-download");
|
|
1273
|
+
this.queueConfiguration("showPrint", this.showPrint, "show-print");
|
|
1274
|
+
this.queueConfiguration("showFullScreen", this.showFullScreen, "show-fullscreen");
|
|
1275
|
+
this.queueConfiguration("showFind", this.showFind, "show-find");
|
|
1276
|
+
this.queueConfiguration("showViewBookmark", this.showViewBookmark, "show-bookmark");
|
|
1277
|
+
this.queueConfiguration("showAnnotations", this.showAnnotations, "show-annotations");
|
|
1278
|
+
// Toolbar/Sidebar group visibility
|
|
1279
|
+
this.queueConfiguration("showToolbarLeft", this.showToolbarLeft, "show-toolbar-left");
|
|
1280
|
+
this.queueConfiguration("showToolbarMiddle", this.showToolbarMiddle, "show-toolbar-middle");
|
|
1281
|
+
this.queueConfiguration("showToolbarRight", this.showToolbarRight, "show-toolbar-right");
|
|
1282
|
+
this.queueConfiguration("showSecondaryToolbarToggle", this.showSecondaryToolbarToggle, "show-secondary-toolbar-toggle");
|
|
1283
|
+
this.queueConfiguration("showSidebar", this.showSidebar, "show-sidebar");
|
|
1284
|
+
this.queueConfiguration("showSidebarLeft", this.showSidebarLeft, "show-sidebar-left");
|
|
1285
|
+
this.queueConfiguration("showSidebarRight", this.showSidebarRight, "show-sidebar-right");
|
|
1286
|
+
// Layout customization
|
|
1287
|
+
this.queueConfiguration("toolbarDensity", this.toolbarDensity, "set-toolbar-density");
|
|
1288
|
+
if (this.sidebarWidth) {
|
|
1289
|
+
this.queueConfiguration("sidebarWidth", this.sidebarWidth, "set-sidebar-width");
|
|
1290
|
+
}
|
|
1291
|
+
this.queueConfiguration("toolbarPosition", this.toolbarPosition, "set-toolbar-position");
|
|
1292
|
+
this.queueConfiguration("sidebarPosition", this.sidebarPosition, "set-sidebar-position");
|
|
1293
|
+
if (this.responsiveBreakpoint !== undefined) {
|
|
1294
|
+
this.queueConfiguration("responsiveBreakpoint", this.responsiveBreakpoint, "set-responsive-breakpoint");
|
|
1295
|
+
}
|
|
1296
|
+
// Queue mode configurations (immediate actions)
|
|
1297
|
+
if (this.cursor) {
|
|
1298
|
+
this.queueConfiguration("cursor", this.cursor, "set-cursor");
|
|
1299
|
+
}
|
|
1300
|
+
if (this.scroll) {
|
|
1301
|
+
this.queueConfiguration("scroll", this.scroll, "set-scroll");
|
|
1302
|
+
}
|
|
1303
|
+
if (this.spread) {
|
|
1304
|
+
this.queueConfiguration("spread", this.spread, "set-spread");
|
|
1305
|
+
}
|
|
1306
|
+
// Queue navigation configurations (immediate actions)
|
|
1307
|
+
if (this._page) {
|
|
1308
|
+
this.queueConfiguration("page", this._page, "set-page");
|
|
1309
|
+
}
|
|
1310
|
+
if (this.zoom) {
|
|
1311
|
+
this.queueConfiguration("zoom", this.zoom, "set-zoom");
|
|
1312
|
+
}
|
|
1313
|
+
// Note: zoom is now handled by two-way binding [(zoom)]
|
|
1314
|
+
// Queue navigation configuration if specified
|
|
1315
|
+
if (this.namedDest && this.namedDest.trim() !== "") {
|
|
1316
|
+
this.queueConfiguration("namedDest", this.namedDest, "go-to-named-dest");
|
|
1317
|
+
}
|
|
1318
|
+
if (this.pageMode) {
|
|
1319
|
+
this.queueConfiguration("pageMode", this.pageMode, "update-page-mode");
|
|
1320
|
+
}
|
|
1321
|
+
// Queue rotation configurations (immediate actions)
|
|
1322
|
+
if (this.rotateCW === true) {
|
|
1323
|
+
this.queueConfiguration("rotateCW", this.rotateCW, "trigger-rotate-cw");
|
|
1324
|
+
}
|
|
1325
|
+
if (this.rotateCCW === true) {
|
|
1326
|
+
this.queueConfiguration("rotateCCW", this.rotateCCW, "trigger-rotate-ccw");
|
|
1327
|
+
}
|
|
1328
|
+
// Queue error handling configurations (non-auto-actions)
|
|
1329
|
+
if (this.errorMessage) {
|
|
1330
|
+
this.queueConfiguration("errorMessage", this.errorMessage, "set-error-message");
|
|
1331
|
+
}
|
|
1332
|
+
if (this.errorOverride !== undefined) {
|
|
1333
|
+
this.queueConfiguration("errorOverride", this.errorOverride, "set-error-override");
|
|
1334
|
+
}
|
|
1335
|
+
if (this.errorAppend !== undefined) {
|
|
1336
|
+
this.queueConfiguration("errorAppend", this.errorAppend, "set-error-append");
|
|
1337
|
+
}
|
|
1338
|
+
// Queue theme and visual customization configurations
|
|
1339
|
+
// Always queue theme to ensure initial styles are applied
|
|
1340
|
+
this.queueConfiguration("theme", this.theme || "light", "set-theme");
|
|
1341
|
+
if (this.primaryColor) {
|
|
1342
|
+
this.queueConfiguration("primaryColor", this.primaryColor, "set-primary-color");
|
|
1343
|
+
}
|
|
1344
|
+
if (this.backgroundColor) {
|
|
1345
|
+
this.queueConfiguration("backgroundColor", this.backgroundColor, "set-background-color");
|
|
1346
|
+
}
|
|
1347
|
+
if (this.pageBorderColor) {
|
|
1348
|
+
this.queueConfiguration("pageBorderColor", this.pageBorderColor, "set-page-border-color");
|
|
1349
|
+
}
|
|
1350
|
+
if (this.toolbarColor) {
|
|
1351
|
+
this.queueConfiguration("toolbarColor", this.toolbarColor, "set-toolbar-color");
|
|
1352
|
+
}
|
|
1353
|
+
if (this.textColor) {
|
|
1354
|
+
this.queueConfiguration("textColor", this.textColor, "set-text-color");
|
|
1355
|
+
}
|
|
1356
|
+
if (this.borderRadius) {
|
|
1357
|
+
this.queueConfiguration("borderRadius", this.borderRadius, "set-border-radius");
|
|
1358
|
+
}
|
|
1359
|
+
if (this.customCSS) {
|
|
1360
|
+
this.queueConfiguration("customCSS", this.customCSS, "set-custom-css");
|
|
1361
|
+
}
|
|
1362
|
+
// Queue CSS zoom configurations (immediate actions)
|
|
1363
|
+
// Note: Locale is now set via URL parameter, not PostMessage
|
|
1364
|
+
if (this.useOnlyCssZoom !== undefined) {
|
|
1365
|
+
this.queueConfiguration("useOnlyCssZoom", this.useOnlyCssZoom, "set-css-zoom");
|
|
1366
|
+
}
|
|
1367
|
+
// Queue event configurations (non-auto-actions)
|
|
1368
|
+
if (this.onBeforePrint) {
|
|
1369
|
+
this.queueConfiguration("beforePrint", true, "enable-before-print");
|
|
1370
|
+
}
|
|
1371
|
+
if (this.onAfterPrint) {
|
|
1372
|
+
this.queueConfiguration("afterPrint", true, "enable-after-print");
|
|
1373
|
+
}
|
|
1374
|
+
if (this.onDocumentLoad) {
|
|
1375
|
+
this.queueConfiguration("pagesLoaded", true, "enable-pages-loaded");
|
|
1376
|
+
}
|
|
1377
|
+
if (this.onPageChange) {
|
|
1378
|
+
this.queueConfiguration("pageChange", true, "enable-page-change");
|
|
124
1379
|
}
|
|
1380
|
+
// Queue new high-value event configurations
|
|
1381
|
+
if (this.onDocumentError) {
|
|
1382
|
+
this.queueConfiguration("documentError", true, "enable-document-error");
|
|
1383
|
+
}
|
|
1384
|
+
if (this.onDocumentInit) {
|
|
1385
|
+
this.queueConfiguration("documentInit", true, "enable-document-init");
|
|
1386
|
+
}
|
|
1387
|
+
if (this.onPagesInit) {
|
|
1388
|
+
this.queueConfiguration("pagesInit", true, "enable-pages-init");
|
|
1389
|
+
}
|
|
1390
|
+
if (this.onPresentationModeChanged) {
|
|
1391
|
+
this.queueConfiguration("presentationModeChanged", true, "enable-presentation-mode-changed");
|
|
1392
|
+
}
|
|
1393
|
+
if (this.onOpenFile) {
|
|
1394
|
+
this.queueConfiguration("openFile", true, "enable-open-file");
|
|
1395
|
+
}
|
|
1396
|
+
if (this.onFind) {
|
|
1397
|
+
this.queueConfiguration("find", true, "enable-find");
|
|
1398
|
+
}
|
|
1399
|
+
if (this.onUpdateFindMatchesCount) {
|
|
1400
|
+
this.queueConfiguration("updateFindMatchesCount", true, "enable-update-find-matches-count");
|
|
1401
|
+
}
|
|
1402
|
+
if (this.onMetadataLoaded) {
|
|
1403
|
+
this.queueConfiguration("metadataLoaded", true, "enable-metadata-loaded");
|
|
1404
|
+
}
|
|
1405
|
+
if (this.onOutlineLoaded) {
|
|
1406
|
+
this.queueConfiguration("outlineLoaded", true, "enable-outline-loaded");
|
|
1407
|
+
}
|
|
1408
|
+
if (this.onPageRendered) {
|
|
1409
|
+
this.queueConfiguration("pageRendered", true, "enable-page-rendered");
|
|
1410
|
+
}
|
|
1411
|
+
// New high-value events
|
|
1412
|
+
if (this.onAnnotationLayerRendered) {
|
|
1413
|
+
this.queueConfiguration("annotationLayerRendered", true, "enable-annotation-layer-rendered");
|
|
1414
|
+
}
|
|
1415
|
+
if (this.onBookmarkClick) {
|
|
1416
|
+
this.queueConfiguration("bookmarkClick", true, "enable-bookmark-click");
|
|
1417
|
+
}
|
|
1418
|
+
if (this.onIdle) {
|
|
1419
|
+
this.queueConfiguration("idle", true, "enable-idle");
|
|
1420
|
+
}
|
|
1421
|
+
// Note: Auto-actions are now queued when the document loads, not during component initialization
|
|
1422
|
+
// This ensures they use the current property values at the time of document load
|
|
1423
|
+
}
|
|
1424
|
+
queueAutoActionsForDocumentLoad() {
|
|
1425
|
+
// Use universal dispatcher for auto-actions
|
|
1426
|
+
if (this.downloadOnLoad === true) {
|
|
1427
|
+
this.dispatchAction("trigger-download", true, "initial-load");
|
|
1428
|
+
}
|
|
1429
|
+
if (this.showLastPageOnLoad === true) {
|
|
1430
|
+
this.dispatchAction("go-to-last-page", true, "initial-load");
|
|
1431
|
+
}
|
|
1432
|
+
// Auto-print is handled in pagesLoadedHandler for timing reasons
|
|
1433
|
+
}
|
|
1434
|
+
queueConfiguration(propertyName, value, action) {
|
|
1435
|
+
// Use universal dispatcher for all configuration actions
|
|
1436
|
+
this.dispatchAction(action, value, "initial-load");
|
|
125
1437
|
}
|
|
126
1438
|
refresh() {
|
|
1439
|
+
// Needs to be invoked for external window or when needs to reload pdf
|
|
1440
|
+
// Clean up existing event listeners
|
|
1441
|
+
ComponentUtils.cleanupEventHandlers(this);
|
|
1442
|
+
// Clear the action queue to ensure clean state
|
|
1443
|
+
if (this.actionQueueManager) {
|
|
1444
|
+
this.actionQueueManager.clearQueues();
|
|
1445
|
+
}
|
|
1446
|
+
// Reset PostMessage readiness state
|
|
1447
|
+
this.isPostMessageReady = false;
|
|
1448
|
+
this.postMessageReadiness = 0;
|
|
1449
|
+
this.pendingInitialConfig = true;
|
|
1450
|
+
this.initialConfigQueued = false; // Reset initial config flag
|
|
1451
|
+
// Reload the PDF - this will trigger queueAllConfigurations() when PostMessage API is ready
|
|
127
1452
|
this.loadPdf();
|
|
128
1453
|
}
|
|
129
|
-
|
|
1454
|
+
// Public method for external control messages
|
|
1455
|
+
sendViewerControlMessage(action, payload) {
|
|
1456
|
+
return this.sendControlMessage(action, payload);
|
|
1457
|
+
}
|
|
1458
|
+
// #region Public Methods for On-Demand Actions
|
|
1459
|
+
triggerDownload() {
|
|
1460
|
+
// Use universal dispatcher for user interactions - now always returns Promise<ActionExecutionResult>
|
|
1461
|
+
return this.dispatchAction("trigger-download", true, "user-interaction");
|
|
1462
|
+
}
|
|
1463
|
+
triggerPrint() {
|
|
1464
|
+
// Use universal dispatcher for user interactions - now always returns Promise<ActionExecutionResult>
|
|
1465
|
+
return this.dispatchAction("trigger-print", true, "user-interaction");
|
|
1466
|
+
}
|
|
1467
|
+
setPage(page) {
|
|
1468
|
+
// Use universal dispatcher for user interactions - now always returns Promise<ActionExecutionResult>
|
|
1469
|
+
return this.dispatchAction("set-page", page, "user-interaction");
|
|
1470
|
+
}
|
|
1471
|
+
setZoom(zoom) {
|
|
1472
|
+
// Use universal dispatcher for user interactions - now always returns Promise<ActionExecutionResult>
|
|
1473
|
+
return this.dispatchAction("set-zoom", zoom, "user-interaction");
|
|
1474
|
+
}
|
|
1475
|
+
goToLastPage() {
|
|
1476
|
+
// Use universal dispatcher for user interactions - now always returns Promise<ActionExecutionResult>
|
|
1477
|
+
return this.dispatchAction("go-to-last-page", true, "user-interaction");
|
|
1478
|
+
}
|
|
1479
|
+
setCursor(cursor) {
|
|
1480
|
+
// Use universal dispatcher for user interactions
|
|
1481
|
+
return this.dispatchAction("set-cursor", cursor, "user-interaction");
|
|
1482
|
+
}
|
|
1483
|
+
setScroll(scroll) {
|
|
1484
|
+
// Use universal dispatcher for user interactions
|
|
1485
|
+
return this.dispatchAction("set-scroll", scroll, "user-interaction");
|
|
1486
|
+
}
|
|
1487
|
+
setSpread(spread) {
|
|
1488
|
+
// Use universal dispatcher for user interactions
|
|
1489
|
+
return this.dispatchAction("set-spread", spread, "user-interaction");
|
|
1490
|
+
}
|
|
1491
|
+
triggerRotation(direction) {
|
|
1492
|
+
// Use universal dispatcher for user interactions
|
|
1493
|
+
const action = direction === "cw" ? "trigger-rotate-cw" : "trigger-rotate-ccw";
|
|
1494
|
+
return this.dispatchAction(action, true, "user-interaction");
|
|
1495
|
+
}
|
|
1496
|
+
goToPage(page) {
|
|
1497
|
+
// Alias for setPage for backward compatibility
|
|
1498
|
+
return this.setPage(page);
|
|
1499
|
+
}
|
|
1500
|
+
// #endregion
|
|
1501
|
+
// Action queue management methods
|
|
1502
|
+
getActionStatus(actionId) {
|
|
1503
|
+
if (!this.actionQueueManager) {
|
|
1504
|
+
return "not-found";
|
|
1505
|
+
}
|
|
1506
|
+
return this.actionQueueManager.getActionStatus(actionId);
|
|
1507
|
+
}
|
|
1508
|
+
getQueueStatus() {
|
|
1509
|
+
if (!this.actionQueueManager) {
|
|
1510
|
+
return {
|
|
1511
|
+
queuedActions: 0,
|
|
1512
|
+
executedActions: 0,
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
return this.actionQueueManager.getQueueStatus();
|
|
1516
|
+
}
|
|
1517
|
+
clearActionQueue() {
|
|
1518
|
+
if (this.actionQueueManager) {
|
|
1519
|
+
this.actionQueueManager.clearQueues();
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
// #endregion
|
|
1523
|
+
// #region PDF Loading and URL Handling
|
|
130
1524
|
loadPdf() {
|
|
131
|
-
if (!this.
|
|
1525
|
+
if (!this.validatePdfSource())
|
|
132
1526
|
return;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
1527
|
+
this.setupExternalWindow();
|
|
1528
|
+
const fileUrl = this.createFileUrl();
|
|
1529
|
+
const viewerUrl = this.buildViewerUrl(fileUrl);
|
|
1530
|
+
this.navigateToViewer(viewerUrl);
|
|
1531
|
+
}
|
|
1532
|
+
validatePdfSource() {
|
|
1533
|
+
return !!this._src;
|
|
1534
|
+
}
|
|
1535
|
+
setupExternalWindow() {
|
|
1536
|
+
if (!this.externalWindow)
|
|
1537
|
+
return;
|
|
1538
|
+
if (typeof this.viewerTab === "undefined" || this.viewerTab.closed) {
|
|
1539
|
+
this.viewerTab = window.open("", this.target, this.externalWindowOptions || "");
|
|
140
1540
|
if (this.viewerTab == null) {
|
|
141
|
-
|
|
142
|
-
console.error("ng2-pdfjs-viewer: For 'externalWindow = true'. i.e opening in new tab to work, pop-ups should be enabled.");
|
|
1541
|
+
console.error("ng2-pdfjs-viewer: For 'externalWindow = true'. i.e opening in new tab to work, pop-ups should be enabled.");
|
|
143
1542
|
return;
|
|
144
1543
|
}
|
|
145
1544
|
if (this.showSpinner) {
|
|
146
|
-
this.
|
|
1545
|
+
this.renderLoadingSpinner();
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
renderLoadingSpinner() {
|
|
1550
|
+
this.viewerTab.document.write(`
|
|
147
1551
|
<style>
|
|
148
1552
|
.loader {
|
|
149
1553
|
position: fixed;
|
|
@@ -167,181 +1571,362 @@ class PdfJsViewerComponent {
|
|
|
167
1571
|
</style>
|
|
168
1572
|
<div class="loader"></div>
|
|
169
1573
|
`);
|
|
170
|
-
|
|
171
|
-
|
|
1574
|
+
}
|
|
1575
|
+
createFileUrl() {
|
|
172
1576
|
this.relaseUrl?.();
|
|
173
|
-
let fileUrl;
|
|
174
|
-
//if (typeof this.src === "string") {
|
|
175
|
-
// fileUrl = this.src;
|
|
176
|
-
//}
|
|
177
1577
|
if (this._src instanceof Blob) {
|
|
178
1578
|
const url = URL.createObjectURL(this._src);
|
|
179
|
-
fileUrl = encodeURIComponent(url);
|
|
180
1579
|
this.relaseUrl = () => URL.revokeObjectURL(url);
|
|
1580
|
+
return encodeURIComponent(url);
|
|
181
1581
|
}
|
|
182
1582
|
else if (this._src instanceof Uint8Array) {
|
|
183
1583
|
let blob = new Blob([this._src], { type: "application/pdf" });
|
|
184
1584
|
const url = URL.createObjectURL(blob);
|
|
185
1585
|
this.relaseUrl = () => URL.revokeObjectURL(url);
|
|
186
|
-
|
|
1586
|
+
return encodeURIComponent(url);
|
|
187
1587
|
}
|
|
188
1588
|
else {
|
|
189
|
-
|
|
1589
|
+
return this._src;
|
|
190
1590
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
1591
|
+
}
|
|
1592
|
+
buildViewerUrl(fileUrl) {
|
|
1593
|
+
let viewerUrl = this.getBaseViewerUrl();
|
|
1594
|
+
viewerUrl = this.addFileParameter(viewerUrl, fileUrl);
|
|
1595
|
+
viewerUrl = this.addViewerIdParameter(viewerUrl);
|
|
1596
|
+
viewerUrl = this.addCacheBustingIfNeeded(viewerUrl);
|
|
1597
|
+
return viewerUrl;
|
|
1598
|
+
}
|
|
1599
|
+
getBaseViewerUrl() {
|
|
1600
|
+
return this.viewerFolder
|
|
1601
|
+
? `${this.viewerFolder}/web/viewer.html`
|
|
1602
|
+
: `assets/pdfjs/web/viewer.html`;
|
|
1603
|
+
}
|
|
1604
|
+
addFileParameter(viewerUrl, fileUrl) {
|
|
1605
|
+
return `${viewerUrl}?file=${fileUrl}`;
|
|
1606
|
+
}
|
|
1607
|
+
addViewerIdParameter(viewerUrl) {
|
|
1608
|
+
return typeof this.viewerId !== "undefined"
|
|
1609
|
+
? `${viewerUrl}&viewerId=${this.viewerId}`
|
|
1610
|
+
: viewerUrl;
|
|
1611
|
+
}
|
|
1612
|
+
addCacheBustingIfNeeded(viewerUrl) {
|
|
1613
|
+
if (this.isDevelopmentMode()) {
|
|
1614
|
+
const cacheBuster = Date.now();
|
|
1615
|
+
return `${viewerUrl}&_t=${cacheBuster}`;
|
|
194
1616
|
}
|
|
195
1617
|
else {
|
|
196
|
-
viewerUrl
|
|
197
|
-
}
|
|
198
|
-
viewerUrl += `?file=${fileUrl}`;
|
|
199
|
-
if (typeof this.viewerId !== 'undefined') {
|
|
200
|
-
viewerUrl += `&viewerId=${this.viewerId}`;
|
|
1618
|
+
return viewerUrl;
|
|
201
1619
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
viewerUrl += `&pageChange=true`;
|
|
213
|
-
}
|
|
214
|
-
if (this.downloadFileName) {
|
|
215
|
-
if (!this.downloadFileName.endsWith(".pdf")) {
|
|
216
|
-
this.downloadFileName += ".pdf";
|
|
217
|
-
}
|
|
218
|
-
viewerUrl += `&fileName=${this.downloadFileName}`;
|
|
219
|
-
}
|
|
220
|
-
if (typeof this.openFile !== 'undefined') {
|
|
221
|
-
viewerUrl += `&openFile=${this.openFile}`;
|
|
222
|
-
}
|
|
223
|
-
if (typeof this.download !== 'undefined') {
|
|
224
|
-
viewerUrl += `&download=${this.download}`;
|
|
225
|
-
}
|
|
226
|
-
if (this.startDownload) {
|
|
227
|
-
viewerUrl += `&startDownload=${this.startDownload}`;
|
|
228
|
-
}
|
|
229
|
-
if (typeof this.viewBookmark !== 'undefined') {
|
|
230
|
-
viewerUrl += `&viewBookmark=${this.viewBookmark}`;
|
|
231
|
-
}
|
|
232
|
-
if (typeof this.print !== 'undefined') {
|
|
233
|
-
viewerUrl += `&print=${this.print}`;
|
|
234
|
-
}
|
|
235
|
-
if (this.startPrint) {
|
|
236
|
-
viewerUrl += `&startPrint=${this.startPrint}`;
|
|
237
|
-
}
|
|
238
|
-
if (typeof this.fullScreen !== 'undefined') {
|
|
239
|
-
viewerUrl += `&fullScreen=${this.fullScreen}`;
|
|
240
|
-
}
|
|
241
|
-
// if (this.showFullScreen) {
|
|
242
|
-
// viewerUrl += `&showFullScreen=${this.showFullScreen}`;
|
|
243
|
-
// }
|
|
244
|
-
if (typeof this.find !== 'undefined') {
|
|
245
|
-
viewerUrl += `&find=${this.find}`;
|
|
246
|
-
}
|
|
247
|
-
if (this.lastPage) {
|
|
248
|
-
viewerUrl += `&lastpage=${this.lastPage}`;
|
|
249
|
-
}
|
|
250
|
-
if (this.rotatecw) {
|
|
251
|
-
viewerUrl += `&rotatecw=${this.rotatecw}`;
|
|
252
|
-
}
|
|
253
|
-
if (this.rotateccw) {
|
|
254
|
-
viewerUrl += `&rotateccw=${this.rotateccw}`;
|
|
255
|
-
}
|
|
256
|
-
if (this.cursor) {
|
|
257
|
-
viewerUrl += `&cursor=${this.cursor}`;
|
|
258
|
-
}
|
|
259
|
-
if (this.scroll) {
|
|
260
|
-
viewerUrl += `&scroll=${this.scroll}`;
|
|
261
|
-
}
|
|
262
|
-
if (this.spread) {
|
|
263
|
-
viewerUrl += `&spread=${this.spread}`;
|
|
264
|
-
}
|
|
265
|
-
if (this.locale) {
|
|
266
|
-
viewerUrl += `&locale=${this.locale}`;
|
|
267
|
-
}
|
|
268
|
-
if (this.useOnlyCssZoom) {
|
|
269
|
-
viewerUrl += `&useOnlyCssZoom=${this.useOnlyCssZoom}`;
|
|
270
|
-
}
|
|
271
|
-
if (this._page || this.zoom || this.nameddest || this.pagemode)
|
|
272
|
-
viewerUrl += "#";
|
|
273
|
-
if (this._page) {
|
|
274
|
-
viewerUrl += `&page=${this._page}`;
|
|
275
|
-
}
|
|
276
|
-
if (this.zoom) {
|
|
277
|
-
viewerUrl += `&zoom=${this.zoom}`;
|
|
278
|
-
}
|
|
279
|
-
if (this.nameddest) {
|
|
280
|
-
viewerUrl += `&nameddest=${this.nameddest}`;
|
|
1620
|
+
}
|
|
1621
|
+
isDevelopmentMode() {
|
|
1622
|
+
return (window.location.hostname === "localhost" ||
|
|
1623
|
+
window.location.hostname === "127.0.0.1" ||
|
|
1624
|
+
window.location.port === "4200" ||
|
|
1625
|
+
window.location.href.includes("localhost:4200"));
|
|
1626
|
+
}
|
|
1627
|
+
navigateToViewer(viewerUrl) {
|
|
1628
|
+
if (this.externalWindow) {
|
|
1629
|
+
this.viewerTab.location.href = viewerUrl;
|
|
281
1630
|
}
|
|
282
|
-
|
|
283
|
-
|
|
1631
|
+
else {
|
|
1632
|
+
this.iframe.nativeElement.contentWindow.location.replace(viewerUrl);
|
|
284
1633
|
}
|
|
285
|
-
if (this.
|
|
286
|
-
|
|
287
|
-
if (this.errorOverride) {
|
|
288
|
-
viewerUrl += `&errorOverride=${this.errorOverride}`;
|
|
289
|
-
}
|
|
290
|
-
if (this.errorAppend) {
|
|
291
|
-
viewerUrl += `&errorAppend=${this.errorAppend}`;
|
|
292
|
-
}
|
|
1634
|
+
if (this.diagnosticLogs) {
|
|
1635
|
+
this.logViewerConfiguration(viewerUrl);
|
|
293
1636
|
}
|
|
294
|
-
|
|
295
|
-
|
|
1637
|
+
}
|
|
1638
|
+
logViewerConfiguration(viewerUrl) {
|
|
1639
|
+
console.debug(`PdfJsViewer: Minimal URL configuration:
|
|
1640
|
+
pdfSrc = ${this.pdfSrc}
|
|
1641
|
+
externalWindow = ${this.externalWindow}
|
|
1642
|
+
viewerFolder = ${this.viewerFolder}
|
|
1643
|
+
viewerId = ${this.viewerId}
|
|
1644
|
+
finalUrl = ${viewerUrl}
|
|
1645
|
+
|
|
1646
|
+
All other configurations handled via PostMessage system:
|
|
1647
|
+
showOpenFile = ${this.showOpenFile}
|
|
1648
|
+
showDownload = ${this.showDownload}
|
|
1649
|
+
showViewBookmark = ${this.showViewBookmark}
|
|
1650
|
+
showPrint = ${this.showPrint}
|
|
1651
|
+
showFullScreen = ${this.showFullScreen}
|
|
1652
|
+
showFind = ${this.showFind}
|
|
1653
|
+
cursor = ${this.cursor}
|
|
1654
|
+
scroll = ${this.scroll}
|
|
1655
|
+
spread = ${this.spread}
|
|
1656
|
+
page = ${this.page}
|
|
1657
|
+
zoom = ${this.zoom}
|
|
1658
|
+
namedDest = ${this.namedDest}
|
|
1659
|
+
pageMode = ${this.pageMode}
|
|
1660
|
+
errorOverride = ${this.errorOverride}
|
|
1661
|
+
errorAppend = ${this.errorAppend}
|
|
1662
|
+
errorMessage = ${this.errorMessage}
|
|
1663
|
+
locale = ${this.locale}
|
|
1664
|
+
useOnlyCssZoom = ${this.useOnlyCssZoom}
|
|
1665
|
+
|
|
1666
|
+
Auto-actions (handled by action queue):
|
|
1667
|
+
downloadOnLoad = ${this.downloadOnLoad}
|
|
1668
|
+
printOnLoad = ${this.printOnLoad}
|
|
1669
|
+
showLastPageOnLoad = ${this.showLastPageOnLoad}
|
|
1670
|
+
`);
|
|
1671
|
+
}
|
|
1672
|
+
// #endregion
|
|
1673
|
+
// #region Two-Way Binding Helper Methods
|
|
1674
|
+
applyZoomToViewer(zoom) {
|
|
1675
|
+
// Use universal dispatcher - it will handle readiness checking and queuing
|
|
1676
|
+
this.dispatchAction("set-zoom", zoom, "property-change");
|
|
1677
|
+
}
|
|
1678
|
+
applyRotationToViewer(rotation) {
|
|
1679
|
+
// Use universal dispatcher - it will handle readiness checking and queuing
|
|
1680
|
+
this.dispatchAction("set-rotation", rotation, "property-change");
|
|
1681
|
+
}
|
|
1682
|
+
applyCursorToViewer(cursor) {
|
|
1683
|
+
// Use universal dispatcher - it will handle readiness checking and queuing
|
|
1684
|
+
this.dispatchAction("set-cursor", cursor, "property-change");
|
|
1685
|
+
}
|
|
1686
|
+
applyScrollToViewer(scroll) {
|
|
1687
|
+
// Use universal dispatcher - it will handle readiness checking and queuing
|
|
1688
|
+
this.dispatchAction("set-scroll", scroll, "property-change");
|
|
1689
|
+
}
|
|
1690
|
+
applySpreadToViewer(spread) {
|
|
1691
|
+
// Use universal dispatcher - it will handle readiness checking and queuing
|
|
1692
|
+
this.dispatchAction("set-spread", spread, "property-change");
|
|
1693
|
+
}
|
|
1694
|
+
applyPageModeToViewer(pageMode) {
|
|
1695
|
+
// Use universal dispatcher - it will handle readiness checking and queuing
|
|
1696
|
+
this.dispatchAction("update-page-mode", pageMode, "property-change");
|
|
1697
|
+
}
|
|
1698
|
+
// #endregion
|
|
1699
|
+
// Universal Action Dispatcher - ALL actions go through readiness-based queuing
|
|
1700
|
+
dispatchAction(action, payload, source = "property-change") {
|
|
1701
|
+
const requiredReadiness = this.getRequiredReadinessLevel(action);
|
|
1702
|
+
const actionObj = {
|
|
1703
|
+
id: `${source}-${action}-${Date.now()}`,
|
|
1704
|
+
action: action,
|
|
1705
|
+
payload: payload,
|
|
1706
|
+
};
|
|
1707
|
+
// Check if we have sufficient readiness to execute immediately
|
|
1708
|
+
if (this.hasRequiredReadiness(requiredReadiness)) {
|
|
1709
|
+
return this.actionQueueManager.executeAction(actionObj);
|
|
296
1710
|
}
|
|
297
1711
|
else {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
// download = ${this.download}
|
|
308
|
-
// startDownload = ${this.startDownload}
|
|
309
|
-
// viewBookmark = ${this.viewBookmark}
|
|
310
|
-
// print = ${this.print}
|
|
311
|
-
// startPrint = ${this.startPrint}
|
|
312
|
-
// fullScreen = ${this.fullScreen}
|
|
313
|
-
// find = ${this.find}
|
|
314
|
-
// lastPage = ${this.lastPage}
|
|
315
|
-
// rotatecw = ${this.rotatecw}
|
|
316
|
-
// rotateccw = ${this.rotateccw}
|
|
317
|
-
// cursor = ${this.cursor}
|
|
318
|
-
// scrollMode = ${this.scroll}
|
|
319
|
-
// spread = ${this.spread}
|
|
320
|
-
// page = ${this.page}
|
|
321
|
-
// zoom = ${this.zoom}
|
|
322
|
-
// nameddest = ${this.nameddest}
|
|
323
|
-
// pagemode = ${this.pagemode}
|
|
324
|
-
// pagemode = ${this.errorOverride}
|
|
325
|
-
// pagemode = ${this.errorAppend}
|
|
326
|
-
// pagemode = ${this.errorMessage}
|
|
327
|
-
// `);
|
|
1712
|
+
// Queue action to execute when readiness is achieved
|
|
1713
|
+
this.actionQueueManager.queueAction(actionObj, requiredReadiness);
|
|
1714
|
+
// Return a promise that resolves when the action eventually executes
|
|
1715
|
+
return Promise.resolve({
|
|
1716
|
+
actionId: actionObj.id,
|
|
1717
|
+
success: true,
|
|
1718
|
+
timestamp: Date.now(),
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
328
1721
|
}
|
|
329
|
-
|
|
330
|
-
|
|
1722
|
+
getRequiredReadinessLevel(action) {
|
|
1723
|
+
// Define readiness requirements for all actions
|
|
1724
|
+
const level1Actions = [
|
|
1725
|
+
"set-theme",
|
|
1726
|
+
"set-primary-color",
|
|
1727
|
+
"set-background-color",
|
|
1728
|
+
"set-page-border-color",
|
|
1729
|
+
"set-toolbar-color",
|
|
1730
|
+
"set-text-color",
|
|
1731
|
+
"set-border-radius",
|
|
1732
|
+
"set-custom-css",
|
|
1733
|
+
];
|
|
1734
|
+
const level3Actions = [
|
|
1735
|
+
"show-download",
|
|
1736
|
+
"show-print",
|
|
1737
|
+
"show-fullscreen",
|
|
1738
|
+
"show-find",
|
|
1739
|
+
"show-bookmark",
|
|
1740
|
+
"show-openfile",
|
|
1741
|
+
"show-annotations",
|
|
1742
|
+
"set-error-message",
|
|
1743
|
+
"set-error-override",
|
|
1744
|
+
"set-error-append",
|
|
1745
|
+
"set-css-zoom",
|
|
1746
|
+
// DOM visibility toggles
|
|
1747
|
+
"show-toolbar-left",
|
|
1748
|
+
"show-toolbar-middle",
|
|
1749
|
+
"show-toolbar-right",
|
|
1750
|
+
"show-secondary-toolbar-toggle",
|
|
1751
|
+
"show-sidebar",
|
|
1752
|
+
"show-sidebar-left",
|
|
1753
|
+
"show-sidebar-right",
|
|
1754
|
+
];
|
|
1755
|
+
const level4Actions = [
|
|
1756
|
+
"set-cursor",
|
|
1757
|
+
"set-scroll",
|
|
1758
|
+
"set-spread",
|
|
1759
|
+
"set-zoom",
|
|
1760
|
+
"update-page-mode",
|
|
1761
|
+
// Layout actions require components ready to measure
|
|
1762
|
+
"set-toolbar-density",
|
|
1763
|
+
"set-sidebar-width",
|
|
1764
|
+
"set-toolbar-position",
|
|
1765
|
+
"set-sidebar-position",
|
|
1766
|
+
"set-responsive-breakpoint",
|
|
1767
|
+
];
|
|
1768
|
+
const level5Actions = [
|
|
1769
|
+
"set-page",
|
|
1770
|
+
"set-rotation",
|
|
1771
|
+
"go-to-last-page",
|
|
1772
|
+
"go-to-named-dest",
|
|
1773
|
+
"trigger-download",
|
|
1774
|
+
"trigger-print",
|
|
1775
|
+
"trigger-rotate-cw",
|
|
1776
|
+
"trigger-rotate-ccw",
|
|
1777
|
+
];
|
|
1778
|
+
if (level1Actions.includes(action))
|
|
1779
|
+
return 1; // VIEWER_LOADED - DOM access only
|
|
1780
|
+
if (level3Actions.includes(action))
|
|
1781
|
+
return 3; // EVENTBUS_READY
|
|
1782
|
+
if (level4Actions.includes(action))
|
|
1783
|
+
return 4; // COMPONENTS_READY
|
|
1784
|
+
if (level5Actions.includes(action))
|
|
1785
|
+
return 5; // DOCUMENT_LOADED
|
|
1786
|
+
return 3; // Default to EVENTBUS_READY
|
|
1787
|
+
}
|
|
1788
|
+
hasRequiredReadiness(requiredLevel) {
|
|
1789
|
+
if (!this.isPostMessageReady)
|
|
1790
|
+
return false;
|
|
1791
|
+
if (requiredLevel === 5 && !this.actionQueueManager?.isDocumentLoaded)
|
|
1792
|
+
return false;
|
|
1793
|
+
return this.postMessageReadiness >= requiredLevel;
|
|
331
1794
|
}
|
|
332
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.
|
|
333
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.
|
|
1795
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: PdfJsViewerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1796
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.6", type: PdfJsViewerComponent, isStandalone: false, selector: "ng2-pdfjs-viewer", inputs: { viewerId: "viewerId", viewerFolder: "viewerFolder", externalWindow: "externalWindow", target: "target", showSpinner: "showSpinner", downloadFileName: "downloadFileName", locale: "locale", useOnlyCssZoom: "useOnlyCssZoom", diagnosticLogs: "diagnosticLogs", showOpenFile: "showOpenFile", showAnnotations: "showAnnotations", showDownload: "showDownload", showViewBookmark: "showViewBookmark", showPrint: "showPrint", showFullScreen: "showFullScreen", showFind: "showFind", downloadOnLoad: "downloadOnLoad", printOnLoad: "printOnLoad", rotateCW: "rotateCW", rotateCCW: "rotateCCW", showLastPageOnLoad: "showLastPageOnLoad", namedDest: "namedDest", errorOverride: "errorOverride", errorAppend: "errorAppend", errorMessage: "errorMessage", theme: "theme", primaryColor: "primaryColor", backgroundColor: "backgroundColor", pageBorderColor: "pageBorderColor", toolbarColor: "toolbarColor", textColor: "textColor", borderRadius: "borderRadius", customCSS: "customCSS", customSpinnerTpl: "customSpinnerTpl", spinnerClass: "spinnerClass", customErrorTpl: "customErrorTpl", errorClass: "errorClass", showToolbarLeft: "showToolbarLeft", showToolbarMiddle: "showToolbarMiddle", showToolbarRight: "showToolbarRight", showSecondaryToolbarToggle: "showSecondaryToolbarToggle", showSidebar: "showSidebar", showSidebarLeft: "showSidebarLeft", showSidebarRight: "showSidebarRight", toolbarDensity: "toolbarDensity", sidebarWidth: "sidebarWidth", toolbarPosition: "toolbarPosition", sidebarPosition: "sidebarPosition", responsiveBreakpoint: "responsiveBreakpoint", controlVisibility: "controlVisibility", autoActions: "autoActions", errorHandling: "errorHandling", viewerConfig: "viewerConfig", themeConfig: "themeConfig", groupVisibility: "groupVisibility", layoutConfig: "layoutConfig", startDownload: "startDownload", startPrint: "startPrint", openFile: "openFile", download: "download", print: "print", fullScreen: "fullScreen", find: "find", viewBookmark: "viewBookmark", lastPage: "lastPage", externalWindowOptions: "externalWindowOptions", zoom: "zoom", rotation: "rotation", cursor: "cursor", scroll: "scroll", spread: "spread", pageMode: "pageMode", page: "page", pdfSrc: "pdfSrc" }, outputs: { onBeforePrint: "onBeforePrint", onAfterPrint: "onAfterPrint", onDocumentLoad: "onDocumentLoad", onPageChange: "onPageChange", onScaleChange: "onScaleChange", onRotationChange: "onRotationChange", onDocumentError: "onDocumentError", onDocumentInit: "onDocumentInit", onPagesInit: "onPagesInit", onPresentationModeChanged: "onPresentationModeChanged", onOpenFile: "onOpenFile", onFind: "onFind", onUpdateFindMatchesCount: "onUpdateFindMatchesCount", onMetadataLoaded: "onMetadataLoaded", onOutlineLoaded: "onOutlineLoaded", onPageRendered: "onPageRendered", onAnnotationLayerRendered: "onAnnotationLayerRendered", onBookmarkClick: "onBookmarkClick", onIdle: "onIdle", zoomChange: "zoomChange", cursorChange: "cursorChange", scrollChange: "scrollChange", spreadChange: "spreadChange", pageModeChange: "pageModeChange" }, viewQueries: [{ propertyName: "iframe", first: true, predicate: ["iframe"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
1797
|
+
<div
|
|
1798
|
+
class="ng2-pdfjs-viewer-container"
|
|
1799
|
+
style="position:relative;width:100%;height:100%;"
|
|
1800
|
+
>
|
|
1801
|
+
<iframe
|
|
1802
|
+
title="ng2-pdfjs-viewer"
|
|
1803
|
+
[hidden]="externalWindow || (!externalWindow && !pdfSrc)"
|
|
1804
|
+
#iframe
|
|
1805
|
+
width="100%"
|
|
1806
|
+
height="100%"
|
|
1807
|
+
></iframe>
|
|
1808
|
+
|
|
1809
|
+
<div
|
|
1810
|
+
class="ng2-pdfjs-loading-overlay"
|
|
1811
|
+
*ngIf="showSpinner && isLoading && !externalWindow"
|
|
1812
|
+
[ngClass]="spinnerClass"
|
|
1813
|
+
style="position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.6);backdrop-filter:saturate(120%) blur(1px);"
|
|
1814
|
+
>
|
|
1815
|
+
<ng-container
|
|
1816
|
+
*ngIf="customSpinnerTpl; else defaultSpinner"
|
|
1817
|
+
[ngTemplateOutlet]="customSpinnerTpl"
|
|
1818
|
+
></ng-container>
|
|
1819
|
+
<ng-template #defaultSpinner>
|
|
1820
|
+
<div style="text-align:center;">
|
|
1821
|
+
<div
|
|
1822
|
+
style="display:inline-block;width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #2196F3;border-radius:50%;animation:spin 1s linear infinite;"
|
|
1823
|
+
></div>
|
|
1824
|
+
<div style="margin-top:16px;color:#666;font-size:16px;">
|
|
1825
|
+
Loading PDF...
|
|
1826
|
+
</div>
|
|
1827
|
+
</div>
|
|
1828
|
+
</ng-template>
|
|
1829
|
+
</div>
|
|
1830
|
+
|
|
1831
|
+
<div
|
|
1832
|
+
class="ng2-pdfjs-error-overlay"
|
|
1833
|
+
*ngIf="errorOverride && hasError && !externalWindow"
|
|
1834
|
+
[ngClass]="errorClass"
|
|
1835
|
+
style="position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.9);backdrop-filter:saturate(120%) blur(1px);"
|
|
1836
|
+
>
|
|
1837
|
+
<ng-container
|
|
1838
|
+
*ngIf="customErrorTpl; else defaultError"
|
|
1839
|
+
[ngTemplateOutlet]="customErrorTpl"
|
|
1840
|
+
[ngTemplateOutletContext]="getErrorTemplateData()"
|
|
1841
|
+
></ng-container>
|
|
1842
|
+
<ng-template #defaultError>
|
|
1843
|
+
<div style="text-align:center;max-width:400px;padding:20px;">
|
|
1844
|
+
<div style="font-size:48px;color:#f44336;margin-bottom:16px;">
|
|
1845
|
+
⚠️
|
|
1846
|
+
</div>
|
|
1847
|
+
<div
|
|
1848
|
+
style="color:#333;font-size:18px;font-weight:500;margin-bottom:8px;"
|
|
1849
|
+
>
|
|
1850
|
+
Error Loading PDF
|
|
1851
|
+
</div>
|
|
1852
|
+
<div style="color:#666;font-size:14px;line-height:1.4;">
|
|
1853
|
+
{{ currentErrorMessage }}
|
|
1854
|
+
</div>
|
|
1855
|
+
</div>
|
|
1856
|
+
</ng-template>
|
|
1857
|
+
</div>
|
|
1858
|
+
</div>
|
|
1859
|
+
`, isInline: true, styles: [".ng2-pdfjs-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#fff9;-webkit-backdrop-filter:saturate(120%) blur(1px);backdrop-filter:saturate(120%) blur(1px)}.ng2-pdfjs-error-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#ffffffe6;-webkit-backdrop-filter:saturate(120%) blur(1px);backdrop-filter:saturate(120%) blur(1px)}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
334
1860
|
}
|
|
335
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.
|
|
1861
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: PdfJsViewerComponent, decorators: [{
|
|
336
1862
|
type: Component,
|
|
337
|
-
args: [{
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
1863
|
+
args: [{ selector: "ng2-pdfjs-viewer", standalone: false, template: `
|
|
1864
|
+
<div
|
|
1865
|
+
class="ng2-pdfjs-viewer-container"
|
|
1866
|
+
style="position:relative;width:100%;height:100%;"
|
|
1867
|
+
>
|
|
1868
|
+
<iframe
|
|
1869
|
+
title="ng2-pdfjs-viewer"
|
|
1870
|
+
[hidden]="externalWindow || (!externalWindow && !pdfSrc)"
|
|
1871
|
+
#iframe
|
|
1872
|
+
width="100%"
|
|
1873
|
+
height="100%"
|
|
1874
|
+
></iframe>
|
|
1875
|
+
|
|
1876
|
+
<div
|
|
1877
|
+
class="ng2-pdfjs-loading-overlay"
|
|
1878
|
+
*ngIf="showSpinner && isLoading && !externalWindow"
|
|
1879
|
+
[ngClass]="spinnerClass"
|
|
1880
|
+
style="position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.6);backdrop-filter:saturate(120%) blur(1px);"
|
|
1881
|
+
>
|
|
1882
|
+
<ng-container
|
|
1883
|
+
*ngIf="customSpinnerTpl; else defaultSpinner"
|
|
1884
|
+
[ngTemplateOutlet]="customSpinnerTpl"
|
|
1885
|
+
></ng-container>
|
|
1886
|
+
<ng-template #defaultSpinner>
|
|
1887
|
+
<div style="text-align:center;">
|
|
1888
|
+
<div
|
|
1889
|
+
style="display:inline-block;width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #2196F3;border-radius:50%;animation:spin 1s linear infinite;"
|
|
1890
|
+
></div>
|
|
1891
|
+
<div style="margin-top:16px;color:#666;font-size:16px;">
|
|
1892
|
+
Loading PDF...
|
|
1893
|
+
</div>
|
|
1894
|
+
</div>
|
|
1895
|
+
</ng-template>
|
|
1896
|
+
</div>
|
|
1897
|
+
|
|
1898
|
+
<div
|
|
1899
|
+
class="ng2-pdfjs-error-overlay"
|
|
1900
|
+
*ngIf="errorOverride && hasError && !externalWindow"
|
|
1901
|
+
[ngClass]="errorClass"
|
|
1902
|
+
style="position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.9);backdrop-filter:saturate(120%) blur(1px);"
|
|
1903
|
+
>
|
|
1904
|
+
<ng-container
|
|
1905
|
+
*ngIf="customErrorTpl; else defaultError"
|
|
1906
|
+
[ngTemplateOutlet]="customErrorTpl"
|
|
1907
|
+
[ngTemplateOutletContext]="getErrorTemplateData()"
|
|
1908
|
+
></ng-container>
|
|
1909
|
+
<ng-template #defaultError>
|
|
1910
|
+
<div style="text-align:center;max-width:400px;padding:20px;">
|
|
1911
|
+
<div style="font-size:48px;color:#f44336;margin-bottom:16px;">
|
|
1912
|
+
⚠️
|
|
1913
|
+
</div>
|
|
1914
|
+
<div
|
|
1915
|
+
style="color:#333;font-size:18px;font-weight:500;margin-bottom:8px;"
|
|
1916
|
+
>
|
|
1917
|
+
Error Loading PDF
|
|
1918
|
+
</div>
|
|
1919
|
+
<div style="color:#666;font-size:14px;line-height:1.4;">
|
|
1920
|
+
{{ currentErrorMessage }}
|
|
1921
|
+
</div>
|
|
1922
|
+
</div>
|
|
1923
|
+
</ng-template>
|
|
1924
|
+
</div>
|
|
1925
|
+
</div>
|
|
1926
|
+
`, styles: [".ng2-pdfjs-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#fff9;-webkit-backdrop-filter:saturate(120%) blur(1px);backdrop-filter:saturate(120%) blur(1px)}.ng2-pdfjs-error-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#ffffffe6;-webkit-backdrop-filter:saturate(120%) blur(1px);backdrop-filter:saturate(120%) blur(1px)}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}\n"] }]
|
|
342
1927
|
}], propDecorators: { iframe: [{
|
|
343
1928
|
type: ViewChild,
|
|
344
|
-
args: [
|
|
1929
|
+
args: ["iframe", { static: true }]
|
|
345
1930
|
}], viewerId: [{
|
|
346
1931
|
type: Input
|
|
347
1932
|
}], onBeforePrint: [{
|
|
@@ -352,6 +1937,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
|
|
|
352
1937
|
type: Output
|
|
353
1938
|
}], onPageChange: [{
|
|
354
1939
|
type: Output
|
|
1940
|
+
}], onScaleChange: [{
|
|
1941
|
+
type: Output
|
|
1942
|
+
}], onRotationChange: [{
|
|
1943
|
+
type: Output
|
|
1944
|
+
}], onDocumentError: [{
|
|
1945
|
+
type: Output
|
|
1946
|
+
}], onDocumentInit: [{
|
|
1947
|
+
type: Output
|
|
1948
|
+
}], onPagesInit: [{
|
|
1949
|
+
type: Output
|
|
1950
|
+
}], onPresentationModeChanged: [{
|
|
1951
|
+
type: Output
|
|
1952
|
+
}], onOpenFile: [{
|
|
1953
|
+
type: Output
|
|
1954
|
+
}], onFind: [{
|
|
1955
|
+
type: Output
|
|
1956
|
+
}], onUpdateFindMatchesCount: [{
|
|
1957
|
+
type: Output
|
|
1958
|
+
}], onMetadataLoaded: [{
|
|
1959
|
+
type: Output
|
|
1960
|
+
}], onOutlineLoaded: [{
|
|
1961
|
+
type: Output
|
|
1962
|
+
}], onPageRendered: [{
|
|
1963
|
+
type: Output
|
|
1964
|
+
}], onAnnotationLayerRendered: [{
|
|
1965
|
+
type: Output
|
|
1966
|
+
}], onBookmarkClick: [{
|
|
1967
|
+
type: Output
|
|
1968
|
+
}], onIdle: [{
|
|
1969
|
+
type: Output
|
|
355
1970
|
}], viewerFolder: [{
|
|
356
1971
|
type: Input
|
|
357
1972
|
}], externalWindow: [{
|
|
@@ -362,43 +1977,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
|
|
|
362
1977
|
type: Input
|
|
363
1978
|
}], downloadFileName: [{
|
|
364
1979
|
type: Input
|
|
365
|
-
}],
|
|
366
|
-
type: Input
|
|
367
|
-
}], download: [{
|
|
368
|
-
type: Input
|
|
369
|
-
}], startDownload: [{
|
|
370
|
-
type: Input
|
|
371
|
-
}], viewBookmark: [{
|
|
1980
|
+
}], locale: [{
|
|
372
1981
|
type: Input
|
|
373
|
-
}],
|
|
1982
|
+
}], useOnlyCssZoom: [{
|
|
374
1983
|
type: Input
|
|
375
|
-
}],
|
|
1984
|
+
}], diagnosticLogs: [{
|
|
376
1985
|
type: Input
|
|
377
|
-
}],
|
|
1986
|
+
}], showOpenFile: [{
|
|
378
1987
|
type: Input
|
|
379
|
-
}],
|
|
1988
|
+
}], showAnnotations: [{
|
|
380
1989
|
type: Input
|
|
381
|
-
}],
|
|
1990
|
+
}], showDownload: [{
|
|
382
1991
|
type: Input
|
|
383
|
-
}],
|
|
1992
|
+
}], showViewBookmark: [{
|
|
384
1993
|
type: Input
|
|
385
|
-
}],
|
|
1994
|
+
}], showPrint: [{
|
|
386
1995
|
type: Input
|
|
387
|
-
}],
|
|
1996
|
+
}], showFullScreen: [{
|
|
388
1997
|
type: Input
|
|
389
|
-
}],
|
|
1998
|
+
}], showFind: [{
|
|
390
1999
|
type: Input
|
|
391
|
-
}],
|
|
2000
|
+
}], downloadOnLoad: [{
|
|
392
2001
|
type: Input
|
|
393
|
-
}],
|
|
2002
|
+
}], printOnLoad: [{
|
|
394
2003
|
type: Input
|
|
395
|
-
}],
|
|
2004
|
+
}], rotateCW: [{
|
|
396
2005
|
type: Input
|
|
397
|
-
}],
|
|
2006
|
+
}], rotateCCW: [{
|
|
398
2007
|
type: Input
|
|
399
|
-
}],
|
|
2008
|
+
}], showLastPageOnLoad: [{
|
|
400
2009
|
type: Input
|
|
401
|
-
}],
|
|
2010
|
+
}], namedDest: [{
|
|
402
2011
|
type: Input
|
|
403
2012
|
}], errorOverride: [{
|
|
404
2013
|
type: Input
|
|
@@ -406,10 +2015,110 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
|
|
|
406
2015
|
type: Input
|
|
407
2016
|
}], errorMessage: [{
|
|
408
2017
|
type: Input
|
|
409
|
-
}],
|
|
2018
|
+
}], theme: [{
|
|
2019
|
+
type: Input
|
|
2020
|
+
}], primaryColor: [{
|
|
2021
|
+
type: Input
|
|
2022
|
+
}], backgroundColor: [{
|
|
2023
|
+
type: Input
|
|
2024
|
+
}], pageBorderColor: [{
|
|
2025
|
+
type: Input
|
|
2026
|
+
}], toolbarColor: [{
|
|
2027
|
+
type: Input
|
|
2028
|
+
}], textColor: [{
|
|
2029
|
+
type: Input
|
|
2030
|
+
}], borderRadius: [{
|
|
2031
|
+
type: Input
|
|
2032
|
+
}], customCSS: [{
|
|
2033
|
+
type: Input
|
|
2034
|
+
}], customSpinnerTpl: [{
|
|
2035
|
+
type: Input
|
|
2036
|
+
}], spinnerClass: [{
|
|
2037
|
+
type: Input
|
|
2038
|
+
}], customErrorTpl: [{
|
|
2039
|
+
type: Input
|
|
2040
|
+
}], errorClass: [{
|
|
2041
|
+
type: Input
|
|
2042
|
+
}], showToolbarLeft: [{
|
|
2043
|
+
type: Input
|
|
2044
|
+
}], showToolbarMiddle: [{
|
|
2045
|
+
type: Input
|
|
2046
|
+
}], showToolbarRight: [{
|
|
2047
|
+
type: Input
|
|
2048
|
+
}], showSecondaryToolbarToggle: [{
|
|
2049
|
+
type: Input
|
|
2050
|
+
}], showSidebar: [{
|
|
2051
|
+
type: Input
|
|
2052
|
+
}], showSidebarLeft: [{
|
|
2053
|
+
type: Input
|
|
2054
|
+
}], showSidebarRight: [{
|
|
2055
|
+
type: Input
|
|
2056
|
+
}], toolbarDensity: [{
|
|
2057
|
+
type: Input
|
|
2058
|
+
}], sidebarWidth: [{
|
|
2059
|
+
type: Input
|
|
2060
|
+
}], toolbarPosition: [{
|
|
2061
|
+
type: Input
|
|
2062
|
+
}], sidebarPosition: [{
|
|
2063
|
+
type: Input
|
|
2064
|
+
}], responsiveBreakpoint: [{
|
|
2065
|
+
type: Input
|
|
2066
|
+
}], controlVisibility: [{
|
|
2067
|
+
type: Input
|
|
2068
|
+
}], autoActions: [{
|
|
2069
|
+
type: Input
|
|
2070
|
+
}], errorHandling: [{
|
|
2071
|
+
type: Input
|
|
2072
|
+
}], viewerConfig: [{
|
|
2073
|
+
type: Input
|
|
2074
|
+
}], themeConfig: [{
|
|
2075
|
+
type: Input
|
|
2076
|
+
}], groupVisibility: [{
|
|
2077
|
+
type: Input
|
|
2078
|
+
}], layoutConfig: [{
|
|
2079
|
+
type: Input
|
|
2080
|
+
}], startDownload: [{
|
|
2081
|
+
type: Input
|
|
2082
|
+
}], startPrint: [{
|
|
2083
|
+
type: Input
|
|
2084
|
+
}], openFile: [{
|
|
2085
|
+
type: Input
|
|
2086
|
+
}], download: [{
|
|
2087
|
+
type: Input
|
|
2088
|
+
}], print: [{
|
|
2089
|
+
type: Input
|
|
2090
|
+
}], fullScreen: [{
|
|
2091
|
+
type: Input
|
|
2092
|
+
}], find: [{
|
|
2093
|
+
type: Input
|
|
2094
|
+
}], viewBookmark: [{
|
|
2095
|
+
type: Input
|
|
2096
|
+
}], lastPage: [{
|
|
410
2097
|
type: Input
|
|
411
2098
|
}], externalWindowOptions: [{
|
|
412
2099
|
type: Input
|
|
2100
|
+
}], zoomChange: [{
|
|
2101
|
+
type: Output
|
|
2102
|
+
}], cursorChange: [{
|
|
2103
|
+
type: Output
|
|
2104
|
+
}], scrollChange: [{
|
|
2105
|
+
type: Output
|
|
2106
|
+
}], spreadChange: [{
|
|
2107
|
+
type: Output
|
|
2108
|
+
}], pageModeChange: [{
|
|
2109
|
+
type: Output
|
|
2110
|
+
}], zoom: [{
|
|
2111
|
+
type: Input
|
|
2112
|
+
}], rotation: [{
|
|
2113
|
+
type: Input
|
|
2114
|
+
}], cursor: [{
|
|
2115
|
+
type: Input
|
|
2116
|
+
}], scroll: [{
|
|
2117
|
+
type: Input
|
|
2118
|
+
}], spread: [{
|
|
2119
|
+
type: Input
|
|
2120
|
+
}], pageMode: [{
|
|
2121
|
+
type: Input
|
|
413
2122
|
}], page: [{
|
|
414
2123
|
type: Input
|
|
415
2124
|
}], pdfSrc: [{
|
|
@@ -422,11 +2131,11 @@ class PdfJsViewerModule {
|
|
|
422
2131
|
ngModule: PdfJsViewerModule,
|
|
423
2132
|
};
|
|
424
2133
|
}
|
|
425
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.
|
|
426
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.
|
|
427
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.
|
|
2134
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: PdfJsViewerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2135
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.6", ngImport: i0, type: PdfJsViewerModule, declarations: [PdfJsViewerComponent], imports: [CommonModule], exports: [PdfJsViewerComponent] });
|
|
2136
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: PdfJsViewerModule, imports: [CommonModule] });
|
|
428
2137
|
}
|
|
429
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.
|
|
2138
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: PdfJsViewerModule, decorators: [{
|
|
430
2139
|
type: NgModule,
|
|
431
2140
|
args: [{
|
|
432
2141
|
imports: [CommonModule],
|