pdff-viewer
Version:
<h1 align="center">Simple PDF Viewer</h1>
655 lines (648 loc) • 39.1 kB
JavaScript
import { Component, ElementRef, EventEmitter, Input, Output, NgModule } from '@angular/core';
import { HttpClient, HttpClientModule } from '@angular/common/http';
var SimpleSearchState = {
FOUND: 0,
NOT_FOUND: 1,
WRAPPED: 2,
PENDING: 3,
};
SimpleSearchState[SimpleSearchState.FOUND] = "FOUND";
SimpleSearchState[SimpleSearchState.NOT_FOUND] = "NOT_FOUND";
SimpleSearchState[SimpleSearchState.WRAPPED] = "WRAPPED";
SimpleSearchState[SimpleSearchState.PENDING] = "PENDING";
var SimpleDocumentInfo = /** @class */ (function () {
function SimpleDocumentInfo(key, value) {
this.key = key;
this.value = value;
}
return SimpleDocumentInfo;
}());
var SimpleOutlineNode = /** @class */ (function () {
function SimpleOutlineNode(title, dest, items) {
this.title = title;
this.dest = dest;
this.items = items;
}
return SimpleOutlineNode;
}());
var SimpleProgressData = /** @class */ (function () {
function SimpleProgressData(loaded, total) {
this.loaded = loaded;
this.total = total;
}
return SimpleProgressData;
}());
var SimpleSearchOptions = /** @class */ (function () {
function SimpleSearchOptions(caseSensitive, highlightAll, phraseSearch) {
if (caseSensitive === void 0) { caseSensitive = false; }
if (highlightAll === void 0) { highlightAll = true; }
if (phraseSearch === void 0) { phraseSearch = true; }
this.caseSensitive = caseSensitive;
this.highlightAll = highlightAll;
this.phraseSearch = phraseSearch;
}
return SimpleSearchOptions;
}());
SimpleSearchOptions.DEFAULT_OPTIONS = new SimpleSearchOptions();
var SimplePDFBookmark = /** @class */ (function () {
function SimplePDFBookmark(page, zoom, rotation, x, y) {
if (page === void 0) { page = 1; }
if (zoom === void 0) { zoom = 1; }
if (rotation === void 0) { rotation = 0; }
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
this.page = page;
this.zoom = zoom;
this.rotation = rotation;
this.x = x;
this.y = y;
}
SimplePDFBookmark.prototype.toDestination = function () {
return { pageNumber: this.page, destArray: [null, { name: 'XYZ' }, this.x, this.y, this.zoom] };
};
SimplePDFBookmark.prototype.toQueryString = function () {
return "" + SimplePDFBookmark.PARAMETER_SEPARATOR +
(SimplePDFBookmark.PARAMETER_PAGE + "=" + this.page + SimplePDFBookmark.PARAMETER_SEPARATOR) +
(SimplePDFBookmark.PARAMETER_ZOOM + "=" + this.zoom + SimplePDFBookmark.PARAMETER_SEPARATOR) +
(SimplePDFBookmark.PARAMETER_ROTATION + "=" + this.rotation + SimplePDFBookmark.PARAMETER_SEPARATOR) +
(SimplePDFBookmark.PARAMETER_X + "=" + this.x + SimplePDFBookmark.PARAMETER_SEPARATOR) +
(SimplePDFBookmark.PARAMETER_Y + "=" + this.y);
};
SimplePDFBookmark.buildSimplePDFBookmark = function (src) {
if (src && typeof src === 'string' && src.trim().length > 0) {
var parts = src.split(SimplePDFBookmark.PARAMETER_SEPARATOR);
if (parts.length > 0) {
var bookmark_1 = new SimplePDFBookmark();
parts.forEach(function (part) {
var parameters = part.split("=");
var paramert_name = parameters[0];
if (parameters.length === 2 && bookmark_1.hasOwnProperty(paramert_name)) {
var paramert_value = 0;
if (paramert_name === SimplePDFBookmark.PARAMETER_ZOOM) {
paramert_value = parseFloat("" + parameters[1]);
}
else {
paramert_value = parseInt("" + parameters[1], 10);
}
paramert_value = Number.isNaN(paramert_value) ? 0 : paramert_value;
bookmark_1[paramert_name] = paramert_value;
}
});
return bookmark_1;
}
}
return SimplePDFBookmark.EMPTY_BOOKMARK;
};
return SimplePDFBookmark;
}());
SimplePDFBookmark.EMPTY_BOOKMARK = new SimplePDFBookmark(1, 0.75, 0, 0, 0);
SimplePDFBookmark.PARAMETER_SEPARATOR = '#';
SimplePDFBookmark.PARAMETER_PAGE = 'page';
SimplePDFBookmark.PARAMETER_ZOOM = 'zoom';
SimplePDFBookmark.PARAMETER_ROTATION = 'rotation';
SimplePDFBookmark.PARAMETER_X = 'x';
SimplePDFBookmark.PARAMETER_Y = 'y';
var ScalePriority = {
FULL: 0,
WIDTH: 1,
HEIGHT: 2,
};
ScalePriority[ScalePriority.FULL] = "FULL";
ScalePriority[ScalePriority.WIDTH] = "WIDTH";
ScalePriority[ScalePriority.HEIGHT] = "HEIGHT";
if (typeof window !== 'undefined') {
window['pdfjs-dist/build/pdf'] = require('pdfjs-dist/build/pdf');
require('pdfjs-dist/web/compatibility');
require('pdfjs-dist/web/pdf_viewer');
PDFJS.verbosity = ((PDFJS)).VERBOSITY_LEVELS.errors;
}
var SimplePdfViewerComponent = /** @class */ (function () {
function SimplePdfViewerComponent(element, http) {
this.element = element;
this.http = http;
this.removePageBorders = false;
this.disableTextLayer = false;
this.onLoadComplete = new EventEmitter();
this.onError = new EventEmitter();
this.onProgress = new EventEmitter();
this.onSearchStateChange = new EventEmitter();
this.startAt = SimplePDFBookmark.EMPTY_BOOKMARK;
this.loaded = false;
this.currentPage = 1;
this.numberOfPages = 1;
this.outline = [];
this.zoom = 1.0;
this.rotation = 0;
this.searching = false;
this.lastSearchText = '';
this.searchPrevious = false;
this.searchOptions = SimpleSearchOptions.DEFAULT_OPTIONS;
}
SimplePdfViewerComponent.prototype.ngOnInit = function () {
if (typeof window !== 'undefined') {
if (typeof PDFJS.workerSrc !== 'string') {
var workerUrl = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/" + (((PDFJS))).version + "/pdf.worker.min.js";
PDFJS.workerSrc = workerUrl;
}
this.initPDFJS();
this.openDocument(this.src);
}
};
SimplePdfViewerComponent.prototype.ngOnDestroy = function () {
if (this.pdf) {
this.pdf.destroy();
}
};
SimplePdfViewerComponent.prototype.openDocument = function (src, startAt) {
if (startAt === void 0) { startAt = SimplePDFBookmark.EMPTY_BOOKMARK; }
this.resetParameters();
this.startAt = startAt;
this.setAndParseSrc(src);
this.loadFile();
};
SimplePdfViewerComponent.prototype.openFile = function (file, startAt) {
var _this = this;
if (startAt === void 0) { startAt = SimplePDFBookmark.EMPTY_BOOKMARK; }
try {
var fileReader_1 = new FileReader();
fileReader_1.onload = function () {
_this.openDocument(new Uint8Array(fileReader_1.result), startAt);
};
fileReader_1.onerror = function (error) {
_this.onError.emit(error);
_this.loaded = false;
};
fileReader_1.readAsArrayBuffer(file);
}
catch (error) {
this.onError.emit(error);
this.loaded = false;
}
};
SimplePdfViewerComponent.prototype.openUrl = function (url, startAt) {
var _this = this;
if (startAt === void 0) { startAt = SimplePDFBookmark.EMPTY_BOOKMARK; }
this.http.get(url, { responseType: 'arraybuffer' })
.subscribe(function (file) {
_this.openDocument(new Uint8Array(file), startAt);
}, function (error) {
_this.onError.emit(error);
_this.loaded = false;
});
};
SimplePdfViewerComponent.prototype.isDocumentLoaded = function () {
return this.loaded;
};
SimplePdfViewerComponent.prototype.initPDFJS = function () {
var container = this.getContainer();
((PDFJS)).disableTextLayer = this.disableTextLayer;
this.pdfLinkService = new ((PDFJS)).PDFLinkService();
this.pdfViewer = new ((PDFJS)).PDFSinglePageViewer({
container: container,
removePageBorders: this.removePageBorders,
linkService: this.pdfLinkService,
});
this.pdfLinkService.setViewer(this.pdfViewer);
this.pdfFindController = new ((PDFJS)).PDFFindController({
pdfViewer: this.pdfViewer
});
this.pdfViewer.setFindController(this.pdfFindController);
container.addEventListener('pagesinit', this.pagesinitEventListener.bind(this));
container.addEventListener('pagechange', this.pagechangeEventListener.bind(this));
container.addEventListener('updateviewarea', this.updateviewareaEventListener.bind(this));
};
SimplePdfViewerComponent.prototype.pagesinitEventListener = function () {
this.pdfViewer.currentScaleValue = SimplePdfViewerComponent.PDF_VIEWER_DEFAULT_SCALE;
this.navigateToBookmark(this.startAt);
this.onLoadComplete.emit();
};
SimplePdfViewerComponent.prototype.pagechangeEventListener = function () {
this.currentPage = this.pdfViewer._currentPageNumber;
};
SimplePdfViewerComponent.prototype.updateviewareaEventListener = function () {
this.zoom = this.pdfViewer._currentScale;
};
SimplePdfViewerComponent.prototype.setAndParseSrc = function (src) {
this.src = src;
if (this.src && typeof this.src === 'string') {
var parts = this.src.split(SimplePDFBookmark.PARAMETER_SEPARATOR);
if (parts.length > 1) {
this.startAt = SimplePDFBookmark.buildSimplePDFBookmark(this.src);
this.src = parts[0];
}
}
};
SimplePdfViewerComponent.prototype.loadFile = function () {
var _this = this;
this.loaded = false;
if (this.src) {
if (this.pdf) {
this.pdf.destroy();
}
var progressSrc = void 0;
if (typeof this.src === 'string') {
progressSrc = PDFJS.getDocument(({ url: this.src, withCredentials: true }));
}
else {
progressSrc = PDFJS.getDocument((this.src));
}
progressSrc.onProgress = function (progressData) {
_this.onProgress.emit(new SimpleProgressData(progressData.loaded, progressData.total));
};
((progressSrc.promise)).then(function (pdfDocument) {
_this.pdfViewer.setDocument(pdfDocument);
_this.pdfViewer.currentScaleValue = SimplePdfViewerComponent.PDF_VIEWER_DEFAULT_SCALE;
_this.pdfLinkService.setDocument(pdfDocument, null);
_this.pdf = pdfDocument;
_this.pdf.getOutline().then(function (nodes) {
_this.outline = _this.mapOutline(nodes);
});
_this.pdf.getMetadata().then(function (information) {
Object.getOwnPropertyNames(information.info).forEach(function (key) {
_this.information.push(new SimpleDocumentInfo(key, information.info[key]));
});
});
_this.numberOfPages = _this.pdf.numPages;
_this.loaded = true;
}, function (error) {
_this.resetParameters();
_this.onError.emit(error);
});
}
};
SimplePdfViewerComponent.prototype.resetParameters = function () {
this.information = [];
this.outline = null;
this.currentPage = 1;
this.zoom = 1;
this.numberOfPages = 1;
this.startAt = SimplePDFBookmark.EMPTY_BOOKMARK;
if (this.pdfFindController) {
this.pdfFindController.reset();
}
};
SimplePdfViewerComponent.prototype.mapOutline = function (nodes) {
var _this = this;
return nodes ? nodes.map(function (node) { return new SimpleOutlineNode(node.title, node.dest, _this.mapOutline(node.items)); }, this) : [];
};
SimplePdfViewerComponent.prototype.getContainer = function () {
return (this.element.nativeElement.querySelector('div'));
};
SimplePdfViewerComponent.prototype.getDocumentInformation = function () {
return this.loaded && !!this.information ? this.information : [];
};
SimplePdfViewerComponent.prototype.getZoom = function () {
return this.zoom;
};
SimplePdfViewerComponent.prototype.getZoomPercent = function () {
return Math.floor(this.getZoom() * 1000) / 10;
};
SimplePdfViewerComponent.prototype.zoomIn = function () {
if (this.isDocumentLoaded()) {
this.setZoom(this.zoom + SimplePdfViewerComponent.ZOOM_UNIT);
}
};
SimplePdfViewerComponent.prototype.zoomOut = function () {
if (this.isDocumentLoaded()) {
this.setZoom(this.zoom - SimplePdfViewerComponent.ZOOM_UNIT);
}
};
SimplePdfViewerComponent.prototype.zoomReset = function () {
if (this.isDocumentLoaded()) {
this.setZoom(1.0);
}
};
SimplePdfViewerComponent.prototype.zoomFullPage = function () {
var _this = this;
if (this.isDocumentLoaded()) {
this.pdf.getPage(this.currentPage).then(function (page) {
var scale = _this.getScale(page, ScalePriority.FULL);
_this.setZoom(scale);
});
}
};
SimplePdfViewerComponent.prototype.zoomPageWidth = function () {
var _this = this;
if (this.isDocumentLoaded()) {
this.pdf.getPage(this.currentPage).then(function (page) {
var scale = _this.getScale(page, ScalePriority.WIDTH);
_this.setZoom(scale);
});
}
};
SimplePdfViewerComponent.prototype.zoomPageHeight = function () {
var _this = this;
if (this.isDocumentLoaded()) {
this.pdf.getPage(this.currentPage).then(function (page) {
var scale = _this.getScale(page, ScalePriority.HEIGHT);
_this.setZoom(scale);
});
}
};
SimplePdfViewerComponent.prototype.getScale = function (page, priority) {
if (priority === void 0) { priority = ScalePriority.FULL; }
var viewport = page.getViewport(1, this.rotation);
var offsetHeight = this.getContainer().offsetHeight;
var offsetWidth = this.getContainer().offsetWidth;
if (offsetHeight === 0 || offsetWidth === 0) {
return 1;
}
var heightRatio = (offsetHeight - SimplePdfViewerComponent.PAGE_RESIZE_BORDER_HEIGHT) / viewport.height;
var widthRatio = (offsetWidth - SimplePdfViewerComponent.PAGE_RESIZE_BORDER_WIDTH) / viewport.width;
var ratio = heightRatio < widthRatio ? heightRatio : widthRatio;
if (priority !== ScalePriority.FULL) {
ratio = priority === ScalePriority.WIDTH ? widthRatio : heightRatio;
}
var zoom = 1;
return Math.floor(zoom * ratio / SimplePdfViewerComponent.CSS_UNITS * 100) / 100;
};
SimplePdfViewerComponent.prototype.setZoom = function (scale) {
if (this.isDocumentLoaded() && typeof scale === 'number') {
var normalizedScale = this.normalizeScale(scale);
this.pdfViewer._setScale(normalizedScale, false);
this.zoom = normalizedScale;
}
};
SimplePdfViewerComponent.prototype.setZoomInPercent = function (zoom) {
if (this.isDocumentLoaded() && typeof zoom === 'number') {
this.setZoom(zoom / 100);
}
};
SimplePdfViewerComponent.prototype.normalizeScale = function (scale) {
var normalizedScale = Math.round(scale * 1000) / 1000;
if (scale > SimplePdfViewerComponent.MAX_ZOOM) {
normalizedScale = SimplePdfViewerComponent.MAX_ZOOM;
}
else if (scale < SimplePdfViewerComponent.MIN_ZOOM) {
normalizedScale = SimplePdfViewerComponent.MIN_ZOOM;
}
return normalizedScale;
};
SimplePdfViewerComponent.prototype.search = function (text, searchOptions) {
if (searchOptions === void 0) { searchOptions = SimpleSearchOptions.DEFAULT_OPTIONS; }
if (this.isDocumentLoaded()) {
var searchText = text ? text.trim() : '';
this.lastSearchText = text;
this.searchPrevious = false;
this.searchOptions = searchOptions;
this.pdfFindController.onUpdateResultsCount = this.onUpdateResultsCount.bind(this);
this.pdfFindController.onUpdateState = this.onUpdateState.bind(this);
this.pdfFindController.executeCommand(SimplePdfViewerComponent.PDF_FINDER_FIND_COMMAND, {
caseSensitive: this.searchOptions.caseSensitive,
findPrevious: false,
highlightAll: this.searchOptions.highlightAll,
phraseSearch: this.searchOptions.phraseSearch,
query: searchText
});
}
};
SimplePdfViewerComponent.prototype.nextMatch = function () {
this.stepMatch(false);
};
SimplePdfViewerComponent.prototype.previousMatch = function () {
this.stepMatch(true);
};
SimplePdfViewerComponent.prototype.stepMatch = function (findPrevious) {
if (this.isDocumentLoaded() && this.getNumberOfMatches() > 1) {
if (this.searchPrevious !== findPrevious) {
this.searchPrevious = findPrevious;
this.searchAgain();
}
else {
this.pdfFindController.nextMatch();
this.currentPage = this.pdfViewer._currentPageNumber;
}
}
};
SimplePdfViewerComponent.prototype.searchAgain = function () {
if (this.isDocumentLoaded()) {
this.pdfFindController.executeCommand(SimplePdfViewerComponent.PDF_FINDER_AGAIN_COMMAND, {
caseSensitive: this.searchOptions.caseSensitive,
findPrevious: this.searchPrevious,
highlightAll: this.searchOptions.highlightAll,
phraseSearch: this.searchOptions.phraseSearch,
query: this.lastSearchText
});
}
};
SimplePdfViewerComponent.prototype.getNumberOfMatches = function () {
if (this.isDocumentLoaded()) {
return this.pdfFindController.matchCount;
}
return 0;
};
SimplePdfViewerComponent.prototype.hasMatches = function () {
return this.getNumberOfMatches() > 0;
};
SimplePdfViewerComponent.prototype.isSearching = function () {
return this.searching;
};
SimplePdfViewerComponent.prototype.onUpdateResultsCount = function () {
this.pdfFindController.onUpdateResultsCount = null;
this.currentPage = this.pdfViewer._currentPageNumber;
};
SimplePdfViewerComponent.prototype.onUpdateState = function (state) {
this.onSearchStateChange.emit(state);
this.searching = state === SimpleSearchState.PENDING;
if (!this.searching) {
this.pdfFindController.onUpdateState = null;
}
};
SimplePdfViewerComponent.prototype.getCurrentPage = function () {
return this.currentPage;
};
SimplePdfViewerComponent.prototype.getNumberOfPages = function () {
return this.numberOfPages;
};
SimplePdfViewerComponent.prototype.getOutline = function () {
return this.hasOutline() ? this.outline : [];
};
SimplePdfViewerComponent.prototype.hasOutline = function () {
return this.loaded && !!this.outline && !!this.outline.length;
};
SimplePdfViewerComponent.prototype.navigateToChapter = function (destination) {
if (this.isDocumentLoaded()) {
this.pdfLinkService.navigateTo(destination);
}
};
SimplePdfViewerComponent.prototype.firstPage = function () {
if (this.isDocumentLoaded()) {
this.currentPage = 1;
this.navigateToPage(this.currentPage);
}
};
SimplePdfViewerComponent.prototype.lastPage = function () {
if (this.isDocumentLoaded()) {
this.currentPage = this.getNumberOfPages();
this.navigateToPage(this.currentPage);
}
};
SimplePdfViewerComponent.prototype.nextPage = function () {
if (this.isDocumentLoaded()) {
this.currentPage++;
this.navigateToPage(this.currentPage, 1);
}
};
SimplePdfViewerComponent.prototype.prevPage = function () {
if (this.isDocumentLoaded()) {
this.currentPage--;
this.navigateToPage(this.currentPage, this.numberOfPages);
}
};
SimplePdfViewerComponent.prototype.navigateToPage = function (page, pageDefault) {
if (this.isDocumentLoaded()) {
var pageInt = parseInt("" + page, 10);
this.currentPage = pageInt ? pageInt : this.currentPage;
if (this.currentPage > this.numberOfPages) {
this.currentPage = pageDefault ? pageDefault : this.numberOfPages;
}
if (this.currentPage <= 0) {
this.currentPage = pageDefault ? pageDefault : 1;
}
}
};
SimplePdfViewerComponent.prototype.resetRotation = function () {
this.rotate(0);
};
SimplePdfViewerComponent.prototype.turnLeft = function () {
this.rotate(this.rotation - 90);
};
SimplePdfViewerComponent.prototype.turnRight = function () {
this.rotate(this.rotation + 90);
};
SimplePdfViewerComponent.prototype.getRotation = function () {
return this.rotation;
};
SimplePdfViewerComponent.prototype.rotate = function (angle) {
if (angle === void 0) { angle = 90; }
if (this.isDocumentLoaded()) {
this.rotation = parseInt("" + angle, 10);
if (this.rotation === 270) {
this.rotation = -90;
}
else if (this.rotation === -180) {
this.rotation = 180;
}
this.pdfViewer.pagesRotation = this.rotation;
}
};
SimplePdfViewerComponent.prototype.createBookmark = function () {
var _this = this;
if (!this.isDocumentLoaded()) {
return Promise.reject('Document is not loaded');
}
var pagePromise = ((this.pdf.getPage(this.currentPage)));
return pagePromise.then(function (page) {
var viewport = page.getViewport(1, _this.rotation);
var container = _this.getContainer();
var x = container.scrollLeft / container.scrollWidth * viewport.width;
var y = (container.scrollHeight - container.scrollTop) / container.scrollHeight * viewport.height;
if (_this.rotation === 90) {
y = container.scrollTop / container.scrollHeight * viewport.height;
var tmp = x;
x = y;
y = tmp;
}
else if (_this.rotation === 180) {
x = (container.scrollWidth - container.scrollLeft) / container.scrollWidth * viewport.width;
y = container.scrollTop / container.scrollHeight * viewport.height;
}
else if (_this.rotation === -90) {
x = (container.scrollWidth - container.scrollLeft) / container.scrollWidth * viewport.width;
var tmp = x;
x = y;
y = tmp;
}
x = Math.round(x);
y = Math.round(y);
return new SimplePDFBookmark(_this.currentPage, _this.zoom, _this.rotation, x, y);
});
};
SimplePdfViewerComponent.prototype.navigateToBookmark = function (bookmark) {
if (this.isDocumentLoaded() && !!bookmark) {
this.rotate(bookmark.rotation);
this.pdfViewer.scrollPageIntoView(bookmark.toDestination());
}
};
SimplePdfViewerComponent.prototype.getPageSnapshot = function (scale) {
var _this = this;
if (scale === void 0) { scale = 1; }
if (this.isDocumentLoaded()) {
var pagePromise = ((this.pdf.getPage(this.currentPage)));
return pagePromise.then(function (page) {
var viewport = page.getViewport(scale, 0);
var canvas = ((document.createElement('canvas')));
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
var task = ((page.render({ canvasContext: context, viewport: viewport })));
return task.then(function () { return _this.dataURItoFile(canvas.toDataURL(SimplePdfViewerComponent.SNAPSHOT_TPYE)); });
});
}
return Promise.reject('Document is not loaded');
};
SimplePdfViewerComponent.prototype.dataURItoFile = function (dataURI) {
var byteString;
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
byteString = atob(dataURI.split(',')[1]);
}
else {
byteString = unescape(dataURI.split(',')[1]);
}
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
var ia = new Uint8Array(byteString.length);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
var blob = new Blob([ia], { type: mimeString });
var b = blob;
b.lastModifiedDate = new Date();
b.name = 'screen.png';
return (blob);
};
return SimplePdfViewerComponent;
}());
SimplePdfViewerComponent.CSS_UNITS = 96.0 / 72.0;
SimplePdfViewerComponent.PAGE_RESIZE_BORDER_HEIGHT = 15;
SimplePdfViewerComponent.PAGE_RESIZE_BORDER_WIDTH = 15;
SimplePdfViewerComponent.ZOOM_UNIT = 0.1;
SimplePdfViewerComponent.MAX_ZOOM = 5;
SimplePdfViewerComponent.MIN_ZOOM = 0.05;
SimplePdfViewerComponent.PDF_FINDER_FIND_COMMAND = 'find';
SimplePdfViewerComponent.PDF_FINDER_AGAIN_COMMAND = 'findagain';
SimplePdfViewerComponent.PDF_VIEWER_DEFAULT_SCALE = 'page-fit';
SimplePdfViewerComponent.SNAPSHOT_TPYE = 'image/png';
SimplePdfViewerComponent.decorators = [
{ type: Component, args: [{
selector: 'simple-pdf-viewer',
template: "<div class=\"pdfViewerContainer\" [hidden]=\"!isDocumentLoaded()\"><div class=\"pdfViewer\"></div></div>",
styles: ["\n :host /deep/ .pdfViewerContainer {\n overflow: auto;\n position: relative;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n }\n \n :host /deep/ .textLayer {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n opacity: 0.2;\n line-height: 1.0;\n }\n \n :host /deep/ .textLayer > div {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n -webkit-transform-origin: 0% 0%;\n -moz-transform-origin: 0% 0%;\n -o-transform-origin: 0% 0%;\n -ms-transform-origin: 0% 0%;\n transform-origin: 0% 0%;\n }\n \n :host /deep/ .textLayer .highlight {\n margin: -1px;\n padding: 1px;\n \n background-color: #002bff;\n border-radius: 4px;\n }\n \n :host /deep/ .textLayer .highlight.begin {\n border-radius: 4px 0px 0px 4px;\n }\n \n :host /deep/ .textLayer .highlight.end {\n border-radius: 0px 4px 4px 0px;\n }\n \n :host /deep/ .textLayer .highlight.middle {\n border-radius: 0px;\n }\n \n :host /deep/ .textLayer .highlight.selected {\n background-color: rgb(0, 100, 0);\n }\n \n :host /deep/ .textLayer ::selection { background: #002bff; }\n :host /deep/ .textLayer ::-moz-selection { background: #002bff; }\n \n :host /deep/ .textLayer .endOfContent {\n display: block;\n position: absolute;\n left: 0px;\n top: 100%;\n right: 0px;\n bottom: 0px;\n z-index: -1;\n cursor: default;\n -webkit-user-select: none;\n -ms-user-select: none;\n -moz-user-select: none;\n }\n \n :host /deep/ .annotationLayer section {\n position: absolute;\n }\n \n :host /deep/ .textLayer .endOfContent.active {\n top: 0px;\n }\n \n :host /deep/ .annotationLayer .linkAnnotation > a {\n position: absolute;\n font-size: 1em;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n \n :host /deep/ .annotationLayer .linkAnnotation > a:hover {\n opacity: 0.2;\n background: #002bff;\n box-shadow: 0px 2px 10px #002bff;\n }\n \n :host /deep/ .annotationLayer .linkAnnotation > a /* -ms-a */ {\n background: url(\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\") 0 0 repeat;\n }\n \n :host /deep/ .annotationLayer .textAnnotation img {\n position: absolute;\n cursor: pointer;\n }\n \n :host /deep/ .annotationLayer .textWidgetAnnotation input,\n :host /deep/ .annotationLayer .textWidgetAnnotation textarea,\n :host /deep/ .annotationLayer .choiceWidgetAnnotation select,\n :host /deep/ .annotationLayer .buttonWidgetAnnotation.checkBox input,\n :host /deep/ .annotationLayer .buttonWidgetAnnotation.radioButton input {\n background-color: #002bff;\n border: 1px solid transparent;\n box-sizing: border-box;\n font-size: 9px;\n height: 100%;\n padding: 0 3px;\n vertical-align: top;\n width: 100%;\n }\n \n :host /deep/ .annotationLayer .textWidgetAnnotation textarea {\n font: message-box;\n font-size: 9px;\n resize: none;\n }\n \n :host /deep/ .annotationLayer .textWidgetAnnotation input[disabled],\n :host /deep/ .annotationLayer .textWidgetAnnotation textarea[disabled],\n :host /deep/ .annotationLayer .choiceWidgetAnnotation select[disabled],\n :host /deep/ .annotationLayer .buttonWidgetAnnotation.checkBox input[disabled],\n :host /deep/ .annotationLayer .buttonWidgetAnnotation.radioButton input[disabled] {\n background: none;\n border: 1px solid transparent;\n cursor: not-allowed;\n }\n \n :host /deep/ .annotationLayer .textWidgetAnnotation input:hover,\n :host /deep/ .annotationLayer .textWidgetAnnotation textarea:hover,\n :host /deep/ .annotationLayer .choiceWidgetAnnotation select:hover,\n :host /deep/ .annotationLayer .buttonWidgetAnnotation.checkBox input:hover,\n :host /deep/ .annotationLayer .buttonWidgetAnnotation.radioButton input:hover {\n border: 1px solid #000;\n }\n \n :host /deep/ .annotationLayer .textWidgetAnnotation input:focus,\n :host /deep/ .annotationLayer .textWidgetAnnotation textarea:focus,\n :host /deep/ .annotationLayer .choiceWidgetAnnotation select:focus {\n background: none;\n border: 1px solid transparent;\n }\n \n :host /deep/ .annotationLayer .textWidgetAnnotation input.comb {\n font-family: monospace;\n padding-left: 2px;\n padding-right: 0;\n }\n \n :host /deep/ .annotationLayer .textWidgetAnnotation input.comb:focus {\n width: 115%;\n }\n \n :host /deep/ .annotationLayer .buttonWidgetAnnotation.checkBox input,\n :host /deep/ .annotationLayer .buttonWidgetAnnotation.radioButton input {\n -webkit-appearance: none;\n -moz-appearance: none;\n -ms-appearance: none;\n appearance: none;\n }\n \n :host /deep/ .annotationLayer .popupWrapper {\n position: absolute;\n width: 20em;\n }\n \n :host /deep/ .annotationLayer .popup {\n position: absolute;\n z-index: 200;\n max-width: 20em;\n background-color: #FFFF99;\n box-shadow: 0px 2px 5px #333;\n border-radius: 2px;\n padding: 0.6em;\n margin-left: 5px;\n cursor: pointer;\n word-wrap: break-word;\n }\n \n :host /deep/ .annotationLayer .popup h1 {\n font-size: 1em;\n border-bottom: 1px solid #000000;\n padding-bottom: 0.2em;\n }\n \n :host /deep/ .annotationLayer .popup p {\n padding-top: 0.2em;\n }\n \n :host /deep/ .annotationLayer .highlightAnnotation,\n :host /deep/ .annotationLayer .underlineAnnotation,\n :host /deep/ .annotationLayer .squigglyAnnotation,\n :host /deep/ .annotationLayer .strikeoutAnnotation,\n :host /deep/ .annotationLayer .fileAttachmentAnnotation {\n cursor: pointer;\n }\n \n :host /deep/ .pdfViewer .canvasWrapper {\n overflow: hidden;\n }\n \n :host /deep/ .pdfViewer .page {\n direction: ltr;\n width: 816px;\n height: 1056px;\n margin: 1px auto -8px auto;\n position: relative;\n overflow: visible;\n border: 9px solid transparent;\n background-clip: content-box;\n border-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAA6UlEQVR4Xl2Pi2rEMAwE16fm1f7/r14v7w4rI0IzLAF7hLxNevBSEMEF5+OilNCsRd8ZMyn+a4NmsOT8WJw1lFbSYgGFzF2bLFoLjTClWjKKGRWpDYAGXUnZ4uhbBUzF3Oe/GG/ue2fn4GgsyXhNgysV2JnrhKEMg4fEZcALmiKbNhBBRFpSyDOj1G4QOVly6O1FV54ZZq8OVygrciDt6JazRgi1ljTPH0gbrPmHPXAbCiDd4GawIjip1TPh9tt2sz24qaCjr/jAb/GBFTbq9KZ7Ke/Cqt8nayUikZKsWZK7Fe6bg5dOUt8fZHWG2BHc+6EAAAAASUVORK5CYII=') 9 9 repeat;\n background-color: white;\n }\n \n :host /deep/ .pdfViewer.removePageBorders .page {\n margin: 0px auto 10px auto;\n border: none;\n }\n \n :host /deep/ .pdfViewer.singlePageView {\n display: inline-block;\n }\n \n :host /deep/ .pdfViewer.singlePageView .page {\n margin: 0;\n border: none;\n }\n \n :host /deep/ .pdfViewer .page canvas {\n margin: 0;\n display: block;\n }\n \n :host /deep/ .pdfViewer .page .loadingIcon {\n position: absolute;\n display: block;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n background: url('data:image/gif;base64,R0lGODlhGAAYAPQAAP///wAAAM7Ozvr6+uDg4LCwsOjo6I6OjsjIyJycnNjY2KioqMDAwPLy8nZ2doaGhri4uGhoaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJBwAAACwAAAAAGAAYAAAFriAgjiQAQWVaDgr5POSgkoTDjFE0NoQ8iw8HQZQTDQjDn4jhSABhAAOhoTqSDg7qSUQwxEaEwwFhXHhHgzOA1xshxAnfTzotGRaHglJqkJcaVEqCgyoCBQkJBQKDDXQGDYaIioyOgYSXA36XIgYMBWRzXZoKBQUMmil0lgalLSIClgBpO0g+s26nUWddXyoED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hACH5BAkHAAAALAAAAAAYABgAAAWtICCOJNA0ZZoOpGGQrDoOBCoSxNgQsQzgMZyIlvOJdi+AS2SoyXrK4umWHM5wNiV0UN3xdLiqr+mENcWpM9TIbrsBkEck8oC0DQqBQGGIz+t3eXtob0ZTPgNrIwQJDgtGAgwCWSIMDg4HiiUIDAxFAAoODwxDBWINCEGdSTQkCQcoegADBaQ6MggHjwAFBZUFCm0HB0kJCUy9bAYHCCPGIwqmRq0jySMGmj6yRiEAIfkECQcAAAAsAAAAABgAGAAABbIgII4k0DRlmg6kYZCsOg4EKhLE2BCxDOAxnIiW84l2L4BLZKipBopW8XRLDkeCiAMyMvQAA+uON4JEIo+vqukkKQ6RhLHplVGN+LyKcXA4Dgx5DWwGDXx+gIKENnqNdzIDaiMECwcFRgQCCowiCAcHCZIlCgICVgSfCEMMnA0CXaU2YSQFoQAKUQMMqjoyAglcAAyBAAIMRUYLCUkFlybDeAYJryLNk6xGNCTQXY0juHghACH5BAkHAAAALAAAAAAYABgAAAWzICCOJNA0ZVoOAmkY5KCSSgSNBDE2hDyLjohClBMNij8RJHIQvZwEVOpIekRQJyJs5AMoHA+GMbE1lnm9EcPhOHRnhpwUl3AsknHDm5RN+v8qCAkHBwkIfw1xBAYNgoSGiIqMgJQifZUjBhAJYj95ewIJCQV7KYpzBAkLLQADCHOtOpY5PgNlAAykAEUsQ1wzCgWdCIdeArczBQVbDJ0NAqyeBb64nQAGArBTt8R8mLuyPyEAOwAAAAAAAAAAAA==') center no-repeat;\n } \n "]
},] },
];
SimplePdfViewerComponent.ctorParameters = function () { return [
{ type: ElementRef, },
{ type: HttpClient, },
]; };
SimplePdfViewerComponent.propDecorators = {
"src": [{ type: Input },],
"removePageBorders": [{ type: Input },],
"disableTextLayer": [{ type: Input },],
"onLoadComplete": [{ type: Output, args: ['onLoadComplete',] },],
"onError": [{ type: Output, args: ['onError',] },],
"onProgress": [{ type: Output, args: ['onProgress',] },],
"onSearchStateChange": [{ type: Output, args: ['onSearchStateChange',] },],
};
var SimplePdfViewerModule = /** @class */ (function () {
function SimplePdfViewerModule() {
}
return SimplePdfViewerModule;
}());
SimplePdfViewerModule.decorators = [
{ type: NgModule, args: [{
imports: [HttpClientModule],
declarations: [SimplePdfViewerComponent],
exports: [SimplePdfViewerComponent]
},] },
];
export { SimplePdfViewerModule, SimplePdfViewerComponent, SimpleSearchState, SimpleDocumentInfo, SimpleOutlineNode, SimpleProgressData, SimpleSearchOptions, SimplePDFBookmark };
//# sourceMappingURL=pdff-viewer.js.map