mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #990 from notmasteryet/concurload
Fixes concurrent pages loading (#974 and #626)
This commit is contained in:
commit
9fd41e11da
3 changed files with 181 additions and 17 deletions
25
src/core.js
25
src/core.js
|
@ -527,6 +527,13 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
|||
this.startXRef,
|
||||
this.mainXRefEntriesOffset);
|
||||
this.catalog = new Catalog(this.xref);
|
||||
if (this.xref.trailer && this.xref.trailer.has('ID')) {
|
||||
var fileID = '';
|
||||
this.xref.trailer.get('ID')[0].split('').forEach(function(el) {
|
||||
fileID += Number(el.charCodeAt(0)).toString(16);
|
||||
});
|
||||
this.fileID = fileID;
|
||||
}
|
||||
},
|
||||
get numPages() {
|
||||
var linearization = this.linearization;
|
||||
|
@ -534,6 +541,22 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
|||
// shadow the prototype getter
|
||||
return shadow(this, 'numPages', num);
|
||||
},
|
||||
getFingerprint: function pdfDocGetFingerprint() {
|
||||
if (this.fileID) {
|
||||
return this.fileID;
|
||||
} else {
|
||||
// If we got no fileID, then we generate one,
|
||||
// from the first 100 bytes of PDF
|
||||
var data = this.stream.bytes.subarray(0, 100);
|
||||
var hash = calculateMD5(data, 0, data.length);
|
||||
var strHash = '';
|
||||
for (var i = 0, length = hash.length; i < length; i++) {
|
||||
strHash += Number(hash[i]).toString(16);
|
||||
}
|
||||
|
||||
return strHash;
|
||||
}
|
||||
},
|
||||
getPage: function pdfDocGetPage(n) {
|
||||
return this.catalog.getPage(n);
|
||||
}
|
||||
|
@ -560,7 +583,7 @@ var PDFDoc = (function PDFDocClosure() {
|
|||
this.data = data;
|
||||
this.stream = stream;
|
||||
this.pdf = new PDFDocModel(stream);
|
||||
|
||||
this.fingerprint = this.pdf.getFingerprint();
|
||||
this.catalog = this.pdf.catalog;
|
||||
this.objs = new PDFObjects();
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ var XRef = (function XRefClosure() {
|
|||
this.entries = [];
|
||||
this.xrefstms = {};
|
||||
var trailerDict = this.readXRef(startXRef);
|
||||
|
||||
this.trailer = trailerDict;
|
||||
// prepare the XRef cache
|
||||
this.cache = [];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue