ng2-pdfjs-viewer 25.0.11 → 25.0.12
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/README.md +18 -2
- package/fesm2022/ng2-pdfjs-viewer.mjs +18 -36
- package/fesm2022/ng2-pdfjs-viewer.mjs.map +1 -1
- package/package.json +1 -1
- package/pdfjs/web/postmessage-wrapper.js +1966 -1966
package/README.md
CHANGED
|
@@ -219,16 +219,32 @@ Add PDF.js assets to your `angular.json`:
|
|
|
219
219
|
|
|
220
220
|
#### Nginx Configuration
|
|
221
221
|
|
|
222
|
-
For production deployments using nginx,
|
|
222
|
+
For production deployments using nginx, configure MIME types for PDF.js ES modules:
|
|
223
223
|
|
|
224
224
|
```nginx
|
|
225
225
|
# Add to your nginx.conf or site configuration
|
|
226
226
|
types {
|
|
227
227
|
application/javascript js mjs;
|
|
228
|
+
text/plain ftl;
|
|
228
229
|
}
|
|
229
230
|
```
|
|
230
231
|
|
|
231
|
-
|
|
232
|
+
#### IIS Configuration (Windows Server)
|
|
233
|
+
|
|
234
|
+
For production deployments using IIS, add to your `web.config`:
|
|
235
|
+
|
|
236
|
+
```xml
|
|
237
|
+
<configuration>
|
|
238
|
+
<system.webServer>
|
|
239
|
+
<staticContent>
|
|
240
|
+
<mimeMap fileExtension=".mjs" mimeType="application/javascript" />
|
|
241
|
+
<mimeMap fileExtension=".ftl" mimeType="text/plain" />
|
|
242
|
+
</staticContent>
|
|
243
|
+
</system.webServer>
|
|
244
|
+
</configuration>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Why this is needed**: PDF.js v5+ uses `.mjs` files (ES modules) and `.ftl` files (localization). Without proper MIME type configuration, web servers serve these files with incorrect content-type headers, causing the PDF viewer to crash during loading in production environments.
|
|
232
248
|
|
|
233
249
|
### Angular Version Support
|
|
234
250
|
|
|
@@ -1885,10 +1885,7 @@ class PdfJsViewerComponent {
|
|
|
1885
1885
|
}
|
|
1886
1886
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: PdfJsViewerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1887
1887
|
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", urlValidation: "urlValidation", customSecurityTpl: "customSecurityTpl", theme: "theme", primaryColor: "primaryColor", backgroundColor: "backgroundColor", pageBorderColor: "pageBorderColor", pageSpacing: "pageSpacing", toolbarColor: "toolbarColor", textColor: "textColor", borderRadius: "borderRadius", customCSS: "customCSS", cspNonce: "cspNonce", iframeTitle: "iframeTitle", 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", iframeBorder: "iframeBorder", 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: `
|
|
1888
|
-
<div
|
|
1889
|
-
class="ng2-pdfjs-viewer-container"
|
|
1890
|
-
style="position:relative;width:100%;height:100%;"
|
|
1891
|
-
>
|
|
1888
|
+
<div class="ng2-pdfjs-viewer-container">
|
|
1892
1889
|
<iframe
|
|
1893
1890
|
[title]="iframeTitle || 'PDF document viewer'"
|
|
1894
1891
|
[hidden]="externalWindow || (!externalWindow && !pdfSrc)"
|
|
@@ -1903,18 +1900,15 @@ class PdfJsViewerComponent {
|
|
|
1903
1900
|
class="ng2-pdfjs-loading-overlay"
|
|
1904
1901
|
*ngIf="showSpinner && isLoading && !externalWindow"
|
|
1905
1902
|
[ngClass]="spinnerClass"
|
|
1906
|
-
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);"
|
|
1907
1903
|
>
|
|
1908
1904
|
<ng-container
|
|
1909
1905
|
*ngIf="customSpinnerTpl; else defaultSpinner"
|
|
1910
1906
|
[ngTemplateOutlet]="customSpinnerTpl"
|
|
1911
1907
|
></ng-container>
|
|
1912
1908
|
<ng-template #defaultSpinner>
|
|
1913
|
-
<div
|
|
1914
|
-
<div
|
|
1915
|
-
|
|
1916
|
-
></div>
|
|
1917
|
-
<div style="margin-top:16px;color:#666;font-size:16px;">
|
|
1909
|
+
<div class="ng2-pdfjs-spinner-content">
|
|
1910
|
+
<div class="ng2-pdfjs-spinner-icon"></div>
|
|
1911
|
+
<div class="ng2-pdfjs-spinner-text">
|
|
1918
1912
|
Loading PDF...
|
|
1919
1913
|
</div>
|
|
1920
1914
|
</div>
|
|
@@ -1925,7 +1919,6 @@ class PdfJsViewerComponent {
|
|
|
1925
1919
|
class="ng2-pdfjs-error-overlay"
|
|
1926
1920
|
*ngIf="errorOverride && hasError && !externalWindow"
|
|
1927
1921
|
[ngClass]="errorClass"
|
|
1928
|
-
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);"
|
|
1929
1922
|
>
|
|
1930
1923
|
<ng-container
|
|
1931
1924
|
*ngIf="customErrorTpl; else defaultError"
|
|
@@ -1933,31 +1926,26 @@ class PdfJsViewerComponent {
|
|
|
1933
1926
|
[ngTemplateOutletContext]="getErrorTemplateData()"
|
|
1934
1927
|
></ng-container>
|
|
1935
1928
|
<ng-template #defaultError>
|
|
1936
|
-
<div
|
|
1937
|
-
<div
|
|
1929
|
+
<div class="ng2-pdfjs-error-content">
|
|
1930
|
+
<div class="ng2-pdfjs-error-icon">
|
|
1938
1931
|
⚠️
|
|
1939
1932
|
</div>
|
|
1940
|
-
<div
|
|
1941
|
-
style="color:#333;font-size:18px;font-weight:500;margin-bottom:8px;"
|
|
1942
|
-
>
|
|
1933
|
+
<div class="ng2-pdfjs-error-title">
|
|
1943
1934
|
Error Loading PDF
|
|
1944
1935
|
</div>
|
|
1945
|
-
<div
|
|
1936
|
+
<div class="ng2-pdfjs-error-message">
|
|
1946
1937
|
{{ currentErrorMessage }}
|
|
1947
1938
|
</div>
|
|
1948
1939
|
</div>
|
|
1949
1940
|
</ng-template>
|
|
1950
1941
|
</div>
|
|
1951
1942
|
</div>
|
|
1952
|
-
`, 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"] }] });
|
|
1943
|
+
`, isInline: true, styles: [".ng2-pdfjs-viewer-container{position:relative;width:100%;height:100%}.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-spinner-content{text-align:center}.ng2-pdfjs-spinner-icon{display:inline-block;width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #2196F3;border-radius:50%;animation:spin 1s linear infinite}.ng2-pdfjs-spinner-text{margin-top:16px;color:#666;font-size:16px}.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)}.ng2-pdfjs-error-content{text-align:center;max-width:400px;padding:20px}.ng2-pdfjs-error-icon{font-size:48px;color:#f44336;margin-bottom:16px}.ng2-pdfjs-error-title{color:#333;font-size:18px;font-weight:500;margin-bottom:8px}.ng2-pdfjs-error-message{color:#666;font-size:14px;line-height:1.4}@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"] }] });
|
|
1953
1944
|
}
|
|
1954
1945
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: PdfJsViewerComponent, decorators: [{
|
|
1955
1946
|
type: Component,
|
|
1956
1947
|
args: [{ selector: "ng2-pdfjs-viewer", standalone: false, template: `
|
|
1957
|
-
<div
|
|
1958
|
-
class="ng2-pdfjs-viewer-container"
|
|
1959
|
-
style="position:relative;width:100%;height:100%;"
|
|
1960
|
-
>
|
|
1948
|
+
<div class="ng2-pdfjs-viewer-container">
|
|
1961
1949
|
<iframe
|
|
1962
1950
|
[title]="iframeTitle || 'PDF document viewer'"
|
|
1963
1951
|
[hidden]="externalWindow || (!externalWindow && !pdfSrc)"
|
|
@@ -1972,18 +1960,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
|
|
|
1972
1960
|
class="ng2-pdfjs-loading-overlay"
|
|
1973
1961
|
*ngIf="showSpinner && isLoading && !externalWindow"
|
|
1974
1962
|
[ngClass]="spinnerClass"
|
|
1975
|
-
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);"
|
|
1976
1963
|
>
|
|
1977
1964
|
<ng-container
|
|
1978
1965
|
*ngIf="customSpinnerTpl; else defaultSpinner"
|
|
1979
1966
|
[ngTemplateOutlet]="customSpinnerTpl"
|
|
1980
1967
|
></ng-container>
|
|
1981
1968
|
<ng-template #defaultSpinner>
|
|
1982
|
-
<div
|
|
1983
|
-
<div
|
|
1984
|
-
|
|
1985
|
-
></div>
|
|
1986
|
-
<div style="margin-top:16px;color:#666;font-size:16px;">
|
|
1969
|
+
<div class="ng2-pdfjs-spinner-content">
|
|
1970
|
+
<div class="ng2-pdfjs-spinner-icon"></div>
|
|
1971
|
+
<div class="ng2-pdfjs-spinner-text">
|
|
1987
1972
|
Loading PDF...
|
|
1988
1973
|
</div>
|
|
1989
1974
|
</div>
|
|
@@ -1994,7 +1979,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
|
|
|
1994
1979
|
class="ng2-pdfjs-error-overlay"
|
|
1995
1980
|
*ngIf="errorOverride && hasError && !externalWindow"
|
|
1996
1981
|
[ngClass]="errorClass"
|
|
1997
|
-
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);"
|
|
1998
1982
|
>
|
|
1999
1983
|
<ng-container
|
|
2000
1984
|
*ngIf="customErrorTpl; else defaultError"
|
|
@@ -2002,23 +1986,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
|
|
|
2002
1986
|
[ngTemplateOutletContext]="getErrorTemplateData()"
|
|
2003
1987
|
></ng-container>
|
|
2004
1988
|
<ng-template #defaultError>
|
|
2005
|
-
<div
|
|
2006
|
-
<div
|
|
1989
|
+
<div class="ng2-pdfjs-error-content">
|
|
1990
|
+
<div class="ng2-pdfjs-error-icon">
|
|
2007
1991
|
⚠️
|
|
2008
1992
|
</div>
|
|
2009
|
-
<div
|
|
2010
|
-
style="color:#333;font-size:18px;font-weight:500;margin-bottom:8px;"
|
|
2011
|
-
>
|
|
1993
|
+
<div class="ng2-pdfjs-error-title">
|
|
2012
1994
|
Error Loading PDF
|
|
2013
1995
|
</div>
|
|
2014
|
-
<div
|
|
1996
|
+
<div class="ng2-pdfjs-error-message">
|
|
2015
1997
|
{{ currentErrorMessage }}
|
|
2016
1998
|
</div>
|
|
2017
1999
|
</div>
|
|
2018
2000
|
</ng-template>
|
|
2019
2001
|
</div>
|
|
2020
2002
|
</div>
|
|
2021
|
-
`, 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"] }]
|
|
2003
|
+
`, styles: [".ng2-pdfjs-viewer-container{position:relative;width:100%;height:100%}.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-spinner-content{text-align:center}.ng2-pdfjs-spinner-icon{display:inline-block;width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #2196F3;border-radius:50%;animation:spin 1s linear infinite}.ng2-pdfjs-spinner-text{margin-top:16px;color:#666;font-size:16px}.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)}.ng2-pdfjs-error-content{text-align:center;max-width:400px;padding:20px}.ng2-pdfjs-error-icon{font-size:48px;color:#f44336;margin-bottom:16px}.ng2-pdfjs-error-title{color:#333;font-size:18px;font-weight:500;margin-bottom:8px}.ng2-pdfjs-error-message{color:#666;font-size:14px;line-height:1.4}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}\n"] }]
|
|
2022
2004
|
}], propDecorators: { iframe: [{
|
|
2023
2005
|
type: ViewChild,
|
|
2024
2006
|
args: ["iframe", { static: true }]
|