};
function createOS2Table(properties, override) {
- var override = override || {};
+ override = override || {
+ unitsPerEm: 0,
+ yMax: 0,
+ yMin: 0,
+ ascent: 0,
+ descent: 0
+ };
var ulUnicodeRange1 = 0;
var ulUnicodeRange2 = 0;
'OS/2': stringToArray(createOS2Table(properties)),
// Character to glyphs mapping
- 'cmap': createCMapTable(charstrings.slice(), font.glyphIds),
+ 'cmap': createCMapTable(charstrings.slice(),
+ ('glyphIds' in font) ? font.glyphIds: null),
// Font header
'head': (function fontFieldsHead() {
if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255))
unicode += kCmapGlyphOffset;
- var width = isNum(mapping.width) ? mapping.width : defaultWidth;
+ var width = ('width' in mapping) && isNum(mapping.width) ? mapping.width
+ : defaultWidth;
properties.encoding[code] = {
unicode: unicode,
width: width
stroke: function canvasGraphicsStroke() {
var ctx = this.ctx;
var strokeColor = this.current.strokeColor;
- if (strokeColor && strokeColor.type === 'Pattern') {
+ if (strokeColor && strokeColor.hasOwnProperty('type') &&
+ 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.hasOwnProperty('type') &&
+ 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.hasOwnProperty('type') &&
+ fillColor.type === 'Pattern') {
ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill();
}
var strokeColor = this.current.strokeColor;
- if (strokeColor && strokeColor.type === 'Pattern') {
+ if (strokeColor && strokeColor.hasOwnProperty('type') &&
+ strokeColor.type === 'Pattern') {
ctx.save();
ctx.strokeStyle = strokeColor.getPattern(ctx);
ctx.stroke();
// IE9 text/html data URI
(function checkDocumentDocumentModeCompatibility() {
- if (document.documentMode !== 9)
+ if (!('documentMode' in document) || document.documentMode !== 9)
return;
// overriding the src property
var originalSrcDescriptor = Object.getOwnPropertyDescriptor(
while (sidebar.hasChildNodes())
sidebar.removeChild(sidebar.lastChild);
- clearInterval(sidebar._loadingInterval);
+
+ if ('_loadingInterval' in sidebar)
+ clearInterval(sidebar._loadingInterval);
var container = document.getElementById('viewer');
while (container.hasChildNodes())
params[unescape(param[0])] = unescape(param[1]);
}
- PDFView.open(params.file || kDefaultURL, parseFloat(params.scale));
+ var scale = ('scale' in params) ? params.scale : kDefaultScale;
+ PDFView.open(params.file || kDefaultURL, parseFloat(scale));
if (!window.File || !window.FileReader || !window.FileList || !window.Blob)
document.getElementById('fileInput').style.display = 'none';