Skip to content

Commit

Permalink
#233 made pdfLinkService public
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimDez committed Jan 10, 2018
1 parent d300006 commit c49c5c3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/pdf-viewer/pdf-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ if (!isSSR()) {
export class PdfViewerComponent implements OnChanges, OnInit {
static CSS_UNITS: number = 96.0 / 72.0;

public pdfLinkService: any;

private _renderText: boolean = true;
private _stickToPage: boolean = false;
private _originalSize: boolean = true;
Expand All @@ -287,7 +289,6 @@ export class PdfViewerComponent implements OnChanges, OnInit {
private _fitToPage: boolean = false;
private _externalLinkTarget: string = 'blank';
private _pdfViewer: any;
private _pdfLinkService: any;
private lastLoaded: string | Uint8Array | PDFSource;
private resizeTimeout: NodeJS.Timer;

Expand Down Expand Up @@ -417,16 +418,16 @@ export class PdfViewerComponent implements OnChanges, OnInit {

PdfViewerComponent.setExternalLinkTarget(this._externalLinkTarget);

this._pdfLinkService = new (<any>PDFJS).PDFLinkService();
this.pdfLinkService = new (<any>PDFJS).PDFLinkService();

const pdfOptions: PDFViewerParams | any = {
container: this.element.nativeElement.querySelector('div'),
removePageBorders: true,
linkService: this._pdfLinkService
linkService: this.pdfLinkService
};

this._pdfViewer = new PDFJS.PDFViewer(pdfOptions);
this._pdfLinkService.setViewer(this._pdfViewer);
this.pdfLinkService.setViewer(this._pdfViewer);
}

public updateSize() {
Expand Down Expand Up @@ -513,8 +514,8 @@ export class PdfViewerComponent implements OnChanges, OnInit {
}
}

if (this._pdfLinkService) {
this._pdfLinkService.setDocument(this._pdf, null);
if (this.pdfLinkService) {
this.pdfLinkService.setDocument(this._pdf, null);
}

this.page = this._page;
Expand Down Expand Up @@ -575,8 +576,8 @@ export class PdfViewerComponent implements OnChanges, OnInit {
};

if (this._renderText) {
this._pdfLinkService = new (<any>PDFJS).PDFLinkService();
pdfOptions.linkService = this._pdfLinkService;
this.pdfLinkService = new (<any>PDFJS).PDFLinkService();
pdfOptions.linkService = this.pdfLinkService;
PdfViewerComponent.setExternalLinkTarget(this._externalLinkTarget);
pdfOptions.textLayerFactory = new (<any>PDFJS).DefaultTextLayerFactory();
pdfOptions.annotationLayerFactory = new (<any>PDFJS).DefaultAnnotationLayerFactory();
Expand All @@ -585,7 +586,7 @@ export class PdfViewerComponent implements OnChanges, OnInit {
let pdfPageView = new (<any>PDFJS).PDFPageView(pdfOptions);

if (this._renderText) {
this._pdfLinkService.setViewer(pdfPageView);
this.pdfLinkService.setViewer(pdfPageView);
}

if (this._rotation !== 0 || pdfPageView.rotation !== this._rotation) {
Expand Down

0 comments on commit c49c5c3

Please sign in to comment.