Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng2-pdfjs-viewer

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2-pdfjs-viewer - npm Package Compare versions

Comparing version 0.2.29 to 3.2.0

pdfjs/web/images/secondaryToolbarButton-scrollHorizontal.png

131

index.js

@@ -6,11 +6,11 @@ import { Component, Input, NgModule, ViewChild } from '@angular/core';

* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
//import viewerHtml from 'pdfjs/web/viewer.html';
//declare var require: any
//require('static-reference')('./pdfjs/web/viewer.html');
//declare var path: any;
var PdfJsViewerComponent = /** @class */ (function () {
function PdfJsViewerComponent() {
this.externalWindow = false;
this.showSpinner = true;
this.openFile = true;
this.download = true;
this.viewBookmark = true;
}

@@ -42,3 +42,2 @@ Object.defineProperty(PdfJsViewerComponent.prototype, "pdfSrc", {

if (!this.externalWindow) { // Load pdf for embedded views
// Load pdf for embedded views
this.loadPdf();

@@ -54,9 +53,10 @@ }

function () {
// Needs to be invoked for external window or when needs to reload pdf
this.loadPdf();
};
/**
* @private
* @return {?}
*/
PdfJsViewerComponent.prototype.loadPdf = /**
* @private
* @return {?}

@@ -72,6 +72,2 @@ */

// }
// console.log(`Tab is - ${this.viewerTab}`);
// if (this.viewerTab) {
// console.log(`Status of window - ${this.viewerTab.closed}`);
// }
if (this.externalWindow && (typeof this.viewerTab === 'undefined' || this.viewerTab.closed)) {

@@ -87,9 +83,7 @@ this.viewerTab = window.open('', '_blank');

}
var /** @type {?} */ fileUrl;
/** @type {?} */
var fileUrl;
//if (typeof this.src === "string") {
// fileUrl = this.src;
//}
//if (typeof this.src === "string") {
// fileUrl = this.src;
//}
if (this.innerSrc instanceof Blob) {

@@ -99,3 +93,4 @@ fileUrl = encodeURIComponent(URL.createObjectURL(this.innerSrc));

else if (this.innerSrc instanceof Uint8Array) {
var /** @type {?} */ blob = new Blob([this.innerSrc], { type: "application/pdf" });
/** @type {?} */
var blob = new Blob([this.innerSrc], { type: "application/pdf" });
fileUrl = encodeURIComponent(URL.createObjectURL(blob));

@@ -106,3 +101,4 @@ }

}
var /** @type {?} */ viewerUrl;
/** @type {?} */
var viewerUrl;
if (this.pdfJsFolder) {

@@ -119,13 +115,66 @@ viewerUrl = this.pdfJsFolder + "/web/viewer.html";

if (this.downloadFileName) {
viewerUrl += "&fileName=" + this.downloadFileName + ".pdf";
if (!this.downloadFileName.endsWith(".pdf")) {
this.downloadFileName += ".pdf";
}
viewerUrl += "&fileName=" + this.downloadFileName;
}
if (typeof this.openFile !== 'undefined') {
if (this.openFile) {
viewerUrl += "&openFile=" + this.openFile;
}
if (typeof this.download !== 'undefined') {
if (this.download) {
viewerUrl += "&download=" + this.download;
}
if (typeof this.viewBookmark !== 'undefined') {
if (this.startDownload) {
viewerUrl += "&startDownload=" + this.startDownload;
}
if (this.viewBookmark) {
viewerUrl += "&viewBookmark=" + this.viewBookmark;
}
if (this.print) {
viewerUrl += "&print=" + this.print;
}
if (this.startPrint) {
viewerUrl += "&startPrint=" + this.startPrint;
}
if (this.fullScreen) {
viewerUrl += "&fullScreen=" + this.fullScreen;
}
// if (this.showFullScreen) {
// viewerUrl += `&showFullScreen=${this.showFullScreen}`;
// }
if (this.find) {
viewerUrl += "&find=" + this.find;
}
if (this.lastPage) {
viewerUrl += "&lastpage=" + this.lastPage;
}
if (this.rotatecw) {
viewerUrl += "&rotatecw=" + this.rotatecw;
}
if (this.rotateccw) {
viewerUrl += "&rotateccw=" + this.rotateccw;
}
if (this.cursor) {
viewerUrl += "&cursor=" + this.cursor;
}
if (this.scroll) {
viewerUrl += "&scroll=" + this.scroll;
}
if (this.spread) {
viewerUrl += "&spread=" + this.spread;
}
if (this.page || this.zoom || this.nameddest || this.pagemode)
viewerUrl += "#";
if (this.page) {
viewerUrl += "&page=" + this.page;
}
if (this.zoom) {
viewerUrl += "&zoom=" + this.zoom;
}
if (this.nameddest) {
viewerUrl += "&nameddest=" + this.nameddest;
}
if (this.pagemode) {
viewerUrl += "&pagemode=" + this.pagemode;
}
if (this.externalWindow) {

@@ -137,2 +186,3 @@ this.viewerTab.location.href = viewerUrl;

}
console.log("\n pdfSrc = " + this.pdfSrc + "\n fileUrl = " + fileUrl + "\n externalWindow = " + this.externalWindow + "\n downloadFileName = " + this.downloadFileName + "\n pdfJsFolder = " + this.pdfJsFolder + "\n openFile = " + this.openFile + "\n download = " + this.download + "\n startDownload = " + this.startDownload + "\n viewBookmark = " + this.viewBookmark + "\n print = " + this.print + "\n startPrint = " + this.startPrint + "\n fullScreen = " + this.fullScreen + "\n find = " + this.find + "\n lastPage = " + this.lastPage + "\n rotatecw = " + this.rotatecw + "\n rotateccw = " + this.rotateccw + "\n cursor = " + this.cursor + "\n scrollMode = " + this.scroll + "\n spread = " + this.spread + "\n page = " + this.page + "\n zoom = " + this.zoom + "\n nameddest = " + this.nameddest + "\n pagemode = " + this.pagemode + "\n ");
};

@@ -145,14 +195,27 @@ PdfJsViewerComponent.decorators = [

];
/** @nocollapse */
PdfJsViewerComponent.ctorParameters = function () { return []; };
PdfJsViewerComponent.propDecorators = {
"iframe": [{ type: ViewChild, args: ['iframe',] },],
"pdfJsFolder": [{ type: Input },],
"externalWindow": [{ type: Input },],
"showSpinner": [{ type: Input },],
"downloadFileName": [{ type: Input },],
"openFile": [{ type: Input },],
"download": [{ type: Input },],
"viewBookmark": [{ type: Input },],
"pdfSrc": [{ type: Input },],
iframe: [{ type: ViewChild, args: ['iframe',] }],
pdfJsFolder: [{ type: Input }],
externalWindow: [{ type: Input }],
showSpinner: [{ type: Input }],
downloadFileName: [{ type: Input }],
openFile: [{ type: Input }],
download: [{ type: Input }],
startDownload: [{ type: Input }],
viewBookmark: [{ type: Input }],
print: [{ type: Input }],
startPrint: [{ type: Input }],
fullScreen: [{ type: Input }],
find: [{ type: Input }],
page: [{ type: Input }],
zoom: [{ type: Input }],
nameddest: [{ type: Input }],
pagemode: [{ type: Input }],
lastPage: [{ type: Input }],
rotatecw: [{ type: Input }],
rotateccw: [{ type: Input }],
cursor: [{ type: Input }],
scroll: [{ type: Input }],
spread: [{ type: Input }],
pdfSrc: [{ type: Input }]
};

@@ -164,3 +227,3 @@ return PdfJsViewerComponent;

* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/

@@ -194,4 +257,2 @@ var PdfJsViewerModule = /** @class */ (function () {

];
/** @nocollapse */
PdfJsViewerModule.ctorParameters = function () { return []; };
return PdfJsViewerModule;

@@ -198,0 +259,0 @@ }());

@@ -10,3 +10,18 @@ import { ElementRef } from '@angular/core';

download: boolean;
startDownload: boolean;
viewBookmark: boolean;
print: boolean;
startPrint: boolean;
fullScreen: boolean;
find: boolean;
page: number;
zoom: string;
nameddest: string;
pagemode: string;
lastPage: boolean;
rotatecw: boolean;
rotateccw: boolean;
cursor: string;
scroll: string;
spread: string;
viewerTab: any;

@@ -17,3 +32,3 @@ private innerSrc;

refresh(): void;
private loadPdf();
private loadPdf;
}

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":4,"metadata":{"PdfJsViewerModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":6,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":8,"character":4}],"declarations":[{"__symbolic":"reference","name":"PdfJsViewerComponent"}],"exports":[{"__symbolic":"reference","name":"PdfJsViewerComponent"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"PdfJsViewerModule"}}}}},"PdfJsViewerComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":7,"character":1},"arguments":[{"selector":"ng2-pdfjs-viewer","template":"<iframe [hidden]=\"externalWindow || (!externalWindow && !pdfSrc)\" #iframe width=\"100%\" height=\"100%\"></iframe>"}]}],"members":{"iframe":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":12,"character":3},"arguments":["iframe"]}]}],"pdfJsFolder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":24,"character":3}}]}],"externalWindow":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":25,"character":3}}]}],"showSpinner":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":26,"character":3}}]}],"downloadFileName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":27,"character":3}}]}],"openFile":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":28,"character":3}}]}],"download":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":29,"character":3}}]}],"viewBookmark":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":30,"character":3}}]}],"pdfSrc":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":35,"character":3}}]}],"ngOnInit":[{"__symbolic":"method"}],"refresh":[{"__symbolic":"method"}],"loadPdf":[{"__symbolic":"method"}]}}},"origins":{"PdfJsViewerModule":"./index","PdfJsViewerComponent":"./ng2-pdfjs-viewer.component"},"importAs":"ng2-pdfjs-viewer"}
{"__symbolic":"module","version":4,"metadata":{"PdfJsViewerModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":6,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":8,"character":4}],"declarations":[{"__symbolic":"reference","name":"PdfJsViewerComponent"}],"exports":[{"__symbolic":"reference","name":"PdfJsViewerComponent"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"PdfJsViewerModule"}}}}},"PdfJsViewerComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":7,"character":1},"arguments":[{"selector":"ng2-pdfjs-viewer","template":"<iframe [hidden]=\"externalWindow || (!externalWindow && !pdfSrc)\" #iframe width=\"100%\" height=\"100%\"></iframe>"}]}],"members":{"iframe":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":12,"character":3},"arguments":["iframe"]}]}],"pdfJsFolder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":24,"character":3}}]}],"externalWindow":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":25,"character":3}}]}],"showSpinner":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":26,"character":3}}]}],"downloadFileName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":27,"character":3}}]}],"openFile":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":28,"character":3}}]}],"download":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":29,"character":3}}]}],"startDownload":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":30,"character":3}}]}],"viewBookmark":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":31,"character":3}}]}],"print":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":32,"character":3}}]}],"startPrint":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":33,"character":3}}]}],"fullScreen":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":34,"character":3}}]}],"find":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":36,"character":3}}]}],"page":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":37,"character":3}}]}],"zoom":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":38,"character":3}}]}],"nameddest":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":39,"character":3}}]}],"pagemode":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":40,"character":3}}]}],"lastPage":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":41,"character":3}}]}],"rotatecw":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":42,"character":3}}]}],"rotateccw":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":43,"character":3}}]}],"cursor":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":44,"character":3}}]}],"scroll":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":45,"character":3}}]}],"spread":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":46,"character":3}}]}],"pdfSrc":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":51,"character":3}}]}],"ngOnInit":[{"__symbolic":"method"}],"refresh":[{"__symbolic":"method"}],"loadPdf":[{"__symbolic":"method"}]}}},"origins":{"PdfJsViewerModule":"./index","PdfJsViewerComponent":"./ng2-pdfjs-viewer.component"},"importAs":"ng2-pdfjs-viewer"}

