|
|
|
@ -276,11 +276,11 @@ var FakeStream = (function() {
@@ -276,11 +276,11 @@ var FakeStream = (function() {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
constructor.prototype.getBytes = function(length) { |
|
|
|
|
var pos = this.pos; |
|
|
|
|
var end, pos = this.pos; |
|
|
|
|
|
|
|
|
|
if (length) { |
|
|
|
|
this.ensureBuffer(pos + length); |
|
|
|
|
var end = pos + length; |
|
|
|
|
end = pos + length; |
|
|
|
|
|
|
|
|
|
while (!this.eof && this.bufferLength < end) |
|
|
|
|
this.readBlock(); |
|
|
|
@ -290,7 +290,7 @@ var FakeStream = (function() {
@@ -290,7 +290,7 @@ var FakeStream = (function() {
|
|
|
|
|
end = bufEnd; |
|
|
|
|
} else { |
|
|
|
|
this.eof = true; |
|
|
|
|
var end = this.bufferLength; |
|
|
|
|
end = this.bufferLength; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.pos = end; |
|
|
|
@ -2056,7 +2056,7 @@ var CCITTFaxStream = (function() {
@@ -2056,7 +2056,7 @@ var CCITTFaxStream = (function() {
|
|
|
|
|
constructor.prototype.eatBits = function(n) { |
|
|
|
|
if ((this.inputBits -= n) < 0) |
|
|
|
|
this.inputBits = 0; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return constructor; |
|
|
|
|
})(); |
|
|
|
@ -2359,7 +2359,7 @@ var Lexer = (function() {
@@ -2359,7 +2359,7 @@ var Lexer = (function() {
|
|
|
|
|
|
|
|
|
|
constructor.isSpace = function(ch) { |
|
|
|
|
return ch == ' ' || ch == '\t'; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// A '1' in this array means the character is white space. A '1' or
|
|
|
|
|
// '2' means the character ends a name or command.
|
|
|
|
@ -2432,7 +2432,8 @@ var Lexer = (function() {
@@ -2432,7 +2432,8 @@ var Lexer = (function() {
|
|
|
|
|
var stream = this.stream; |
|
|
|
|
var ch; |
|
|
|
|
do { |
|
|
|
|
switch (ch = stream.getChar()) { |
|
|
|
|
ch = stream.getChar(); |
|
|
|
|
switch (ch) { |
|
|
|
|
case undefined: |
|
|
|
|
warn('Unterminated string'); |
|
|
|
|
done = true; |
|
|
|
@ -2449,7 +2450,8 @@ var Lexer = (function() {
@@ -2449,7 +2450,8 @@ var Lexer = (function() {
|
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case '\\': |
|
|
|
|
switch (ch = stream.getChar()) { |
|
|
|
|
ch = stream.getChar(); |
|
|
|
|
switch (ch) { |
|
|
|
|
case undefined: |
|
|
|
|
warn('Unterminated string'); |
|
|
|
|
done = true; |
|
|
|
@ -2802,7 +2804,7 @@ var Parser = (function() {
@@ -2802,7 +2804,7 @@ var Parser = (function() {
|
|
|
|
|
if (xref) |
|
|
|
|
length = xref.fetchIfRef(length); |
|
|
|
|
if (!IsInt(length)) { |
|
|
|
|
error('Bad ' + Length + ' attribute in stream'); |
|
|
|
|
error('Bad ' + length + ' attribute in stream'); |
|
|
|
|
length = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3160,7 +3162,7 @@ var XRef = (function() {
@@ -3160,7 +3162,7 @@ var XRef = (function() {
|
|
|
|
|
if (!IsCmd(obj3, 'obj')) { |
|
|
|
|
// some bad pdfs use "obj1234" and really mean 1234
|
|
|
|
|
if (obj3.cmd.indexOf('obj') == 0) { |
|
|
|
|
var num = parseInt(obj3.cmd.substring(3)); |
|
|
|
|
num = parseInt(obj3.cmd.substring(3)); |
|
|
|
|
if (!isNaN(num)) |
|
|
|
|
return num; |
|
|
|
|
} |
|
|
|
@ -3190,7 +3192,7 @@ var XRef = (function() {
@@ -3190,7 +3192,7 @@ var XRef = (function() {
|
|
|
|
|
var i, entries = [], nums = []; |
|
|
|
|
// read the object numbers to populate cache
|
|
|
|
|
for (i = 0; i < n; ++i) { |
|
|
|
|
var num = parser.getObj(); |
|
|
|
|
num = parser.getObj(); |
|
|
|
|
if (!IsInt(num)) { |
|
|
|
|
error('invalid object number in the ObjStm stream: ' + num); |
|
|
|
|
} |
|
|
|
@ -4175,7 +4177,7 @@ var PartialEvaluator = (function() {
@@ -4175,7 +4177,7 @@ var PartialEvaluator = (function() {
|
|
|
|
|
return function(gfx) { |
|
|
|
|
for (var i = 0, length = argsArray.length; i < length; i++) |
|
|
|
|
gfx[fnArray[i]].apply(gfx, argsArray[i]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
translateFont: function(fontDict, xref, resources) { |
|
|
|
@ -5221,7 +5223,7 @@ var CanvasGraphics = (function() {
@@ -5221,7 +5223,7 @@ var CanvasGraphics = (function() {
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
var Util = (function() { |
|
|
|
|
function constructor() {}; |
|
|
|
|
function constructor() {} |
|
|
|
|
constructor.makeCssRgb = function makergb(r, g, b) { |
|
|
|
|
var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0; |
|
|
|
|
return 'rgb(' + ri + ',' + gi + ',' + bi + ')'; |
|
|
|
@ -5244,7 +5246,7 @@ var ColorSpace = (function() {
@@ -5244,7 +5246,7 @@ var ColorSpace = (function() {
|
|
|
|
|
// Constructor should define this.numComps, this.defaultColor, this.name
|
|
|
|
|
function constructor() { |
|
|
|
|
error('should not call ColorSpace constructor'); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
// Input: array of size numComps representing color component values
|
|
|
|
@ -5279,18 +5281,14 @@ var ColorSpace = (function() {
@@ -5279,18 +5281,14 @@ var ColorSpace = (function() {
|
|
|
|
|
case 'DeviceGray': |
|
|
|
|
case 'G': |
|
|
|
|
return new DeviceGrayCS(); |
|
|
|
|
break; |
|
|
|
|
case 'DeviceRGB': |
|
|
|
|
case 'RGB': |
|
|
|
|
return new DeviceRgbCS(); |
|
|
|
|
break; |
|
|
|
|
case 'DeviceCMYK': |
|
|
|
|
case 'CMYK': |
|
|
|
|
return new DeviceCmykCS(); |
|
|
|
|
break; |
|
|
|
|
case 'Pattern': |
|
|
|
|
return new PatternCS(null); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
error('unrecognized colorspace ' + mode); |
|
|
|
|
} |
|
|
|
@ -5302,30 +5300,25 @@ var ColorSpace = (function() {
@@ -5302,30 +5300,25 @@ var ColorSpace = (function() {
|
|
|
|
|
case 'DeviceGray': |
|
|
|
|
case 'G': |
|
|
|
|
return new DeviceGrayCS(); |
|
|
|
|
break; |
|
|
|
|
case 'DeviceRGB': |
|
|
|
|
case 'RGB': |
|
|
|
|
return new DeviceRgbCS(); |
|
|
|
|
break; |
|
|
|
|
case 'DeviceCMYK': |
|
|
|
|
case 'CMYK': |
|
|
|
|
return new DeviceCmykCS(); |
|
|
|
|
break; |
|
|
|
|
case 'CalGray': |
|
|
|
|
return new DeviceGrayCS(); |
|
|
|
|
break; |
|
|
|
|
case 'CalRGB': |
|
|
|
|
return new DeviceRgbCS(); |
|
|
|
|
break; |
|
|
|
|
case 'ICCBased': |
|
|
|
|
var stream = xref.fetchIfRef(cs[1]); |
|
|
|
|
var dict = stream.dict; |
|
|
|
|
var numComps = dict.get('N'); |
|
|
|
|
if (numComps == 1) |
|
|
|
|
return new DeviceGrayCS(); |
|
|
|
|
else if (numComps == 3) |
|
|
|
|
if (numComps == 3) |
|
|
|
|
return new DeviceRgbCS(); |
|
|
|
|
else if (numComps == 4) |
|
|
|
|
if (numComps == 4) |
|
|
|
|
return new DeviceCmykCS(); |
|
|
|
|
break; |
|
|
|
|
case 'Pattern': |
|
|
|
@ -5333,19 +5326,16 @@ var ColorSpace = (function() {
@@ -5333,19 +5326,16 @@ var ColorSpace = (function() {
|
|
|
|
|
if (baseCS) |
|
|
|
|
baseCS = ColorSpace.parse(baseCS, xref, res); |
|
|
|
|
return new PatternCS(baseCS); |
|
|
|
|
break; |
|
|
|
|
case 'Indexed': |
|
|
|
|
var base = ColorSpace.parse(cs[1], xref, res); |
|
|
|
|
var hiVal = cs[2] + 1; |
|
|
|
|
var lookup = xref.fetchIfRef(cs[3]); |
|
|
|
|
return new IndexedCS(base, hiVal, lookup); |
|
|
|
|
break; |
|
|
|
|
case 'Separation': |
|
|
|
|
var name = cs[1]; |
|
|
|
|
var alt = ColorSpace.parse(cs[2], xref, res); |
|
|
|
|
var tintFn = new PDFFunction(xref, xref.fetchIfRef(cs[3])); |
|
|
|
|
return new SeparationCS(alt, tintFn); |
|
|
|
|
break; |
|
|
|
|
case 'Lab': |
|
|
|
|
case 'DeviceN': |
|
|
|
|
default: |
|
|
|
@ -5435,7 +5425,7 @@ var IndexedCS = (function() {
@@ -5435,7 +5425,7 @@ var IndexedCS = (function() {
|
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
getRgb: function indexcs_getRgb(color) { |
|
|
|
|
var numComps = base.numComps; |
|
|
|
|
var numComps = this.base.numComps; |
|
|
|
|
|
|
|
|
|
var start = color[0] * numComps; |
|
|
|
|
var c = []; |
|
|
|
@ -5471,7 +5461,7 @@ var DeviceGrayCS = (function() {
@@ -5471,7 +5461,7 @@ var DeviceGrayCS = (function() {
|
|
|
|
|
this.name = 'DeviceGray'; |
|
|
|
|
this.numComps = 1; |
|
|
|
|
this.defaultColor = [0]; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
getRgb: function graycs_getRgb(color) { |
|
|
|
@ -5606,7 +5596,7 @@ var Pattern = (function() {
@@ -5606,7 +5596,7 @@ var Pattern = (function() {
|
|
|
|
|
// Constructor should define this.getPattern
|
|
|
|
|
function constructor() { |
|
|
|
|
error('should not call Pattern constructor'); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
// Input: current Canvas context
|
|
|
|
@ -5670,14 +5660,14 @@ var Pattern = (function() {
@@ -5670,14 +5660,14 @@ var Pattern = (function() {
|
|
|
|
|
default: |
|
|
|
|
return new DummyShading(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
return constructor; |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
var DummyShading = (function() { |
|
|
|
|
function constructor() { |
|
|
|
|
this.type = 'Pattern'; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
constructor.prototype = { |
|
|
|
|
getPattern: function dummy_getpattern() { |
|
|
|
|
return 'hotpink'; |
|
|
|
@ -5707,13 +5697,15 @@ var RadialAxialShading = (function() {
@@ -5707,13 +5697,15 @@ var RadialAxialShading = (function() {
|
|
|
|
|
var t0 = 0.0, t1 = 1.0; |
|
|
|
|
if (dict.has('Domain')) { |
|
|
|
|
var domainArr = dict.get('Domain'); |
|
|
|
|
t0 = domainArr[0], t1 = domainArr[1]; |
|
|
|
|
t0 = domainArr[0]; |
|
|
|
|
t1 = domainArr[1]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var extendStart = false, extendEnd = false; |
|
|
|
|
if (dict.has('Extend')) { |
|
|
|
|
var extendArr = dict.get('Extend'); |
|
|
|
|
extendStart = extendArr[0], extendEnd = extendArr[1]; |
|
|
|
|
extendStart = extendArr[0]; |
|
|
|
|
extendEnd = extendArr[1]; |
|
|
|
|
TODO('Support extend'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5742,7 +5734,7 @@ var RadialAxialShading = (function() {
@@ -5742,7 +5734,7 @@ var RadialAxialShading = (function() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.colorStops = colorStops; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
getPattern: function() { |
|
|
|
@ -5807,7 +5799,7 @@ var TilingPattern = (function() {
@@ -5807,7 +5799,7 @@ var TilingPattern = (function() {
|
|
|
|
|
var e = m[4] * tm[0] + m[5] * tm[2] + tm[4]; |
|
|
|
|
var f = m[4] * tm[1] + m[5] * tm[3] + tm[5]; |
|
|
|
|
return [a, b, c, d, e, f]; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TODO('TilingType'); |
|
|
|
|
|
|
|
|
@ -5879,7 +5871,7 @@ var TilingPattern = (function() {
@@ -5879,7 +5871,7 @@ var TilingPattern = (function() {
|
|
|
|
|
graphics.execute(code, xref, res); |
|
|
|
|
|
|
|
|
|
this.canvas = tmpCanvas; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
getPattern: function tiling_getPattern() { |
|
|
|
@ -5958,7 +5950,7 @@ var PDFImage = (function() {
@@ -5958,7 +5950,7 @@ var PDFImage = (function() {
|
|
|
|
|
} else if (smask) { |
|
|
|
|
this.smask = new PDFImage(xref, res, smask); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
getComponents: function getComponents(buffer, decodeMap) { |
|
|
|
@ -6133,7 +6125,7 @@ var PDFFunction = (function() {
@@ -6133,7 +6125,7 @@ var PDFFunction = (function() {
|
|
|
|
|
error('Unknown type of function'); |
|
|
|
|
|
|
|
|
|
typeFn.call(this, fn, dict, xref); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
|
constructSampled: function(str, dict) { |
|
|
|
@ -6179,7 +6171,7 @@ var PDFFunction = (function() {
@@ -6179,7 +6171,7 @@ var PDFFunction = (function() {
|
|
|
|
|
else if (v < min) |
|
|
|
|
v = min; |
|
|
|
|
return v; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (inputSize != args.length) |
|
|
|
|
error('Incorrect number of arguments: ' + inputSize + ' != ' + |
|
|
|
@ -6229,7 +6221,7 @@ var PDFFunction = (function() {
@@ -6229,7 +6221,7 @@ var PDFFunction = (function() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return output; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
getSampleArray: function(size, outputSize, bps, str) { |
|
|
|
|
var length = 1; |
|
|
|
@ -6277,7 +6269,7 @@ var PDFFunction = (function() {
@@ -6277,7 +6269,7 @@ var PDFFunction = (function() {
|
|
|
|
|
out.push(c0[j] + (x^n * diff[i])); |
|
|
|
|
|
|
|
|
|
return out; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
constructStiched: function(fn, dict, xref) { |
|
|
|
|
var domain = dict.get('Domain'); |
|
|
|
@ -6305,7 +6297,7 @@ var PDFFunction = (function() {
@@ -6305,7 +6297,7 @@ var PDFFunction = (function() {
|
|
|
|
|
else if (v < min) |
|
|
|
|
v = min; |
|
|
|
|
return v; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// clip to domain
|
|
|
|
|
var v = clip(args[0], domain[0], domain[1]); |
|
|
|
@ -6330,11 +6322,13 @@ var PDFFunction = (function() {
@@ -6330,11 +6322,13 @@ var PDFFunction = (function() {
|
|
|
|
|
|
|
|
|
|
// call the appropropriate function
|
|
|
|
|
return fns[i].func([v2]); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
constructPostScript: function() { |
|
|
|
|
TODO('unhandled type of function'); |
|
|
|
|
this.func = function() { return [255, 105, 180]; } |
|
|
|
|
this.func = function() { |
|
|
|
|
return [255, 105, 180]; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|