Skip to content

Commit

Permalink
default options
Browse files Browse the repository at this point in the history
  • Loading branch information
pionnegru committed Feb 26, 2021
1 parent f9ea7be commit a9eadfe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/core/viewer/components/pdf-viewer.component.ts
Expand Up @@ -101,6 +101,10 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
}

private eventBus = new pdfjsViewer.EventBus();
private pdfjsDefaultOptions = {
disableAutoFetch: true,
disableStream: true
};

constructor(
private dialog: MatDialog,
Expand Down Expand Up @@ -141,6 +145,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
const reader = new FileReader();
reader.onload = async () => {
const pdfSource: PDFSource = {
...this.pdfjsDefaultOptions,
data: reader.result,
withCredentials: this.appConfigService.get<boolean>('auth.withCredentials', undefined)
};
Expand All @@ -152,6 +157,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
const urlFile = changes['urlFile'];
if (urlFile && urlFile.currentValue) {
const pdfSource: PDFSource = {
...this.pdfjsDefaultOptions,
url: urlFile.currentValue,
withCredentials: this.appConfigService.get<boolean>('auth.withCredentials', undefined)
};
Expand All @@ -166,11 +172,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
executePdf(pdfOptions: PDFSource) {
pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdf.worker.min.js';

this.loadingTask = pdfjsLib.getDocument({
...pdfOptions,
disableAutoFetch: true,
disableStream: true
});
this.loadingTask = pdfjsLib.getDocument(pdfOptions);

this.loadingTask.onPassword = (callback, reason) => {
this.onPdfPassword(callback, reason);
Expand Down

0 comments on commit a9eadfe

Please sign in to comment.