Skip to content

Commit

Permalink
Add console logging (if PDFJS.enableConsoleStats is true)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrant committed Mar 21, 2017
1 parent 4653eb9 commit 980cc1c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ PDFJS.getDocument = function getDocument(src,
source = src;
}

console.info("Loading PDF from " + src.url);

var params = {};
for (var key in source) {
if (key === 'url' && typeof window !== 'undefined') {
Expand Down Expand Up @@ -636,7 +638,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.pageInfo = pageInfo;
this.transport = transport;
this.stats = new StatTimer();
this.stats.enabled = !!globalScope.PDFJS.enableStats;
this.stats.enabled = !!globalScope.PDFJS.enableStats || !!globalScope.PDFJS.enableConsoleStats;
this.commonObjs = transport.commonObjs;
this.objs = new PDFObjects();
this.cleanupAfterRender = false;
Expand Down Expand Up @@ -785,6 +787,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
}
stats.timeEnd('Rendering');
stats.timeEnd('Overall');

if (stats.enabled) {
var consoleStats = stats.toString().trim().replace(/\n/g, ', ').replace(/\s+/g, ' ');
console.info('Page ' + this.pageNumber + ' complete: ' + consoleStats);
}
}

return renderTask;
Expand Down

0 comments on commit 980cc1c

Please sign in to comment.