Merge branch 'master' of https://github.com/andreasgal/pdf.js.git into zoom-bookmark
Conflicts: web/viewer.js
This commit is contained in:
commit
9eac2e1c95
25
fonts.js
25
fonts.js
@ -9,6 +9,10 @@ var isWorker = (typeof window == 'undefined');
|
||||
*/
|
||||
var kMaxWaitForFontFace = 1000;
|
||||
|
||||
// Unicode Private Use Area
|
||||
var kCmapGlyphOffset = 0xE000;
|
||||
|
||||
|
||||
/**
|
||||
* Hold a map of decoded fonts and of the standard fourteen Type1
|
||||
* fonts and their acronyms.
|
||||
@ -797,9 +801,6 @@ var Font = (function Font() {
|
||||
encoding: null,
|
||||
|
||||
checkAndRepair: function font_checkAndRepair(name, font, properties) {
|
||||
// offset glyphs to the Unicode Private Use Area
|
||||
var kCmapGlyphOffset = 0xE000;
|
||||
|
||||
function readTableEntry(file) {
|
||||
var tag = file.getBytes(4);
|
||||
tag = String.fromCharCode(tag[0]) +
|
||||
@ -879,16 +880,23 @@ var Font = (function Font() {
|
||||
var index = font.getByte();
|
||||
if (index) {
|
||||
deltas.push(index);
|
||||
glyphs.push({ unicode: j });
|
||||
|
||||
var code = encoding[index];
|
||||
for (var glyph in properties.glyphs) {
|
||||
if (properties.glyphs[glyph] == code)
|
||||
break;
|
||||
}
|
||||
|
||||
glyphs.push({ glyph: glyph, unicode: j });
|
||||
}
|
||||
}
|
||||
|
||||
if (properties.firstChar < 0x20) {
|
||||
var code = 0;
|
||||
for (var j = 0; j < glyphs.length; j++) {
|
||||
var glyph = glyphs[j];
|
||||
glyphs[j].unicode += 0x1F;
|
||||
properties.glyphs[glyph.glyph] = encoding[++code] = glyph.unicode;
|
||||
var code = glyph.unicode + kCmapGlyphOffset;
|
||||
properties.glyphs[glyph.glyph] = encoding[glyph.unicode] = code;
|
||||
glyph.unicode = code;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1458,7 +1466,7 @@ var Type1Parser = function() {
|
||||
charstring.push('drop');
|
||||
|
||||
// If the flex mechanism is not used in a font program, Adobe
|
||||
// state that that entries 0, 1 and 2 can simply be replace by
|
||||
// states that entries 0, 1 and 2 can simply be replaced by
|
||||
// {}, which means that we can simply ignore them.
|
||||
if (index < 3) {
|
||||
continue;
|
||||
@ -2235,7 +2243,6 @@ var Type2CFF = (function() {
|
||||
var nominalWidth = privDict['nominalWidthX'];
|
||||
|
||||
var charstrings = [];
|
||||
var kCmapGlyphOffset = 0xE000;
|
||||
var differences = properties.differences;
|
||||
var index = 0;
|
||||
for (var i = 1; i < charsets.length; i++) {
|
||||
|
85
pdf.js
85
pdf.js
@ -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() {
|
||||
end = bufEnd;
|
||||
} else {
|
||||
this.eof = true;
|
||||
var end = this.bufferLength;
|
||||
end = this.bufferLength;
|
||||
}
|
||||
|
||||
this.pos = end;
|
||||
@ -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() {
|
||||
|
||||
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() {
|
||||
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() {
|
||||
}
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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) {
|
||||
@ -4302,7 +4304,6 @@ var PartialEvaluator = (function() {
|
||||
var index = GlyphsUnicode[glyph] || i;
|
||||
glyphsMap[glyph] = encodingMap[i] = index;
|
||||
|
||||
var kCmapGlyphOffset = 0xE000;
|
||||
if (index <= 0x1f || (index >= 127 && index <= 255))
|
||||
glyphsMap[glyph] = encodingMap[i] += kCmapGlyphOffset;
|
||||
}
|
||||
@ -5221,7 +5222,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 +5245,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 +5280,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 +5299,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 +5325,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 +5424,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 +5460,7 @@ var DeviceGrayCS = (function() {
|
||||
this.name = 'DeviceGray';
|
||||
this.numComps = 1;
|
||||
this.defaultColor = [0];
|
||||
};
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
getRgb: function graycs_getRgb(color) {
|
||||
@ -5606,7 +5595,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 +5659,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 +5696,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 +5733,7 @@ var RadialAxialShading = (function() {
|
||||
}
|
||||
|
||||
this.colorStops = colorStops;
|
||||
};
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
getPattern: function() {
|
||||
@ -5807,7 +5798,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 +5870,7 @@ var TilingPattern = (function() {
|
||||
graphics.execute(code, xref, res);
|
||||
|
||||
this.canvas = tmpCanvas;
|
||||
};
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
getPattern: function tiling_getPattern() {
|
||||
@ -5958,7 +5949,7 @@ var PDFImage = (function() {
|
||||
} else if (smask) {
|
||||
this.smask = new PDFImage(xref, res, smask);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
getComponents: function getComponents(buffer, decodeMap) {
|
||||
@ -6133,7 +6124,7 @@ var PDFFunction = (function() {
|
||||
error('Unknown type of function');
|
||||
|
||||
typeFn.call(this, fn, dict, xref);
|
||||
};
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
constructSampled: function(str, dict) {
|
||||
@ -6179,7 +6170,7 @@ var PDFFunction = (function() {
|
||||
else if (v < min)
|
||||
v = min;
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
if (inputSize != args.length)
|
||||
error('Incorrect number of arguments: ' + inputSize + ' != ' +
|
||||
@ -6229,7 +6220,7 @@ var PDFFunction = (function() {
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
};
|
||||
},
|
||||
getSampleArray: function(size, outputSize, bps, str) {
|
||||
var length = 1;
|
||||
@ -6277,7 +6268,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 +6296,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 +6321,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];
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@ -34,12 +34,14 @@
|
||||
<div class="separator"></div>
|
||||
|
||||
<button id="next" title="Zoom Out" onclick="PDFView.zoomOut();">
|
||||
<img src="images/list-remove.svg" align="top" height="32"/>
|
||||
<img src="images/zoom-out.svg" align="top" height="32"/>
|
||||
</button>
|
||||
<button id="next" title="Zoom In" onclick="PDFView.zoomIn();">
|
||||
<img src="images/list-add.svg" align="top" height="32"/>
|
||||
<img src="images/zoom-in.svg" align="top" height="32"/>
|
||||
</button>
|
||||
|
||||
<div class="separator"></div>
|
||||
|
||||
<select id="scaleSelect" onchange="PDFView.parseScale(this.value);">
|
||||
<option id="customScaleOption" value="custom"></option>
|
||||
<option value="0.5">50%</option>
|
||||
|
@ -47,13 +47,14 @@ var PDFView = {
|
||||
},
|
||||
|
||||
parseScale: function(value, resetAutoSettings) {
|
||||
if ('custom' == value)
|
||||
return;
|
||||
|
||||
var scale = parseFloat(value);
|
||||
if (scale) {
|
||||
this.setScale(scale, true);
|
||||
return;
|
||||
}
|
||||
if ('custom' == value)
|
||||
return;
|
||||
|
||||
var currentPage = this.pages[this.page - 1];
|
||||
var pageWidthScale = (window.innerWidth - kScrollbarPadding) /
|
||||
@ -567,7 +568,7 @@ window.addEventListener('scalechange', function scalechange(evt) {
|
||||
var value = '' + evt.scale;
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
var option = options[i];
|
||||
if (option.value != evt.scale) {
|
||||
if (option.value != value) {
|
||||
option.selected = false;
|
||||
continue;
|
||||
}
|
||||
@ -591,16 +592,19 @@ window.addEventListener('pagechange', function pagechange(evt) {
|
||||
document.getElementById('next').disabled = (page == PDFView.pages.length);
|
||||
}, true);
|
||||
|
||||
window.addEventListener('keydown', function (evt) {
|
||||
window.addEventListener('keydown', function keydown(evt) {
|
||||
switch(evt.keyCode) {
|
||||
case 61: // '+' and '=' keys
|
||||
case 107:
|
||||
case 187:
|
||||
case 61: // FF/Mac '='
|
||||
case 107: // FF '+' and '='
|
||||
case 187: // Chrome '+'
|
||||
PDFView.zoomIn();
|
||||
break;
|
||||
case 109: // '-' keys
|
||||
case 189:
|
||||
case 109: // FF '-'
|
||||
case 189: // Chrome '-'
|
||||
PDFView.zoomOut();
|
||||
break;
|
||||
case 48: // '0'
|
||||
PDFView.setScale(kDefaultScale, true);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user