@@ -9,11 +9,11 @@ (function (global, factory) {

* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
//import viewerHtml from 'pdfjs/web/viewer.html';
//declare var require: any
//require('static-reference')('./pdfjs/web/viewer.html');
//declare var path: any;
var PdfJsViewerComponent = /** @class */ (function () {
function PdfJsViewerComponent() {
this.externalWindow = false;
this.showSpinner = true;
this.openFile = true;
this.download = true;
this.viewBookmark = true;
}

@@ -45,3 +45,2 @@ Object.defineProperty(PdfJsViewerComponent.prototype, "pdfSrc", {

if (!this.externalWindow) { // Load pdf for embedded views
// Load pdf for embedded views
this.loadPdf();

@@ -57,9 +56,10 @@ }

function () {
// Needs to be invoked for external window or when needs to reload pdf
this.loadPdf();
};
/**
* @private
* @return {?}
*/
PdfJsViewerComponent.prototype.loadPdf = /**
* @private
* @return {?}

@@ -75,6 +75,2 @@ */

// }
// console.log(`Tab is - ${this.viewerTab}`);
// if (this.viewerTab) {
// console.log(`Status of window - ${this.viewerTab.closed}`);
// }
if (this.externalWindow && (typeof this.viewerTab === 'undefined' || this.viewerTab.closed)) {

@@ -90,9 +86,7 @@ this.viewerTab = window.open('', '_blank');

}
var /** @type {?} */ fileUrl;
/** @type {?} */
var fileUrl;
//if (typeof this.src === "string") {
// fileUrl = this.src;
//}
//if (typeof this.src === "string") {
// fileUrl = this.src;
//}
if (this.innerSrc instanceof Blob) {

@@ -102,3 +96,4 @@ fileUrl = encodeURIComponent(URL.createObjectURL(this.innerSrc));

else if (this.innerSrc instanceof Uint8Array) {
var /** @type {?} */ blob = new Blob([this.innerSrc], { type: "application/pdf" });
/** @type {?} */
var blob = new Blob([this.innerSrc], { type: "application/pdf" });
fileUrl = encodeURIComponent(URL.createObjectURL(blob));

@@ -109,3 +104,4 @@ }

}
var /** @type {?} */ viewerUrl;
/** @type {?} */
var viewerUrl;
if (this.pdfJsFolder) {

@@ -122,13 +118,66 @@ viewerUrl = this.pdfJsFolder + "/web/viewer.html";

if (this.downloadFileName) {
viewerUrl += "&fileName=" + this.downloadFileName + ".pdf";
if (!this.downloadFileName.endsWith(".pdf")) {
this.downloadFileName += ".pdf";
}
viewerUrl += "&fileName=" + this.downloadFileName;
}
if (typeof this.openFile !== 'undefined') {
if (this.openFile) {
viewerUrl += "&openFile=" + this.openFile;
}
if (typeof this.download !== 'undefined') {
if (this.download) {
viewerUrl += "&download=" + this.download;
}
if (typeof this.viewBookmark !== 'undefined') {
if (this.startDownload) {
viewerUrl += "&startDownload=" + this.startDownload;
}
if (this.viewBookmark) {
viewerUrl += "&viewBookmark=" + this.viewBookmark;
}
if (this.print) {
viewerUrl += "&print=" + this.print;
}
if (this.startPrint) {
viewerUrl += "&startPrint=" + this.startPrint;
}
if (this.fullScreen) {
viewerUrl += "&fullScreen=" + this.fullScreen;
}
// if (this.showFullScreen) {
// viewerUrl += `&showFullScreen=${this.showFullScreen}`;
// }
if (this.find) {
viewerUrl += "&find=" + this.find;
}
if (this.lastPage) {
viewerUrl += "&lastpage=" + this.lastPage;
}
if (this.rotatecw) {
viewerUrl += "&rotatecw=" + this.rotatecw;
}
if (this.rotateccw) {
viewerUrl += "&rotateccw=" + this.rotateccw;
}
if (this.cursor) {
viewerUrl += "&cursor=" + this.cursor;
}
if (this.scroll) {
viewerUrl += "&scroll=" + this.scroll;
}
if (this.spread) {
viewerUrl += "&spread=" + this.spread;
}
if (this.page || this.zoom || this.nameddest || this.pagemode)
viewerUrl += "#";
if (this.page) {
viewerUrl += "&page=" + this.page;
}
if (this.zoom) {
viewerUrl += "&zoom=" + this.zoom;
}
if (this.nameddest) {
viewerUrl += "&nameddest=" + this.nameddest;
}
if (this.pagemode) {
viewerUrl += "&pagemode=" + this.pagemode;
}
if (this.externalWindow) {

@@ -140,2 +189,3 @@ this.viewerTab.location.href = viewerUrl;

}
console.log("\n pdfSrc = " + this.pdfSrc + "\n fileUrl = " + fileUrl + "\n externalWindow = " + this.externalWindow + "\n downloadFileName = " + this.downloadFileName + "\n pdfJsFolder = " + this.pdfJsFolder + "\n openFile = " + this.openFile + "\n download = " + this.download + "\n startDownload = " + this.startDownload + "\n viewBookmark = " + this.viewBookmark + "\n print = " + this.print + "\n startPrint = " + this.startPrint + "\n fullScreen = " + this.fullScreen + "\n find = " + this.find + "\n lastPage = " + this.lastPage + "\n rotatecw = " + this.rotatecw + "\n rotateccw = " + this.rotateccw + "\n cursor = " + this.cursor + "\n scrollMode = " + this.scroll + "\n spread = " + this.spread + "\n page = " + this.page + "\n zoom = " + this.zoom + "\n nameddest = " + this.nameddest + "\n pagemode = " + this.pagemode + "\n ");
};

@@ -148,14 +198,27 @@ PdfJsViewerComponent.decorators = [

];
/** @nocollapse */
PdfJsViewerComponent.ctorParameters = function () { return []; };
PdfJsViewerComponent.propDecorators = {
"iframe": [{ type: core.ViewChild, args: ['iframe',] },],
"pdfJsFolder": [{ type: core.Input },],
"externalWindow": [{ type: core.Input },],
"showSpinner": [{ type: core.Input },],
"downloadFileName": [{ type: core.Input },],
"openFile": [{ type: core.Input },],
"download": [{ type: core.Input },],
"viewBookmark": [{ type: core.Input },],
"pdfSrc": [{ type: core.Input },],
iframe: [{ type: core.ViewChild, args: ['iframe',] }],
pdfJsFolder: [{ type: core.Input }],
externalWindow: [{ type: core.Input }],
showSpinner: [{ type: core.Input }],
downloadFileName: [{ type: core.Input }],
openFile: [{ type: core.Input }],
download: [{ type: core.Input }],
startDownload: [{ type: core.Input }],
viewBookmark: [{ type: core.Input }],
print: [{ type: core.Input }],
startPrint: [{ type: core.Input }],
fullScreen: [{ type: core.Input }],
find: [{ type: core.Input }],
page: [{ type: core.Input }],
zoom: [{ type: core.Input }],
nameddest: [{ type: core.Input }],
pagemode: [{ type: core.Input }],
lastPage: [{ type: core.Input }],
rotatecw: [{ type: core.Input }],
rotateccw: [{ type: core.Input }],
cursor: [{ type: core.Input }],
scroll: [{ type: core.Input }],
spread: [{ type: core.Input }],
pdfSrc: [{ type: core.Input }]
};

@@ -167,3 +230,3 @@ return PdfJsViewerComponent;

* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/

@@ -197,4 +260,2 @@ var PdfJsViewerModule = /** @class */ (function () {

];
/** @nocollapse */
PdfJsViewerModule.ctorParameters = function () { return []; };
return PdfJsViewerModule;

@@ -201,0 +262,0 @@ }());

{
"name": "ng2-pdfjs-viewer",
"version": "0.2.29",
"version": "3.2.0",
"repository": {

@@ -29,6 +29,4 @@ "type": "git",

"peerDependencies": {
"@angular/core": "^4.0.0",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
"@angular/core": "^7.2.15"
}
}

@@ -1,620 +0,1 @@

/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-var */
'use strict';
var FontInspector = (function FontInspectorClosure() {
var fonts;
var active = false;
var fontAttribute = 'data-font-name';
function removeSelection() {
var divs = document.querySelectorAll('div[' + fontAttribute + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
div.className = '';
}
}
function resetSelection() {
var divs = document.querySelectorAll('div[' + fontAttribute + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
div.className = 'debuggerHideText';
}
}
function selectFont(fontName, show) {
var divs = document.querySelectorAll('div[' + fontAttribute + '=' +
fontName + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
div.className = show ? 'debuggerShowText' : 'debuggerHideText';
}
}
function textLayerClick(e) {
if (!e.target.dataset.fontName ||
e.target.tagName.toUpperCase() !== 'DIV') {
return;
}
var fontName = e.target.dataset.fontName;
var selects = document.getElementsByTagName('input');
for (var i = 0; i < selects.length; ++i) {
var select = selects[i];
if (select.dataset.fontName !== fontName) {
continue;
}
select.checked = !select.checked;
selectFont(fontName, select.checked);
select.scrollIntoView();
}
}
return {
// Properties/functions needed by PDFBug.
id: 'FontInspector',
name: 'Font Inspector',
panel: null,
manager: null,
init: function init(pdfjsLib) {
var panel = this.panel;
panel.setAttribute('style', 'padding: 5px;');
var tmp = document.createElement('button');
tmp.addEventListener('click', resetSelection);
tmp.textContent = 'Refresh';
panel.appendChild(tmp);
fonts = document.createElement('div');
panel.appendChild(fonts);
},
cleanup: function cleanup() {
fonts.textContent = '';
},
enabled: false,
get active() {
return active;
},
set active(value) {
active = value;
if (active) {
document.body.addEventListener('click', textLayerClick, true);
resetSelection();
} else {
document.body.removeEventListener('click', textLayerClick, true);
removeSelection();
}
},
// FontInspector specific functions.
fontAdded: function fontAdded(fontObj, url) {
function properties(obj, list) {
var moreInfo = document.createElement('table');
for (var i = 0; i < list.length; i++) {
var tr = document.createElement('tr');
var td1 = document.createElement('td');
td1.textContent = list[i];
tr.appendChild(td1);
var td2 = document.createElement('td');
td2.textContent = obj[list[i]].toString();
tr.appendChild(td2);
moreInfo.appendChild(tr);
}
return moreInfo;
}
var moreInfo = properties(fontObj, ['name', 'type']);
var fontName = fontObj.loadedName;
var font = document.createElement('div');
var name = document.createElement('span');
name.textContent = fontName;
var download = document.createElement('a');
if (url) {
url = /url\(['"]?([^\)"']+)/.exec(url);
download.href = url[1];
} else if (fontObj.data) {
url = URL.createObjectURL(new Blob([fontObj.data], {
type: fontObj.mimeType,
}));
download.href = url;
}
download.textContent = 'Download';
var logIt = document.createElement('a');
logIt.href = '';
logIt.textContent = 'Log';
logIt.addEventListener('click', function(event) {
event.preventDefault();
console.log(fontObj);
});
var select = document.createElement('input');
select.setAttribute('type', 'checkbox');
select.dataset.fontName = fontName;
select.addEventListener('click', (function(select, fontName) {
return (function() {
selectFont(fontName, select.checked);
});
})(select, fontName));
font.appendChild(select);
font.appendChild(name);
font.appendChild(document.createTextNode(' '));
font.appendChild(download);
font.appendChild(document.createTextNode(' '));
font.appendChild(logIt);
font.appendChild(moreInfo);
fonts.appendChild(font);
// Somewhat of a hack, should probably add a hook for when the text layer
// is done rendering.
setTimeout(() => {
if (this.active) {
resetSelection();
}
}, 2000);
},
};
})();
var opMap;
// Manages all the page steppers.
var StepperManager = (function StepperManagerClosure() {
var steppers = [];
var stepperDiv = null;
var stepperControls = null;
var stepperChooser = null;
var breakPoints = Object.create(null);
return {
// Properties/functions needed by PDFBug.
id: 'Stepper',
name: 'Stepper',
panel: null,
manager: null,
init: function init(pdfjsLib) {
var self = this;
this.panel.setAttribute('style', 'padding: 5px;');
stepperControls = document.createElement('div');
stepperChooser = document.createElement('select');
stepperChooser.addEventListener('change', function(event) {
self.selectStepper(this.value);
});
stepperControls.appendChild(stepperChooser);
stepperDiv = document.createElement('div');
this.panel.appendChild(stepperControls);
this.panel.appendChild(stepperDiv);
if (sessionStorage.getItem('pdfjsBreakPoints')) {
breakPoints = JSON.parse(sessionStorage.getItem('pdfjsBreakPoints'));
}
opMap = Object.create(null);
for (var key in pdfjsLib.OPS) {
opMap[pdfjsLib.OPS[key]] = key;
}
},
cleanup: function cleanup() {
stepperChooser.textContent = '';
stepperDiv.textContent = '';
steppers = [];
},
enabled: false,
active: false,
// Stepper specific functions.
create: function create(pageIndex) {
var debug = document.createElement('div');
debug.id = 'stepper' + pageIndex;
debug.setAttribute('hidden', true);
debug.className = 'stepper';
stepperDiv.appendChild(debug);
var b = document.createElement('option');
b.textContent = 'Page ' + (pageIndex + 1);
b.value = pageIndex;
stepperChooser.appendChild(b);
var initBreakPoints = breakPoints[pageIndex] || [];
var stepper = new Stepper(debug, pageIndex, initBreakPoints);
steppers.push(stepper);
if (steppers.length === 1) {
this.selectStepper(pageIndex, false);
}
return stepper;
},
selectStepper: function selectStepper(pageIndex, selectPanel) {
var i;
pageIndex = pageIndex | 0;
if (selectPanel) {
this.manager.selectPanel(this);
}
for (i = 0; i < steppers.length; ++i) {
var stepper = steppers[i];
if (stepper.pageIndex === pageIndex) {
stepper.panel.removeAttribute('hidden');
} else {
stepper.panel.setAttribute('hidden', true);
}
}
var options = stepperChooser.options;
for (i = 0; i < options.length; ++i) {
var option = options[i];
option.selected = (option.value | 0) === pageIndex;
}
},
saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
breakPoints[pageIndex] = bps;
sessionStorage.setItem('pdfjsBreakPoints', JSON.stringify(breakPoints));
},
};
})();
// The stepper for each page's IRQueue.
var Stepper = (function StepperClosure() {
// Shorter way to create element and optionally set textContent.
function c(tag, textContent) {
var d = document.createElement(tag);
if (textContent) {
d.textContent = textContent;
}
return d;
}
function simplifyArgs(args) {
if (typeof args === 'string') {
var MAX_STRING_LENGTH = 75;
return args.length <= MAX_STRING_LENGTH ? args :
args.substr(0, MAX_STRING_LENGTH) + '...';
}
if (typeof args !== 'object' || args === null) {
return args;
}
if ('length' in args) { // array
var simpleArgs = [], i, ii;
var MAX_ITEMS = 10;
for (i = 0, ii = Math.min(MAX_ITEMS, args.length); i < ii; i++) {
simpleArgs.push(simplifyArgs(args[i]));
}
if (i < args.length) {
simpleArgs.push('...');
}
return simpleArgs;
}
var simpleObj = {};
for (var key in args) {
simpleObj[key] = simplifyArgs(args[key]);
}
return simpleObj;
}
function Stepper(panel, pageIndex, initialBreakPoints) {
this.panel = panel;
this.breakPoint = 0;
this.nextBreakPoint = null;
this.pageIndex = pageIndex;
this.breakPoints = initialBreakPoints;
this.currentIdx = -1;
this.operatorListIdx = 0;
}
Stepper.prototype = {
init: function init(operatorList) {
var panel = this.panel;
var content = c('div', 'c=continue, s=step');
var table = c('table');
content.appendChild(table);
table.cellSpacing = 0;
var headerRow = c('tr');
table.appendChild(headerRow);
headerRow.appendChild(c('th', 'Break'));
headerRow.appendChild(c('th', 'Idx'));
headerRow.appendChild(c('th', 'fn'));
headerRow.appendChild(c('th', 'args'));
panel.appendChild(content);
this.table = table;
this.updateOperatorList(operatorList);
},
updateOperatorList: function updateOperatorList(operatorList) {
var self = this;
function cboxOnClick() {
var x = +this.dataset.idx;
if (this.checked) {
self.breakPoints.push(x);
} else {
self.breakPoints.splice(self.breakPoints.indexOf(x), 1);
}
StepperManager.saveBreakPoints(self.pageIndex, self.breakPoints);
}
var MAX_OPERATORS_COUNT = 15000;
if (this.operatorListIdx > MAX_OPERATORS_COUNT) {
return;
}
var chunk = document.createDocumentFragment();
var operatorsToDisplay = Math.min(MAX_OPERATORS_COUNT,
operatorList.fnArray.length);
for (var i = this.operatorListIdx; i < operatorsToDisplay; i++) {
var line = c('tr');
line.className = 'line';
line.dataset.idx = i;
chunk.appendChild(line);
var checked = this.breakPoints.includes(i);
var args = operatorList.argsArray[i] || [];
var breakCell = c('td');
var cbox = c('input');
cbox.type = 'checkbox';
cbox.className = 'points';
cbox.checked = checked;
cbox.dataset.idx = i;
cbox.onclick = cboxOnClick;
breakCell.appendChild(cbox);
line.appendChild(breakCell);
line.appendChild(c('td', i.toString()));
var fn = opMap[operatorList.fnArray[i]];
var decArgs = args;
if (fn === 'showText') {
var glyphs = args[0];
var newArgs = [];
var str = [];
for (var j = 0; j < glyphs.length; j++) {
var glyph = glyphs[j];
if (typeof glyph === 'object' && glyph !== null) {
str.push(glyph.fontChar);
} else {
if (str.length > 0) {
newArgs.push(str.join(''));
str = [];
}
newArgs.push(glyph); // null or number
}
}
if (str.length > 0) {
newArgs.push(str.join(''));
}
decArgs = [newArgs];
}
line.appendChild(c('td', fn));
line.appendChild(c('td', JSON.stringify(simplifyArgs(decArgs))));
}
if (operatorsToDisplay < operatorList.fnArray.length) {
line = c('tr');
var lastCell = c('td', '...');
lastCell.colspan = 4;
chunk.appendChild(lastCell);
}
this.operatorListIdx = operatorList.fnArray.length;
this.table.appendChild(chunk);
},
getNextBreakPoint: function getNextBreakPoint() {
this.breakPoints.sort(function(a, b) {
return a - b;
});
for (var i = 0; i < this.breakPoints.length; i++) {
if (this.breakPoints[i] > this.currentIdx) {
return this.breakPoints[i];
}
}
return null;
},
breakIt: function breakIt(idx, callback) {
StepperManager.selectStepper(this.pageIndex, true);
var self = this;
var dom = document;
self.currentIdx = idx;
var listener = function(e) {
switch (e.keyCode) {
case 83: // step
dom.removeEventListener('keydown', listener);
self.nextBreakPoint = self.currentIdx + 1;
self.goTo(-1);
callback();
break;
case 67: // continue
dom.removeEventListener('keydown', listener);
var breakPoint = self.getNextBreakPoint();
self.nextBreakPoint = breakPoint;
self.goTo(-1);
callback();
break;
}
};
dom.addEventListener('keydown', listener);
self.goTo(idx);
},
goTo: function goTo(idx) {
var allRows = this.panel.getElementsByClassName('line');
for (var x = 0, xx = allRows.length; x < xx; ++x) {
var row = allRows[x];
if ((row.dataset.idx | 0) === idx) {
row.style.backgroundColor = 'rgb(251,250,207)';
row.scrollIntoView();
} else {
row.style.backgroundColor = null;
}
}
},
};
return Stepper;
})();
var Stats = (function Stats() {
var stats = [];
function clear(node) {
while (node.hasChildNodes()) {
node.removeChild(node.lastChild);
}
}
function getStatIndex(pageNumber) {
for (var i = 0, ii = stats.length; i < ii; ++i) {
if (stats[i].pageNumber === pageNumber) {
return i;
}
}
return false;
}
return {
// Properties/functions needed by PDFBug.
id: 'Stats',
name: 'Stats',
panel: null,
manager: null,
init(pdfjsLib) {
this.panel.setAttribute('style', 'padding: 5px;');
},
enabled: false,
active: false,
// Stats specific functions.
add(pageNumber, stat) {
if (!stat) {
return;
}
var statsIndex = getStatIndex(pageNumber);
if (statsIndex !== false) {
var b = stats[statsIndex];
this.panel.removeChild(b.div);
stats.splice(statsIndex, 1);
}
var wrapper = document.createElement('div');
wrapper.className = 'stats';
var title = document.createElement('div');
title.className = 'title';
title.textContent = 'Page: ' + pageNumber;
var statsDiv = document.createElement('div');
statsDiv.textContent = stat.toString();
wrapper.appendChild(title);
wrapper.appendChild(statsDiv);
stats.push({ pageNumber, div: wrapper, });
stats.sort(function(a, b) {
return a.pageNumber - b.pageNumber;
});
clear(this.panel);
for (var i = 0, ii = stats.length; i < ii; ++i) {
this.panel.appendChild(stats[i].div);
}
},
cleanup() {
stats = [];
clear(this.panel);
},
};
})();
// Manages all the debugging tools.
window.PDFBug = (function PDFBugClosure() {
var panelWidth = 300;
var buttons = [];
var activePanel = null;
return {
tools: [
FontInspector,
StepperManager,
Stats
],
enable(ids) {
var all = false, tools = this.tools;
if (ids.length === 1 && ids[0] === 'all') {
all = true;
}
for (var i = 0; i < tools.length; ++i) {
var tool = tools[i];
if (all || ids.includes(tool.id)) {
tool.enabled = true;
}
}
if (!all) {
// Sort the tools by the order they are enabled.
tools.sort(function(a, b) {
var indexA = ids.indexOf(a.id);
indexA = indexA < 0 ? tools.length : indexA;
var indexB = ids.indexOf(b.id);
indexB = indexB < 0 ? tools.length : indexB;
return indexA - indexB;
});
}
},
init(pdfjsLib, container) {
/*
* Basic Layout:
* PDFBug
* Controls
* Panels
* Panel
* Panel
* ...
*/
var ui = document.createElement('div');
ui.id = 'PDFBug';
var controls = document.createElement('div');
controls.setAttribute('class', 'controls');
ui.appendChild(controls);
var panels = document.createElement('div');
panels.setAttribute('class', 'panels');
ui.appendChild(panels);
container.appendChild(ui);
container.style.right = panelWidth + 'px';
// Initialize all the debugging tools.
var tools = this.tools;
var self = this;
for (var i = 0; i < tools.length; ++i) {
var tool = tools[i];
var panel = document.createElement('div');
var panelButton = document.createElement('button');
panelButton.textContent = tool.name;
panelButton.addEventListener('click', (function(selected) {
return function(event) {
event.preventDefault();
self.selectPanel(selected);
};
})(i));
controls.appendChild(panelButton);
panels.appendChild(panel);
tool.panel = panel;
tool.manager = this;
if (tool.enabled) {
tool.init(pdfjsLib);
} else {
panel.textContent = tool.name + ' is disabled. To enable add ' +
' "' + tool.id + '" to the pdfBug parameter ' +
'and refresh (separate multiple by commas).';
}
buttons.push(panelButton);
}
this.selectPanel(0);
},
cleanup() {
for (var i = 0, ii = this.tools.length; i < ii; i++) {
if (this.tools[i].enabled) {
this.tools[i].cleanup();
}
}
},
selectPanel(index) {
if (typeof index !== 'number') {
index = this.tools.indexOf(index);
}
if (index === activePanel) {
return;
}
activePanel = index;
var tools = this.tools;
for (var j = 0; j < tools.length; ++j) {
if (j === index) {
buttons[j].setAttribute('class', 'active');
tools[j].active = true;
tools[j].panel.removeAttribute('hidden');
} else {
buttons[j].setAttribute('class', '');
tools[j].active = false;
tools[j].panel.setAttribute('hidden', 'true');
}
}
},
};
})();
"use strict";var opMap,FontInspector=function(){var e,t,n=!1,a="data-font-name";function r(){let e=document.querySelectorAll(`span[${a}]`);for(let t of e)t.className="debuggerHideText"}function i(e,t){let n=document.querySelectorAll(`span[${a}=${e}]`);for(let e of n)e.className=t?"debuggerShowText":"debuggerHideText"}function o(e){if(e.target.dataset.fontName&&"SPAN"===e.target.tagName.toUpperCase())for(var t=e.target.dataset.fontName,n=document.getElementsByTagName("input"),a=0;a<n.length;++a){var r=n[a];r.dataset.fontName===t&&(r.checked=!r.checked,i(t,r.checked),r.scrollIntoView())}}return{id:"FontInspector",name:"Font Inspector",panel:null,manager:null,init:function(n){var a=this.panel;a.setAttribute("style","padding: 5px;");var i=document.createElement("button");i.addEventListener("click",r),i.textContent="Refresh",a.appendChild(i),e=document.createElement("div"),a.appendChild(e),t=n.createObjectURL},cleanup:function(){e.textContent=""},enabled:!1,get active(){return n},set active(e){(n=e)?(document.body.addEventListener("click",o,!0),r()):(document.body.removeEventListener("click",o,!0),function(){let e=document.querySelectorAll(`span[${a}]`);for(let t of e)t.className=""}())},fontAdded:function(n,a){var o=function(e,t){for(var n=document.createElement("table"),a=0;a<t.length;a++){var r=document.createElement("tr"),i=document.createElement("td");i.textContent=t[a],r.appendChild(i);var o=document.createElement("td");o.textContent=e[t[a]].toString(),r.appendChild(o),n.appendChild(r)}return n}(n,["name","type"]),d=n.loadedName,l=document.createElement("div"),s=document.createElement("span");s.textContent=d;var p=document.createElement("a");a?(a=/url\(['"]?([^\)"']+)/.exec(a),p.href=a[1]):n.data&&(p.href=t(n.data,n.mimeType)),p.textContent="Download";var c=document.createElement("a");c.href="",c.textContent="Log",c.addEventListener("click",function(e){e.preventDefault(),console.log(n)});var u=document.createElement("input");u.setAttribute("type","checkbox"),u.dataset.fontName=d,u.addEventListener("click",function(e,t){return function(){i(t,e.checked)}}(u,d)),l.appendChild(u),l.appendChild(s),l.appendChild(document.createTextNode(" ")),l.appendChild(p),l.appendChild(document.createTextNode(" ")),l.appendChild(c),l.appendChild(o),e.appendChild(l),setTimeout(()=>{this.active&&r()},2e3)}}}(),StepperManager=function(){var e=[],t=null,n=null,a=null,r=Object.create(null);return{id:"Stepper",name:"Stepper",panel:null,manager:null,init:function(e){var i=this;for(var o in this.panel.setAttribute("style","padding: 5px;"),n=document.createElement("div"),(a=document.createElement("select")).addEventListener("change",function(e){i.selectStepper(this.value)}),n.appendChild(a),t=document.createElement("div"),this.panel.appendChild(n),this.panel.appendChild(t),sessionStorage.getItem("pdfjsBreakPoints")&&(r=JSON.parse(sessionStorage.getItem("pdfjsBreakPoints"))),opMap=Object.create(null),e.OPS)opMap[e.OPS[o]]=o},cleanup:function(){a.textContent="",t.textContent="",e=[]},enabled:!1,active:!1,create:function(n){var i=document.createElement("div");i.id="stepper"+n,i.setAttribute("hidden",!0),i.className="stepper",t.appendChild(i);var o=document.createElement("option");o.textContent="Page "+(n+1),o.value=n,a.appendChild(o);var d=r[n]||[],l=new Stepper(i,n,d);return e.push(l),1===e.length&&this.selectStepper(n,!1),l},selectStepper:function(t,n){var r;for(t|=0,n&&this.manager.selectPanel(this),r=0;r<e.length;++r){var i=e[r];i.pageIndex===t?i.panel.removeAttribute("hidden"):i.panel.setAttribute("hidden",!0)}var o=a.options;for(r=0;r<o.length;++r){var d=o[r];d.selected=(0|d.value)===t}},saveBreakPoints:function(e,t){r[e]=t,sessionStorage.setItem("pdfjsBreakPoints",JSON.stringify(r))}}}(),Stepper=function(){function e(e,t){var n=document.createElement(e);return t&&(n.textContent=t),n}function t(e){if("string"==typeof e){return e.length<=75?e:e.substring(0,75)+"..."}if("object"!=typeof e||null===e)return e;if("length"in e){var n,a,r=[];for(n=0,a=Math.min(10,e.length);n<a;n++)r.push(t(e[n]));return n<e.length&&r.push("..."),r}var i={};for(var o in e)i[o]=t(e[o]);return i}function n(e,t,n){this.panel=e,this.breakPoint=0,this.nextBreakPoint=null,this.pageIndex=t,this.breakPoints=n,this.currentIdx=-1,this.operatorListIdx=0}return n.prototype={init:function(t){var n=this.panel,a=e("div","c=continue, s=step"),r=e("table");a.appendChild(r),r.cellSpacing=0;var i=e("tr");r.appendChild(i),i.appendChild(e("th","Break")),i.appendChild(e("th","Idx")),i.appendChild(e("th","fn")),i.appendChild(e("th","args")),n.appendChild(a),this.table=r,this.updateOperatorList(t)},updateOperatorList:function(n){var a=this;function r(){var e=+this.dataset.idx;this.checked?a.breakPoints.push(e):a.breakPoints.splice(a.breakPoints.indexOf(e),1),StepperManager.saveBreakPoints(a.pageIndex,a.breakPoints)}if(!(this.operatorListIdx>15e3)){for(var i=document.createDocumentFragment(),o=Math.min(15e3,n.fnArray.length),d=this.operatorListIdx;d<o;d++){var l=e("tr");l.className="line",l.dataset.idx=d,i.appendChild(l);var s=this.breakPoints.includes(d),p=n.argsArray[d]||[],c=e("td"),u=e("input");u.type="checkbox",u.className="points",u.checked=s,u.dataset.idx=d,u.onclick=r,c.appendChild(u),l.appendChild(c),l.appendChild(e("td",d.toString()));var h=opMap[n.fnArray[d]],m=p;if("showText"===h){for(var v=p[0],f=[],g=[],C=0;C<v.length;C++){var b=v[C];"object"==typeof b&&null!==b?g.push(b.fontChar):(g.length>0&&(f.push(g.join("")),g=[]),f.push(b))}g.length>0&&f.push(g.join("")),m=[f]}l.appendChild(e("td",h)),l.appendChild(e("td",JSON.stringify(t(m))))}if(o<n.fnArray.length){l=e("tr");var x=e("td","...");x.colspan=4,i.appendChild(x)}this.operatorListIdx=n.fnArray.length,this.table.appendChild(i)}},getNextBreakPoint:function(){this.breakPoints.sort(function(e,t){return e-t});for(var e=0;e<this.breakPoints.length;e++)if(this.breakPoints[e]>this.currentIdx)return this.breakPoints[e];return null},breakIt:function(e,t){StepperManager.selectStepper(this.pageIndex,!0);var n=this,a=document;n.currentIdx=e;var r=function(e){switch(e.keyCode){case 83:a.removeEventListener("keydown",r),n.nextBreakPoint=n.currentIdx+1,n.goTo(-1),t();break;case 67:a.removeEventListener("keydown",r);var i=n.getNextBreakPoint();n.nextBreakPoint=i,n.goTo(-1),t()}};a.addEventListener("keydown",r),n.goTo(e)},goTo:function(e){for(var t=this.panel.getElementsByClassName("line"),n=0,a=t.length;n<a;++n){var r=t[n];(0|r.dataset.idx)===e?(r.style.backgroundColor="rgb(251,250,207)",r.scrollIntoView()):r.style.backgroundColor=null}}},n}(),Stats=function(){var e=[];function t(e){for(;e.hasChildNodes();)e.removeChild(e.lastChild)}return{id:"Stats",name:"Stats",panel:null,manager:null,init(e){this.panel.setAttribute("style","padding: 5px;")},enabled:!1,active:!1,add(n,a){if(a){var r=function(t){for(var n=0,a=e.length;n<a;++n)if(e[n].pageNumber===t)return n;return!1}(n);if(!1!==r){var i=e[r];this.panel.removeChild(i.div),e.splice(r,1)}var o=document.createElement("div");o.className="stats";var d=document.createElement("div");d.className="title",d.textContent="Page: "+n;var l=document.createElement("div");l.textContent=a.toString(),o.appendChild(d),o.appendChild(l),e.push({pageNumber:n,div:o}),e.sort(function(e,t){return e.pageNumber-t.pageNumber}),t(this.panel);for(var s=0,p=e.length;s<p;++s)this.panel.appendChild(e[s].div)}},cleanup(){e=[],t(this.panel)}}}();window.PDFBug=function(){var e=[],t=null;return{tools:[FontInspector,StepperManager,Stats],enable(e){var t=!1,n=this.tools;1===e.length&&"all"===e[0]&&(t=!0);for(var a=0;a<n.length;++a){var r=n[a];(t||e.includes(r.id))&&(r.enabled=!0)}t||n.sort(function(t,a){var r=e.indexOf(t.id);r=r<0?n.length:r;var i=e.indexOf(a.id);return r-(i=i<0?n.length:i)})},init(t,n){var a=document.createElement("div");a.id="PDFBug";var r=document.createElement("div");r.setAttribute("class","controls"),a.appendChild(r);var i=document.createElement("div");i.setAttribute("class","panels"),a.appendChild(i),n.appendChild(a),n.style.right="300px";for(var o=this.tools,d=this,l=0;l<o.length;++l){var s=o[l],p=document.createElement("div"),c=document.createElement("button");c.textContent=s.name,c.addEventListener("click",function(e){return function(t){t.preventDefault(),d.selectPanel(e)}}(l)),r.appendChild(c),i.appendChild(p),s.panel=p,s.manager=this,s.enabled?s.init(t):p.textContent=s.name+' is disabled. To enable add "'+s.id+'" to the pdfBug parameter and refresh (separate multiple by commas).',e.push(c)}this.selectPanel(0)},cleanup(){for(var e=0,t=this.tools.length;e<t;e++)this.tools[e].enabled&&this.tools[e].cleanup()},selectPanel(n){if("number"!=typeof n&&(n=this.tools.indexOf(n)),n!==t){t=n;for(var a=this.tools,r=0;r<a.length;++r)r===n?(e[r].setAttribute("class","active"),a[r].active=!0,a[r].panel.removeAttribute("hidden")):(e[r].setAttribute("class",""),a[r].active=!1,a[r].panel.setAttribute("hidden","true"))}}}}();

@@ -1,2 +0,2 @@

# Angular 2+ PDFJS viewer with Mozilla's ViewerJS
# Angular 2+ PDFJS viewer with Mozilla's ViewerJS (Supports Angular 2/4/5/6/7)
<p align="center">

@@ -11,3 +11,3 @@ <a href="https://www.npmjs.com/package/ng2-pdfjs-viewer">

This is a simple library wraps mozilla's pdfjs and viewerjs into an angular2+ component.
This is a super simple library for displaying pdf inline/embedded or in a new tab along with a feature wrich viewer. It uses mozilla's pdfjs viewer behind the scenes and supports angular(2/4/5/6/7). Extremely lightweight, easiest to integrate and use, this library have only one dependancy (@angular/core).

@@ -22,3 +22,3 @@ ### Open in a new tab/window

## Step 1: To install `ng2-pdfjs-viewer`, run:
## Step 1: Install `ng2-pdfjs-viewer`

@@ -34,7 +34,5 @@ ```bash

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import PdfJsViewerModule module
import { PdfJsViewerModule } from 'ng2-pdfjs-viewer';
import { PdfJsViewerModule } from 'ng2-pdfjs-viewer'; // <-- Import PdfJsViewerModule module

@@ -47,4 +45,3 @@ @NgModule({

BrowserModule,
// Add to declarations
PdfJsViewerModule
PdfJsViewerModule // <-- Add to declarations
],

@@ -57,36 +54,47 @@ providers: [],

## Step 2: To use this library you need a copy of pdfjs
1. Using modified version of viewerJs available in the package (Recommended approach)
- Either copy `node_modules\ng2-pdfjs-viewer\pdfjs` to your public or asset folder Or use `TransferWebpackPlugin` or something similar to make sure the static files are accessible from the public folder in your application/webserver. Please note, if you decide to put `pdfjs` folder anywhere else other than the `assets` folder, make sure you also set `[pdfJsFolder]` property to help locate the folder.
## Step 2: Copy task for pdfjs
Copy `node_modules\ng2-pdfjs-viewer\pdfjs` to your public or asset folder Or use _`TransferWebpackPlugin`_ or similar plugins/task/build task to make sure the static files are accessible from the public folder in your application/webserver. Please note, if you decide to put _`pdfjs`_ folder anywhere else other than the _`assets`_ folder, make sure you also set _`[pdfJsFolder]`_ property to help locate the folder.
`TransferWebpackPlugin` Sample code
```typescript
var TransferWebpackPlugin = require('transfer-webpack-plugin');
...
plugins: [
new TransferWebpackPlugin([
{ from: 'node_modules\ng2-pdfjs-viewer\pdfjs', to: path.join(__dirname, 'assets') }
])
]
```
Now you can use additional settings such as
`[pdfJsFolder]`: To set the folder path under `web` and `build` resides.
`[externalWindow]`: To decide pdf should be inline or in a new tab
`[openFile]`: Show/hide open file icon
`[viewBookmark]`: Show/hide bookmark icon
`[download]`: Show/hide download icon
`[showSpinner]`: Show a simple css based spinner/progress before the pdf loads
**_`TransferWebpackPlugin` Sample code_**
```typescript
var TransferWebpackPlugin = require('transfer-webpack-plugin');
...
plugins: [
new TransferWebpackPlugin([
{ from: 'node_modules\ng2-pdfjs-viewer\pdfjs', to: path.join(__dirname, 'assets') }
])
]
```
OR
### Options
| Attribute | Description | Type | Default Value
| --- | --- | --- | --- |
| `[pdfJsFolder]` | Set path to _pdfjs's_ `web` and `build` folders. | `string` | `assets` folder path |
| `[externalWindow]` | Open in new tab. Set to `true` to open document in a new tab | `boolean` | `false` |
| `downloadFileName` | Sets/Changes the name of document to be downloaded. If the file name does not ends in `.pdf`, the component will automatically add it for you. | `string` | Actual name of the document |
| `[page]` | Show specific page. E.g _page=3_ | `number` | `1` |
| `[lastPage]` | Show last page of the document once it is loaded(If set to `true`). If you use this option along with _`page`_ option, undesired effects might occur | `boolean` | `false` |
| `nameddest` | Go to a named destination. E.g. To go to section _5.1_ use like nameddest=5.1. Do not mix this option with _`page`_ and _`lastPage`_ options | `string` | |
| `zoom` | Set zoom level of document. Applicable values are `auto`, `page-width`, `page-height`, `page-fit`, `200`_(As a zoom percentage)_, `left offset`_(As in "auto,18,827")_, `top offset`_(As in "auto,18,127")_ | `string` | `auto` |
| `[print]` | Show/hide print button. Set `false` to hide | `boolean` | `true` |
| `[startPrint]` | Start print preview of document. This combined with _`externalWindow`_ could mimic a print preview functionality just like the one in gmail. | `boolean` | |
| `[download]` | Show/hide download button. Set `false` to hide | boolean | `true` |
| `[startDownload]` | Download document as soon as it opens. You may put this to good use. | `boolean` | |
| `[rotatecw]` | Rotate document clock wise 90° | `boolean` | |
| `[rotateccw]` | Rotate document anti-clock wise 90° | `boolean` | |
| `cursor` | Type of cursor. Available options are _`HAND`/`H`_, _`SELECT`/`S`_,_`ZOOM`/`Z`_. Case is irrelevant. | _`SELECT`/`S`_ | |
| `scroll` | Sets scroll. Available options are _`VERTICAL`/`V`_, _`HORIZONTAL`/`H`_,_`WRAPPED`/`W`_. Case is irrelevant. | _`VERTICAL`/`V`_ | |
| `spread` | Sets Odd or Even spread. Available options are _`ODD`/`O`_, _`EVEN`/`E`_,_`NONE`/`N`_. Case is irrelevant. | _`NONE`/`N`_ | |
| `[fullScreen]` | Show/hide presentation(full screen) button. Set `false` to hide | `boolean` | `true` |
| `cursor` | Type of cursor. Available options are _`HAND`/`H`_, _`SELECT`/`S`_,_`ZOOM`/`Z`_. Case is irrelevant. | _`SELECT`/`S`_ | |
| `pagemode` | State of sidebar. Available options are _`none`_, _`thumbs`_,_`bookmarks`_,_`attachments`_. E.g. `pagemode=attachments`. | _`none`_ | |
| `[openFile]` | Show/hide open file button. Set `false` to hide | boolean | `true` |
| `[viewBookmark]` | Show/hide bookmark button. Set `false` to hide | boolean | `true` |
| `[showSpinner]` | Show a simple css based spinner/progress before the document loads | boolean | `true` |
2. Using pdf-js-gh-pages
- Download pdfjs-gh-pages from here: https://github.com/mozilla/pdf.js/archive/gh-pages.zip and extract it.
- Create a `pdfjs` folder under your angular2+ applications `assets` folder
- Copy `pdf.js-gh-pages/build` and `pdf.js-gh-pages/web` folders from extracted package to `pdfjs` folder.
- The web/ directory contains a 1 MB PDF file called "compressed.tracemonkey-pldi-09.pdf". This file is a sample and can safely be removed.
ps: More info can be found here: https://github.com/mozilla/pdf.js/wiki/setup-pdf.js-in-a-website
**_Please note, copy step is mandatory to enjoy all of the different options listed above. You may also avoid this step and could directly use https://github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website if you wish to just use the default viewer_**
## Usage
`For your convenience a sample app using angular6 is available under this repository, if you would like to see it in action (Folder ng6SampleApp). It shows many ways to configure this component for different needs.`
_For your convenience a sample app using angular6 is available under this repository, if you would like to see it in action (Folder ng6SampleApp). It shows many ways to configure this component for different needs._

@@ -146,3 +154,4 @@ Once your PdfJsViewerComponent is imported you can use it in your Angular application like this:

this.downloadFile(url).subscribe(
(res) => {
(res) => {
this.pdfViewer.pdfSrc = res; // pdfSrc can be Blob or Uint8Array

@@ -207,8 +216,10 @@ this.pdfViewer.refresh(); // Ask pdf viewer to load/reresh pdf

## Other projects worth mentioning
1. Angular 5+ [ng2-pdf-viewer](https://github.com/VadimDez/ng2-pdf-viewer)
2. AngularJS [angular-pdfjs-viewer](https://github.com/legalthings/angular-pdfjs-viewer)
## Questions?
There are several how to questions being posted in issues section of this repository. Questions would be better answered if posted on www.stackoverflow.com with tag **_ng2-pdfjs-viewer_** (Please create **_ng2-pdfjs-viewer_** tag if not already present on SO)
## Looking for old AngularJS? - The below library is quite useful
AngularJS [angular-pdfjs-viewer](https://github.com/legalthings/angular-pdfjs-viewer)
## License
MIT © [Code Hippie](mailto:codehippie1@gmail.com)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc