|
|
|
@ -171,15 +171,22 @@ var DecodeStream = (function() {
@@ -171,15 +171,22 @@ var DecodeStream = (function() {
|
|
|
|
|
getBytes: function(length) { |
|
|
|
|
var pos = this.pos; |
|
|
|
|
|
|
|
|
|
if (length) { |
|
|
|
|
this.ensureBuffer(pos + length); |
|
|
|
|
while (!this.eof && this.bufferLength < pos + length) |
|
|
|
|
var end = pos + length; |
|
|
|
|
|
|
|
|
|
while (!this.eof && this.bufferLength < end) |
|
|
|
|
this.readBlock(); |
|
|
|
|
|
|
|
|
|
var end = pos + length; |
|
|
|
|
var bufEnd = this.bufferLength; |
|
|
|
|
|
|
|
|
|
if (end > bufEnd) |
|
|
|
|
end = bufEnd; |
|
|
|
|
} else { |
|
|
|
|
while (!this.eof) |
|
|
|
|
this.readBlock(); |
|
|
|
|
|
|
|
|
|
var end = this.bufferLength; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.pos = end; |
|
|
|
|
return this.buffer.subarray(pos, end) |
|
|
|
@ -763,79 +770,12 @@ var Ascii85Stream = (function() {
@@ -763,79 +770,12 @@ var Ascii85Stream = (function() {
|
|
|
|
|
function constructor(str) { |
|
|
|
|
this.str = str; |
|
|
|
|
this.dict = str.dict; |
|
|
|
|
this.eof = false; |
|
|
|
|
this.pos = 0; |
|
|
|
|
this.bufferLength = 0; |
|
|
|
|
this.buffer = null; |
|
|
|
|
} |
|
|
|
|
constructor.prototype = { |
|
|
|
|
ensureBuffer: function(requested) { |
|
|
|
|
var buffer = this.buffer; |
|
|
|
|
var current = buffer ? buffer.byteLength : 0; |
|
|
|
|
if (requested < current) |
|
|
|
|
return buffer; |
|
|
|
|
var size = 512; |
|
|
|
|
while (size < requested) |
|
|
|
|
size <<= 1; |
|
|
|
|
var buffer2 = Uint8Array(size); |
|
|
|
|
for (var i = 0; i < current; ++i) |
|
|
|
|
buffer2[i] = buffer[i]; |
|
|
|
|
return this.buffer = buffer2; |
|
|
|
|
}, |
|
|
|
|
getByte: function() { |
|
|
|
|
var pos = this.pos; |
|
|
|
|
while (this.bufferLength <= pos) { |
|
|
|
|
if (this.eof) |
|
|
|
|
return; |
|
|
|
|
this.readBlock(); |
|
|
|
|
} |
|
|
|
|
return this.buffer[this.pos++]; |
|
|
|
|
}, |
|
|
|
|
getBytes: function(length) { |
|
|
|
|
var pos = this.pos; |
|
|
|
|
|
|
|
|
|
this.ensureBuffer(pos + length); |
|
|
|
|
if (length) { |
|
|
|
|
while (!this.eof && this.bufferLength < pos + length) |
|
|
|
|
this.readBlock(); |
|
|
|
|
|
|
|
|
|
var end = pos + length; |
|
|
|
|
var bufEnd = this.bufferLength; |
|
|
|
|
|
|
|
|
|
if (end > bufEnd) |
|
|
|
|
end = bufEnd; |
|
|
|
|
} else { |
|
|
|
|
while(!this.eof) |
|
|
|
|
this.readBlock(); |
|
|
|
|
var end = this.bufferLength; |
|
|
|
|
} |
|
|
|
|
this.pos = end; |
|
|
|
|
return this.buffer.subarray(pos, end) |
|
|
|
|
}, |
|
|
|
|
lookChar: function() { |
|
|
|
|
var pos = this.pos; |
|
|
|
|
while (this.bufferLength <= pos) { |
|
|
|
|
if (this.eof) |
|
|
|
|
return; |
|
|
|
|
this.readBlock(); |
|
|
|
|
} |
|
|
|
|
return String.fromCharCode(this.buffer[this.pos]); |
|
|
|
|
}, |
|
|
|
|
getChar: function() { |
|
|
|
|
var pos = this.pos; |
|
|
|
|
while (this.bufferLength <= pos) { |
|
|
|
|
if (this.eof) |
|
|
|
|
return; |
|
|
|
|
this.readBlock(); |
|
|
|
|
DecodeStream.call(this); |
|
|
|
|
} |
|
|
|
|
return String.fromCharCode(this.buffer[this.pos++]); |
|
|
|
|
}, |
|
|
|
|
skip: function(n) { |
|
|
|
|
if (!n) |
|
|
|
|
n = 1; |
|
|
|
|
this.pos += n; |
|
|
|
|
}, |
|
|
|
|
readBlock: function() { |
|
|
|
|
|
|
|
|
|
constructor.prototype = Object.create(DecodeStream.prototype); |
|
|
|
|
constructor.prototype.readBlock = function() { |
|
|
|
|
const tildaCode = "~".charCodeAt(0); |
|
|
|
|
const zCode = "z".charCodeAt(0); |
|
|
|
|
var str = this.str; |
|
|
|
@ -843,6 +783,7 @@ var Ascii85Stream = (function() {
@@ -843,6 +783,7 @@ var Ascii85Stream = (function() {
|
|
|
|
|
var c = str.getByte(); |
|
|
|
|
while (Lexer.isSpace(String.fromCharCode(c))) |
|
|
|
|
c = str.getByte(); |
|
|
|
|
|
|
|
|
|
if (!c || c === tildaCode) { |
|
|
|
|
this.eof = true; |
|
|
|
|
return; |
|
|
|
@ -854,10 +795,8 @@ var Ascii85Stream = (function() {
@@ -854,10 +795,8 @@ var Ascii85Stream = (function() {
|
|
|
|
|
if (c == zCode) { |
|
|
|
|
this.ensureBuffer(bufferLength + 4); |
|
|
|
|
var buffer = this.buffer; |
|
|
|
|
buffer[bufferLength++] = 0; |
|
|
|
|
buffer[bufferLength++] = 0; |
|
|
|
|
buffer[bufferLength++] = 0; |
|
|
|
|
buffer[bufferLength++] = 0; |
|
|
|
|
for (var i = 0; i < 4; ++i) |
|
|
|
|
buffer[bufferLength + i] = 0; |
|
|
|
|
this.bufferLength += 4; |
|
|
|
|
} else { |
|
|
|
|
var input = new Uint8Array(5); |
|
|
|
@ -875,9 +814,10 @@ var Ascii85Stream = (function() {
@@ -875,9 +814,10 @@ var Ascii85Stream = (function() {
|
|
|
|
|
this.ensureBuffer(bufferLength + i - 1); |
|
|
|
|
var buffer = this.buffer; |
|
|
|
|
this.bufferLength += i - 1; |
|
|
|
|
|
|
|
|
|
// partial ending;
|
|
|
|
|
if (i < 5) { |
|
|
|
|
for (++i; i < 5; ++i) |
|
|
|
|
for (; i < 5; ++i) |
|
|
|
|
input[i] = 0x21 + 84; |
|
|
|
|
this.eof = true; |
|
|
|
|
} |
|
|
|
@ -890,7 +830,6 @@ var Ascii85Stream = (function() {
@@ -890,7 +830,6 @@ var Ascii85Stream = (function() {
|
|
|
|
|
t >>= 8; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return constructor; |
|
|
|
@ -2402,6 +2341,7 @@ var CanvasGraphics = (function() {
@@ -2402,6 +2341,7 @@ var CanvasGraphics = (function() {
|
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
translateFont: function(fontDict, xref, resources) { |
|
|
|
|
return; |
|
|
|
|
var descriptor = xref.fetch(fontDict.get("FontDescriptor")); |
|
|
|
|
|
|
|
|
|
var fontName = descriptor.get("FontName"); |
|
|
|
|