added getBytes method
This commit is contained in:
parent
3b4d7d3e78
commit
19f9897ec3
35
pdf.js
35
pdf.js
@ -65,6 +65,17 @@ var Stream = (function() {
|
|||||||
return -1;
|
return -1;
|
||||||
return bytes[this.pos++];
|
return bytes[this.pos++];
|
||||||
},
|
},
|
||||||
|
getBytes: function(length) {
|
||||||
|
var bytes = this.bytes;
|
||||||
|
var pos = this.pos;
|
||||||
|
var end = this.end;
|
||||||
|
if (pos + length > end)
|
||||||
|
length = end - pos;
|
||||||
|
|
||||||
|
var n = 0;
|
||||||
|
var buf = new Uint8Array(bytes, pos, length);
|
||||||
|
return buf;
|
||||||
|
},
|
||||||
lookChar: function() {
|
lookChar: function() {
|
||||||
var bytes = this.bytes;
|
var bytes = this.bytes;
|
||||||
if (this.pos >= this.end)
|
if (this.pos >= this.end)
|
||||||
@ -233,7 +244,7 @@ var FlateStream = (function() {
|
|||||||
this.eof = false;
|
this.eof = false;
|
||||||
this.codeSize = 0;
|
this.codeSize = 0;
|
||||||
this.codeBuf = 0;
|
this.codeBuf = 0;
|
||||||
this.pos = 0;
|
|
||||||
this.bufferPos = 0;
|
this.bufferPos = 0;
|
||||||
this.bufferLength = 0;
|
this.bufferLength = 0;
|
||||||
}
|
}
|
||||||
@ -290,6 +301,27 @@ var FlateStream = (function() {
|
|||||||
buffer2[i] = buffer[i];
|
buffer2[i] = buffer[i];
|
||||||
return this.buffer = buffer2;
|
return this.buffer = buffer2;
|
||||||
},
|
},
|
||||||
|
getByte: function() {
|
||||||
|
var bufferLength = this.bufferLength;
|
||||||
|
var bufferPos = this.bufferPos;
|
||||||
|
if (bufferLength == bufferPos) {
|
||||||
|
if (this.eof)
|
||||||
|
return;
|
||||||
|
this.readBlock();
|
||||||
|
}
|
||||||
|
return this.buffer[this.bufferPos++];
|
||||||
|
},
|
||||||
|
getBytes: function(length) {
|
||||||
|
var bufferPos = this.bufferPos;
|
||||||
|
|
||||||
|
while (!this.eof && this.bufferLength < bufferPos + length)
|
||||||
|
this.readBlock();
|
||||||
|
|
||||||
|
if (length > bufferLength - bufferPos)
|
||||||
|
length = bufferLength - bufferPos;
|
||||||
|
|
||||||
|
return new Uint8Array(this.buffer, bufferPos, length);
|
||||||
|
},
|
||||||
lookChar: function() {
|
lookChar: function() {
|
||||||
var bufferLength = this.bufferLength;
|
var bufferLength = this.bufferLength;
|
||||||
var bufferPos = this.bufferPos;
|
var bufferPos = this.bufferPos;
|
||||||
@ -304,7 +336,6 @@ var FlateStream = (function() {
|
|||||||
var ch = this.lookChar();
|
var ch = this.lookChar();
|
||||||
if (!ch)
|
if (!ch)
|
||||||
return;
|
return;
|
||||||
this.pos++;
|
|
||||||
this.bufferPos++;
|
this.bufferPos++;
|
||||||
return ch;
|
return ch;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user