1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Refactoring Settings manager, now with limit on memory usage

This commit is contained in:
Saebekassebil 2011-12-26 15:07:24 +01:00
parent 4c064eb94a
commit e147485262
2 changed files with 67 additions and 48 deletions

View file

@ -527,8 +527,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
this.startXRef,
this.mainXRefEntriesOffset);
this.catalog = new Catalog(this.xref);
if(this.xref.trailer && this.xref.trailer.has('ID')) {
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);
@ -543,14 +542,15 @@ var PDFDocModel = (function PDFDocModelClosure() {
return shadow(this, 'numPages', num);
},
getFingerprint: function pdfDocGetFingerprint() {
if(this.fileID) {
if (this.fileID) {
return this.fileID;
} else {
// If we got no fileID, then we generate one, from the first 100 bytes of PDF
// 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++) {
for (var i = 0, length = hash.length; i < length; i++) {
strHash += Number(hash[i]).toString(16);
}