And remove stray tabs.
* fonts and their acronyms.
*/
var stdFontMap = {
- "Arial": "Helvetica",
- "Arial_Bold": "Helvetica-Bold",
- "Arial_BoldItalic": "Helvetica-BoldOblique",
- "Arial_Italic": "Helvetica-Oblique",
- "Arial_BoldItalicMT": "Helvetica-BoldOblique",
- "Arial_BoldMT": "Helvetica-Bold",
- "Arial_ItalicMT": "Helvetica-Oblique",
- "ArialMT": "Helvetica",
- "Courier_Bold": "Courier-Bold",
- "Courier_BoldItalic": "Courier-BoldOblique",
- "Courier_Italic": "Courier-Oblique",
- "CourierNew": "Courier",
- "CourierNew_Bold": "Courier-Bold",
- "CourierNew_BoldItalic": "Courier-BoldOblique",
- "CourierNew_Italic": "Courier-Oblique",
- "CourierNewPS_BoldItalicMT": "Courier-BoldOblique",
- "CourierNewPS_BoldMT": "Courier-Bold",
- "CourierNewPS_ItalicMT": "Courier-Oblique",
- "CourierNewPSMT": "Courier",
- "Helvetica_Bold": "Helvetica-Bold",
- "Helvetica_BoldItalic": "Helvetica-BoldOblique",
- "Helvetica_Italic": "Helvetica-Oblique",
- "Symbol_Bold": "Symbol",
- "Symbol_BoldItalic": "Symbol",
- "Symbol_Italic": "Symbol",
- "TimesNewRoman": "Times-Roman",
- "TimesNewRoman_Bold": "Times-Bold",
- "TimesNewRoman_BoldItalic": "Times-BoldItalic",
- "TimesNewRoman_Italic": "Times-Italic",
- "TimesNewRomanPS": "Times-Roman",
- "TimesNewRomanPS_Bold": "Times-Bold",
- "TimesNewRomanPS_BoldItalic": "Times-BoldItalic",
- "TimesNewRomanPS_BoldItalicMT": "Times-BoldItalic",
- "TimesNewRomanPS_BoldMT": "Times-Bold",
- "TimesNewRomanPS_Italic": "Times-Italic",
- "TimesNewRomanPS_ItalicMT": "Times-Italic",
- "TimesNewRomanPSMT": "Times-Roman",
- "TimesNewRomanPSMT_Bold": "Times-Bold",
- "TimesNewRomanPSMT_BoldItalic": "Times-BoldItalic",
- "TimesNewRomanPSMT_Italic": "Times-Italic"
+ 'Arial': 'Helvetica',
+ 'Arial_Bold': 'Helvetica-Bold',
+ 'Arial_BoldItalic': 'Helvetica-BoldOblique',
+ 'Arial_Italic': 'Helvetica-Oblique',
+ 'Arial_BoldItalicMT': 'Helvetica-BoldOblique',
+ 'Arial_BoldMT': 'Helvetica-Bold',
+ 'Arial_ItalicMT': 'Helvetica-Oblique',
+ 'ArialMT': 'Helvetica',
+ 'Courier_Bold': 'Courier-Bold',
+ 'Courier_BoldItalic': 'Courier-BoldOblique',
+ 'Courier_Italic': 'Courier-Oblique',
+ 'CourierNew': 'Courier',
+ 'CourierNew_Bold': 'Courier-Bold',
+ 'CourierNew_BoldItalic': 'Courier-BoldOblique',
+ 'CourierNew_Italic': 'Courier-Oblique',
+ 'CourierNewPS_BoldItalicMT': 'Courier-BoldOblique',
+ 'CourierNewPS_BoldMT': 'Courier-Bold',
+ 'CourierNewPS_ItalicMT': 'Courier-Oblique',
+ 'CourierNewPSMT': 'Courier',
+ 'Helvetica_Bold': 'Helvetica-Bold',
+ 'Helvetica_BoldItalic': 'Helvetica-BoldOblique',
+ 'Helvetica_Italic': 'Helvetica-Oblique',
+ 'Symbol_Bold': 'Symbol',
+ 'Symbol_BoldItalic': 'Symbol',
+ 'Symbol_Italic': 'Symbol',
+ 'TimesNewRoman': 'Times-Roman',
+ 'TimesNewRoman_Bold': 'Times-Bold',
+ 'TimesNewRoman_BoldItalic': 'Times-BoldItalic',
+ 'TimesNewRoman_Italic': 'Times-Italic',
+ 'TimesNewRomanPS': 'Times-Roman',
+ 'TimesNewRomanPS_Bold': 'Times-Bold',
+ 'TimesNewRomanPS_BoldItalic': 'Times-BoldItalic',
+ 'TimesNewRomanPS_BoldItalicMT': 'Times-BoldItalic',
+ 'TimesNewRomanPS_BoldMT': 'Times-Bold',
+ 'TimesNewRomanPS_Italic': 'Times-Italic',
+ 'TimesNewRomanPS_ItalicMT': 'Times-Italic',
+ 'TimesNewRomanPSMT': 'Times-Roman',
+ 'TimesNewRomanPSMT_Bold': 'Times-Bold',
+ 'TimesNewRomanPSMT_BoldItalic': 'Times-BoldItalic',
+ 'TimesNewRomanPSMT_Italic': 'Times-Italic'
};
var FontMeasure = (function FontMeasure() {
if (!(measureCache = sizes[size]))
measureCache = sizes[size] = Object.create(null);
} else {
- measureCache = null
+ measureCache = null;
}
var name = font.loadedName;
- var bold = font.bold ? "bold" : "normal";
- var italic = font.italic ? "italic" : "normal";
+ var bold = font.bold ? 'bold' : 'normal';
+ var italic = font.italic ? 'italic' : 'normal';
size *= kScalePrecision;
- var rule = bold + " " + italic + " " + size + 'px "' + name + '"';
+ var rule = bold + ' ' + italic + ' ' + size + 'px "' + name + '"';
ctx.font = rule;
},
measureText: function fonts_measureText(text) {
if (!isWorker && rules.length) {
FontLoader.prepareFontLoadEvent(rules, names, objs);
}
-
+
if (!checkFontsLoaded()) {
document.documentElement.addEventListener(
'pdfjsFontLoad', checkFontsLoaded, false);
if (!file) {
var fontName = stdFontMap[name];
- this.bold = (fontName.indexOf("Bold") != -1);
- this.italic = (fontName.indexOf("Oblique") != -1);
- this.loadedName = fontName.split("-")[0];
+ this.bold = (fontName.indexOf('Bold') != -1);
+ this.italic = (fontName.indexOf('Oblique') != -1);
+ this.loadedName = fontName.split('-')[0];
this.loading = false;
return;
}
case 'Type1':
case 'CIDFontType0':
this.mimetype = 'font/opentype';
-
+
var subtype = properties.subtype;
if (subtype === 'Type1C') {
var cff = new Type2CFF(file, properties);
// checksum
var checksum = 0, n = data.length;
- for (var i = 0; i < n; i+=4)
- checksum = (checksum + int32([data[i], data[i+1], data[i+2], data[i+3]])) | 0;
+ for (var i = 0; i < n; i += 4)
+ checksum = (checksum + int32([data[i], data[i + 1], data[i + 2], data[i + 3]])) | 0;
var tableEntry = (tag + string32(checksum) +
string32(offset) + string32(length));
}
ranges.push([start, end]);
}
-
+
return ranges;
};
var range = ranges[i];
var start = range[0];
var end = range[1];
- var offset = (segCount - i) * 2 + bias * 2;
+ var offset = (segCount - i) * 2 + bias * 2;
bias += (end - start + 1);
startCount += string16(start);
'Unknown', // 8.Manufacturer
'Unknown' // 9.Designer
];
-
+
// Mac want 1-byte per character strings while Windows want
// 2-bytes per character, so duplicate the names table
var stringsUnicode = [];
for (var i = 0; i < strings.length; i++) {
var str = strings[i];
-
+
var strUnicode = '';
for (var j = 0; j < str.length; j++)
strUnicode += string16(str.charCodeAt(j));
stringsUnicode.push(strUnicode);
}
-
+
var names = [strings, stringsUnicode];
var platforms = ['\x00\x01', '\x00\x03'];
var encodings = ['\x00\x00', '\x00\x01'];
var languages = ['\x00\x00', '\x04\x09'];
-
+
var namesRecordCount = strings.length * platforms.length;
var nameTable =
'\x00\x00' + // format
string16(namesRecordCount) + // Number of names Record
string16(namesRecordCount * 12 + 6); // Storage
-
+
// Build the name records field
var strOffset = 0;
for (var i = 0; i < platforms.length; i++) {
strOffset += str.length;
}
}
-
+
nameTable += strings.join('') + stringsUnicode.join('');
return nameTable;
}
encodingID: int16(font.getBytes(2)),
offset: int32(font.getBytes(4))
});
- };
+ }
var encoding = properties.encoding;
var charset = properties.charset;
for (var i = 0; i < numRecords; i++) {
var table = records[i];
font.pos = start + table.offset;
-
+
var format = int16(font.getBytes(2));
var length = int16(font.getBytes(2));
var language = int16(font.getBytes(2));
// into the platform so if some characters in the font are assigned
// under this limit they will not be displayed so let's rewrite the
// CMap.
- var glyphs = [];
+ var glyphs = [];
var deltas = [];
for (var j = 0; j < 256; j++) {
var index = font.getByte();
if (index) {
deltas.push(index);
- glyphs.push({ unicode : j });
+ glyphs.push({ unicode: j });
}
}
var rewrite = false;
for (var code in encoding) {
- if (code < 0x20 && encoding[code])
+ if (code < 0x20 && encoding[code])
rewrite = true;
if (rewrite)
((hmtx.length - numOfHMetrics * 4) >> 1);
if (numMissing > 0) {
font.pos = (font.start ? font.start : 0) + hmtx.offset;
- var metrics = "";
+ var metrics = '';
for (var i = 0; i < hmtx.length; i++)
metrics += String.fromCharCode(font.getByte());
for (var i = 0; i < numMissing; i++)
- metrics += "\x00\x00";
+ metrics += '\x00\x00';
hmtx.data = stringToArray(metrics);
}
if (properties.type == 'CIDFontType2') {
// Type2 composite fonts map characters directly to glyphs so the cmap
// table must be replaced.
-
+
var glyphs = [];
var charset = properties.charset;
if (!charset.length) {
charsToUnicode: function fonts_chars2Unicode(chars) {
var charsCache = this.charsCache;
var str;
-
+
// if we translated this string before, just grab it from the cache
if (charsCache) {
str = charsCache[chars];
if (str)
return str;
}
-
+
// lazily create the translation cache
if (!charsCache)
charsCache = this.charsCache = Object.create(null);
-
+
if (this.compositeFont) {
// composite fonts have multi-byte strings
// convert the string from single-byte to multi-byte
// XXX assuming CIDFonts are two-byte - later need to extract the correct byte encoding
// according to the PDF spec
str = '';
- var multiByteStr = "";
+ var multiByteStr = '';
var length = chars.length;
for (var i = 0; i < length; i++) {
var byte1 = chars.charCodeAt(i++) & 0xFF;
var encoding = this.encoding;
if (!encoding)
return chars;
-
+
str = '';
for (var i = 0; i < chars.length; ++i) {
var charcode = chars.charCodeAt(i);
if ('undefined' == typeof(unicode)) {
// FIXME/issue 233: we're hitting this in test/pdf/sizes.pdf
// at the moment, for unknown reasons.
- warn('Unencoded charcode '+ charcode);
+ warn('Unencoded charcode ' + charcode);
unicode = charcode;
}
-
+
// Check if the glyph has already been converted
if (!IsNum(unicode))
unicode = encoding[unicode] = GlyphsUnicode[unicode.name];
-
+
// Handle surrogate pairs
if (unicode > 0xFFFF) {
str += String.fromCharCode(unicode & 0xFFFF);
BlueFuzz: '\x0c\x0b',
BlueScale: '\x0c\x09',
LanguageGroup: '\x0c\x11',
- ExpansionFactor: '\x0c\x18'
+ ExpansionFactor: '\x0c\x18'
};
for (var field in fieldMap) {
if (!properties.private.hasOwnProperty(field)) continue;
var bytes = file.getBytes();
this.bytes = bytes;
this.properties = properties;
-
+
// Other classes expect this.data to be a Javascript array
- var data = []
- for (var i = 0, ii = bytes.length; i < ii; ++i)
+ var data = [];
+ for (var i = 0, ii = bytes.length; i < ii; ++i)
data.push(bytes[i]);
this.data = data;
parse: function cff_parse() {
var header = this.parseHeader();
var nameIndex = this.parseIndex(header.endPos);
-
+
var dictIndex = this.parseIndex(nameIndex.endPos);
if (dictIndex.length != 1)
error('More than 1 font');
-
+
var stringIndex = this.parseIndex(dictIndex.endPos);
var gsubrIndex = this.parseIndex(stringIndex.endPos);
var privOffset = privInfo[1], privLength = privInfo[0];
var privBytes = bytes.subarray(privOffset, privOffset + privLength);
baseDict = this.parseDict(privBytes);
- var privDict = this.getPrivDict(baseDict, strings);
+ var privDict = this.getPrivDict(baseDict, strings);
TODO('Parse encoding');
var charStrings = this.parseIndex(topDict['CharStrings']);
// containing mappings for {unicode, width})
var charstrings = this.getCharStrings(charset, charStrings,
privDict, this.properties);
-
+
// create the mapping between charstring and glyph id
var glyphIds = [];
for (var i = 0, ii = charstrings.length; i < ii; ++i) {
var pair = baseDict[i];
var key = pair[0];
var value = pair[1];
- switch(key) {
+ switch (key) {
case 20:
dict['defaultWidthX'] = value[0];
case 21:
var pair = baseDict[i];
var key = pair[0];
var value = pair[1];
- switch(key) {
+ switch (key) {
case 1:
dict['Notice'] = strings[value[0]];
break;
},
getStrings: function cff_getstrings(stringIndex) {
function bytesToString(bytesArr) {
- var s = "";
+ var s = '';
for (var i = 0, ii = bytesArr.length; i < ii; ++i)
s += String.fromCharCode(bytesArr[i]);
return s;
var bytes = this.bytes;
var offset = 0;
- while(bytes[offset] != 1)
+ while (bytes[offset] != 1)
++offset;
if (offset != 0) {
- warning("cff data is shifted");
+ warning('cff data is shifted');
bytes = bytes.subarray(offset);
this.bytes = bytes;
}
return {
endPos: bytes[2],
offsetSize: bytes[3]
- }
+ };
},
parseDict: function cff_parseDict(dict) {
var pos = 0;
};
function parseFloatOperand() {
- var str = "";
+ var str = '';
var eof = 15;
var lookup = ['0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', '.', 'E', 'E-', null, '-'];
var operands = [];
var entries = [];
-
+
var pos = 0;
var end = dict.length;
while (pos < end) {
},
length: count,
endPos: end
- }
- },
+ };
+ }
};
return constructor;
var stackStr;
try {
throw new Error();
- } catch(e) {
+ } catch (e) {
stackStr = e.stack;
- };
+ }
return stackStr.split('\n').slice(1).join('\n');
}
function constructor(str) {
this.str = str;
this.dict = str.dict;
-
+
DecodeStream.call(this);
}
-
+
var hexvalueMap = {
9: -1, // \t
32: -1, // space
};
constructor.prototype = Object.create(DecodeStream.prototype);
-
+
constructor.prototype.readBlock = function() {
- var gtCode = '>'.charCodeAt(0), bytes = this.str.getBytes(), c, n,
+ var gtCode = '>'.charCodeAt(0), bytes = this.str.getBytes(), c, n,
decodeLength, buffer, bufferLength, i, length;
-
+
decodeLength = (bytes.length + 1) >> 1;
buffer = this.ensureBuffer(this.bufferLength + decodeLength);
bufferLength = this.bufferLength;
-
- for(i = 0, length = bytes.length; i < length; i++) {
+
+ for (i = 0, length = bytes.length; i < length; i++) {
c = hexvalueMap[bytes[i]];
- while (c == -1 && (i+1) < length) {
+ while (c == -1 && (i + 1) < length) {
c = hexvalueMap[bytes[++i]];
}
-
- if((i+1) < length && (bytes[i+1] !== gtCode)) {
+
+ if ((i + 1) < length && (bytes[i + 1] !== gtCode)) {
n = hexvalueMap[bytes[++i]];
- buffer[bufferLength++] = c*16+n;
+ buffer[bufferLength++] = c * 16 + n;
} else {
- if(bytes[i] !== gtCode) { // EOD marker at an odd number, behave as if a 0 followed the last digit.
- buffer[bufferLength++] = c*16;
+ if (bytes[i] !== gtCode) { // EOD marker at an odd number, behave as if a 0 followed the last digit.
+ buffer[bufferLength++] = c * 16;
}
}
}
-
+
this.bufferLength = bufferLength;
this.eof = true;
};
-
+
return constructor;
})();
create: Date.now(),
compile: 0.0,
fonts: 0.0,
- render: 0.0,
+ render: 0.0
};
this.xref = xref;
}
return shadow(this, 'height', height);
},
get rotate() {
- var rotate = this.inheritPageProp("Rotate") || 0;
+ var rotate = this.inheritPageProp('Rotate') || 0;
// Normalize rotation so it's a multiple of 90 and between 0 and 270
if (rotate % 90 != 0) {
rotate = 0;
stats.compile = stats.fonts = stats.render = 0;
var gfx = new CanvasGraphics(canvasCtx);
- var fonts = [ ];
+ var fonts = [];
this.compile(gfx, fonts);
stats.compile = Date.now();
stats.fonts = Date.now();
// Always defer call to display() to work around bug in
// Firefox error reporting from XHR callbacks.
- setTimeout(function () {
+ setTimeout(function() {
var exc = null;
try {
self.display(gfx);
var PartialEvaluator = (function() {
function constructor() {
this.state = new EvalState();
- this.stateStack = [ ];
+ this.stateStack = [];
}
var OP_MAP = {
eval: function(stream, xref, resources, fonts) {
resources = xref.fetchIfRef(resources) || new Dict();
var xobjs = xref.fetchIfRef(resources.get('XObject')) || new Dict();
- var patterns = xref.fetchIfRef(resources.get("Pattern")) || new Dict();
+ var patterns = xref.fetchIfRef(resources.get('Pattern')) || new Dict();
var parser = new Parser(new Lexer(stream), false);
var args = [], argsArray = [], fnArray = [], obj;
-
+
while (!IsEOF(obj = parser.getObj())) {
if (IsCmd(obj)) {
var cmd = obj.cmd;
var pattern = xref.fetchIfRef(patterns.get(patternName.name));
if (pattern) {
var dict = IsStream(pattern) ? pattern.dict : pattern;
- var typeNum = dict.get("PatternType");
+ var typeNum = dict.get('PatternType');
if (typeNum == 1) {
patternName.code = this.eval(pattern, xref,
dict.get('Resources'), fonts);
}
return function(gfx) {
- for(var i = 0, length = argsArray.length; i < length; i++)
+ for (var i = 0, length = argsArray.length; i < length; i++)
gfx[fnArray[i]].apply(gfx, argsArray[i]);
}
},
var subType = fontDict.get('Subtype');
var compositeFont = false;
assertWellFormed(IsName(subType), 'invalid font Subtype');
-
- // If font is a composite
+
+ // If font is a composite
// - get the descendant font
// - set the type according to the descendant font
// - get the FontDescriptor from the descendant font
} else {
fd = fontDict.get('FontDescriptor');
}
-
+
if (!fd)
return null;
-
+
var descriptor = xref.fetch(fd);
var fontName = xref.fetchIfRef(descriptor.get('FontName'));
var glyphsData = glyphsStream.getBytes(0);
var i = 0;
// Glyph ids are big-endian 2-byte values
- for (var j=0; j<glyphsData.length; j++) {
+ for (var j = 0; j < glyphsData.length; j++) {
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
charset.push(glyphID);
}
if (IsName(encoding)) {
// Encoding is a predefined CMap
if (encoding.name == 'Identity-H') {
- TODO ('Need to create an identity cmap')
+ TODO('Need to create an identity cmap');
} else {
- TODO ('Need to support predefined CMaps see PDF 32000-1:2008 9.7.5.2 Predefined CMaps')
+ TODO('Need to support predefined CMaps see PDF 32000-1:2008 9.7.5.2 Predefined CMaps');
}
} else {
- TODO ('Need to support encoding streams see PDF 32000-1:2008 9.7.5.3');
+ TODO('Need to support encoding streams see PDF 32000-1:2008 9.7.5.3');
}
}
} else if (fontDict.has('Encoding')) {
return {
name: fontName,
- fontDict: fontDict,
+ fontDict: fontDict,
file: fontFile,
properties: properties
};
- },
+ }
};
return constructor;
stroke: function() {
var ctx = this.ctx;
var strokeColor = this.current.strokeColor;
- if (strokeColor && strokeColor.type === "Pattern") {
+ if (strokeColor && strokeColor.type === 'Pattern') {
// for patterns, we transform to pattern space, calculate
// the pattern, call stroke, and restore to user space
ctx.save();
var ctx = this.ctx;
var fillColor = this.current.fillColor;
- if (fillColor && fillColor.type === "Pattern") {
+ if (fillColor && fillColor.type === 'Pattern') {
ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill();
var ctx = this.ctx;
var fillColor = this.current.fillColor;
- if (fillColor && fillColor.type === "Pattern") {
+ if (fillColor && fillColor.type === 'Pattern') {
ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill();
} else {
ctx.fill();
}
-
+
var strokeColor = this.current.strokeColor;
- if (strokeColor && strokeColor.type === "Pattern") {
+ if (strokeColor && strokeColor.type === 'Pattern') {
ctx.save();
ctx.strokeStyle = strokeColor.getPattern(ctx);
ctx.stroke();
} else {
ctx.stroke();
}
-
+
this.consumePath();
},
eoFillStroke: function() {
size = (size <= kRasterizerMin) ? size * kScalePrecision : size;
- var bold = fontObj.bold ? "bold" : "normal";
- var italic = fontObj.italic ? "italic" : "normal";
- var rule = bold + " " + italic + " " + size + 'px "' + name + '"';
+ var bold = fontObj.bold ? 'bold' : 'normal';
+ var italic = fontObj.italic ? 'italic' : 'normal';
+ var rule = bold + ' ' + italic + ' ' + size + 'px "' + name + '"';
this.ctx.font = rule;
}
},
ctx.save();
ctx.transform.apply(ctx, current.textMatrix);
ctx.scale(1, -1);
-
+
ctx.translate(current.x, -1 * current.y);
var scaleFactorX = 1, scaleFactorY = 1;
// Color
setStrokeColorSpace: function(space) {
- this.current.strokeColorSpace =
+ this.current.strokeColorSpace =
ColorSpace.parse(space, this.xref, this.res);
},
setFillColorSpace: function(space) {
- this.current.fillColorSpace =
+ this.current.fillColorSpace =
ColorSpace.parse(space, this.xref, this.res);
},
setStrokeColor: function(/*...*/) {
var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
-
+
this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
} else {
// HACK to draw the gradient onto an infinite rectangle.
// Canvas only allows gradients to be drawn in a rectangle
// The following bug should allow us to remove this.
// https://bugzilla.mozilla.org/show_bug.cgi?id=664884
-
+
this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
}
},
restoreFillRule: function(rule) {
this.ctx.mozFillRule = rule;
- },
+ }
};
return constructor;
var yt = p[0] * m[1] + p[1] * m[3] + m[5];
return [xt, yt];
};
-
+
return constructor;
})();
error("unimplemented color space object '" + mode + "'");
}
} else {
- error('unrecognized color space object: "'+ cs +"'");
+ error('unrecognized color space object: "' + cs + "'");
}
};
var SeparationCS = (function() {
function constructor(base, tintFn) {
- this.name = "Separation";
+ this.name = 'Separation';
this.numComps = 1;
this.defaultColor = [1];
r += 0.1373 * x;
g += 0.1216 * x;
b += 0.1255 * x;
- x = c1 * m1 * y * k1; // 0 0 1 0
+ x = c1 * m1 * y * k1; // 0 0 1 0
r += x;
g += 0.9490 * x;
- x = c1 * m1 * y * k; // 0 0 1 1
+ x = c1 * m1 * y * k; // 0 0 1 1
r += 0.1098 * x;
g += 0.1020 * x;
- x = c1 * m * y1 * k1; // 0 1 0 0
+ x = c1 * m * y1 * k1; // 0 1 0 0
r += 0.9255 * x;
b += 0.5490 * x;
- x = c1 * m * y1 * k; // 0 1 0 1
+ x = c1 * m * y1 * k; // 0 1 0 1
r += 0.1412 * x;
- x = c1 * m * y * k1; // 0 1 1 0
+ x = c1 * m * y * k1; // 0 1 1 0
r += 0.9294 * x;
g += 0.1098 * x;
b += 0.1412 * x;
- x = c1 * m * y * k; // 0 1 1 1
+ x = c1 * m * y * k; // 0 1 1 1
r += 0.1333 * x;
- x = c * m1 * y1 * k1; // 1 0 0 0
+ x = c * m1 * y1 * k1; // 1 0 0 0
g += 0.6784 * x;
b += 0.9373 * x;
- x = c * m1 * y1 * k; // 1 0 0 1
+ x = c * m1 * y1 * k; // 1 0 0 1
g += 0.0588 * x;
b += 0.1412 * x;
- x = c * m1 * y * k1; // 1 0 1 0
+ x = c * m1 * y * k1; // 1 0 1 0
g += 0.6510 * x;
b += 0.3137 * x;
- x = c * m1 * y * k; // 1 0 1 1
+ x = c * m1 * y * k; // 1 0 1 1
g += 0.0745 * x;
- x = c * m * y1 * k1; // 1 1 0 0
+ x = c * m * y1 * k1; // 1 1 0 0
r += 0.1804 * x;
g += 0.1922 * x;
b += 0.5725 * x;
- x = c * m * y1 * k; // 1 1 0 1
+ x = c * m * y1 * k; // 1 1 0 1
b += 0.0078 * x;
- x = c * m * y * k1; // 1 1 1 0
+ x = c * m * y * k1; // 1 1 1 0
r += 0.2118 * x;
g += 0.2119 * x;
b += 0.2235 * x;
for (var i = 0; i < length; i++) {
var cmyk = [];
for (var j = 0; j < 4; ++j)
- cmyk.push(colorBuf[colorBufPos++]/255);
+ cmyk.push(colorBuf[colorBufPos++] / 255);
var rgb = this.getRgb(cmyk);
for (var j = 0; j < 3; ++j)
// Output: the appropriate fillStyle or strokeStyle
getPattern: function pattern_getStyle(ctx) {
error('Should not call Pattern.getStyle');
- },
+ }
};
constructor.parse = function pattern_parse(args, cs, xref, res, ctx) {
var patternName = args[length - 1];
if (!IsName(patternName))
- error("Bad args to getPattern");
+ error('Bad args to getPattern');
- var patternRes = xref.fetchIfRef(res.get("Pattern"));
+ var patternRes = xref.fetchIfRef(res.get('Pattern'));
if (!patternRes)
- error("Unable to find pattern resource");
+ error('Unable to find pattern resource');
var pattern = xref.fetchIfRef(patternRes.get(patternName.name));
var dict = IsStream(pattern) ? pattern.dict : pattern;
- var typeNum = dict.get("PatternType");
+ var typeNum = dict.get('PatternType');
- switch(typeNum) {
+ switch (typeNum) {
case 1:
var base = cs.base;
var color;
} else if (type == 3) {
var p0 = [coordsArr[0], coordsArr[1]];
var p1 = [coordsArr[3], coordsArr[4]];
- var r0 = coordsArr[2], r1 = coordsArr[5]
+ var r0 = coordsArr[2], r1 = coordsArr[5];
} else {
- error()
+ error();
}
var matrix = this.matrix;
var TilingPattern = (function() {
var PAINT_TYPE_COLORED = 1, PAINT_TYPE_UNCOLORED = 2;
-
+
function constructor(pattern, code, dict, color, xref, ctx) {
function multiply(m, tm) {
var a = m[0] * tm[0] + m[1] * tm[2];
TODO('TilingType');
- this.matrix = dict.get("Matrix");
+ this.matrix = dict.get('Matrix');
this.curMatrix = ctx.mozCurrentTransform;
this.invMatrix = ctx.mozCurrentTransformInverse;
this.ctx = ctx;
var topLeft = [x0, y0];
// we want the canvas to be as large as the step size
- var botRight = [x0 + xstep, y0 + ystep]
+ var botRight = [x0 + xstep, y0 + ystep];
var width = botRight[0] - topLeft[0];
var height = botRight[1] - topLeft[1];
// TODO: hack to avoid OOM, we would idealy compute the tiling
// pattern to be only as large as the acual size in device space
- // This could be computed with .mozCurrentTransform, but still
+ // This could be computed with .mozCurrentTransform, but still
// needs to be implemented
while (Math.abs(width) > 512 || Math.abs(height) > 512) {
width = 512;
var c0 = dict.get('C0') || [0];
var c1 = dict.get('C1') || [1];
var n = dict.get('N');
-
+
if (!IsArray(c0) || !IsArray(c1))
error('Illegal dictionary for interpolated function');
for (var i = 0; i < length; ++i)
diff.push(c1[i] - c0[i]);
- this.func = function (args) {
+ this.func = function(args) {
var x = args[0];
var out = [];
},
constructStiched: function() {
TODO('unhandled type of function');
- this.func = function () { return [ 255, 105, 180 ]; }
+ this.func = function() { return [255, 105, 180]; }
},
constructPostScript: function() {
TODO('unhandled type of function');
- this.func = function () { return [ 255, 105, 180 ]; }
+ this.func = function() { return [255, 105, 180]; }
}
};
set page(val) {
var pages = this.pages;
- var input = document.getElementById("pageNumber");
+ var input = document.getElementById('pageNumber');
if (val <= 0 || val > pages.length) {
input.value = this.page;
return;
}
-
+
document.location.hash = val;
- document.getElementById("previous").disabled = (val == 1);
- document.getElementById("next").disabled = (val == pages.length);
+ document.getElementById('previous').disabled = (val == 1);
+ document.getElementById('next').disabled = (val == pages.length);
if (input.value == val)
return;
},
open: function(url, scale) {
- if (url.indexOf("http") == 0)
+ if (url.indexOf('http') == 0)
return;
document.title = url;
var page = pdf.getPage(i);
pages.push(new PageView(container, page, i, page.width, page.height, page.stats));
thumbnails.push(new ThumbnailView(sidebar, pages[i - 1]));
- };
+ }
this.scale = (scale || kDefaultScale);
this.page = parseInt(document.location.hash.substring(1)) || 1;
}
return visiblePages;
- },
+ }
};
var PageView = function(container, content, id, width, height, stats) {
this.update = function(scale) {
this.scale = scale || this.scale;
- div.style.width = (this.width * this.scale)+ 'px';
+ div.style.width = (this.width * this.scale) + 'px';
div.style.height = (this.height * this.scale) + 'px';
while (div.hasChildNodes())
this.updateStats = function() {
var t1 = stats.compile, t2 = stats.fonts, t3 = stats.render;
- var str = 'Time to compile/fonts/render: ' +
+ var str = 'Time to compile/fonts/render: ' +
(t1 - stats.begin) + '/' + (t2 - t1) + '/' + (t3 - t2) + ' ms';
document.getElementById('info').innerHTML = str;
};
PDFView.page = firstPage.id;
}, true);
-window.addEventListener("hashchange", function(evt) {
+window.addEventListener('hashchange', function(evt) {
PDFView.page = PDFView.page;
});
-window.addEventListener("change", function(evt) {
+window.addEventListener('change', function(evt) {
var files = evt.target.files;
if (!files || files.length == 0)
return;
document.location.hash = 1;
}, true);
-window.addEventListener("transitionend", function(evt) {
+window.addEventListener('transitionend', function(evt) {
var pageIndex = 0;
var pagesCount = PDFView.pages.length;
container._interval = window.setInterval(function() {
if (pageIndex >= pagesCount)
return window.clearInterval(container._interval);
-
+
PDFView.thumbnails[pageIndex++].draw();
}, 500);
}, true);