Browse Source

Merge pull request #198 from fancycode/pdfjs-1.0.1040

Update pdf.js to 1.0.1040
pull/200/head
Simon Eisenmann 10 years ago
parent
commit
e060c66710
  1. 229
      static/js/libs/pdf/pdf.js
  2. 805
      static/js/libs/pdf/pdf.worker.js

229
static/js/libs/pdf/pdf.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '1.0.907';
PDFJS.build = 'e9072ac';
PDFJS.version = '1.0.1040';
PDFJS.build = '997096f';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -601,10 +601,10 @@ var Util = PDFJS.Util = (function UtilClosure() { @@ -601,10 +601,10 @@ var Util = PDFJS.Util = (function UtilClosure() {
// makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
// creating many intermediate strings.
Util.makeCssRgb = function Util_makeCssRgb(rgb) {
rgbBuf[1] = rgb[0];
rgbBuf[3] = rgb[1];
rgbBuf[5] = rgb[2];
Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
rgbBuf[1] = r;
rgbBuf[3] = g;
rgbBuf[5] = b;
return rgbBuf.join('');
};
@ -3111,9 +3111,17 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() { @@ -3111,9 +3111,17 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
// Minimal font size that would be used during canvas fillText operations.
var MIN_FONT_SIZE = 16;
// Maximum font size that would be used during canvas fillText operations.
var MAX_FONT_SIZE = 100;
var MAX_GROUP_SIZE = 4096;
// Heuristic value used when enforcing minimum line widths.
var MIN_WIDTH_FACTOR = 0.65;
var COMPILE_TYPE3_GLYPHS = true;
var MAX_SIZE_TO_COMPILE = 1000;
var FULL_CHUNK_HEIGHT = 16;
function createScratchCanvas(width, height) {
var canvas = document.createElement('canvas');
@ -3247,7 +3255,7 @@ var CachedCanvases = (function CachedCanvasesClosure() { @@ -3247,7 +3255,7 @@ var CachedCanvases = (function CachedCanvasesClosure() {
getCanvas: function CachedCanvases_getCanvas(id, width, height,
trackTransform) {
var canvasEntry;
if (id in cache) {
if (cache[id] !== undefined) {
canvasEntry = cache[id];
canvasEntry.canvas.width = width;
canvasEntry.canvas.height = height;
@ -3461,6 +3469,7 @@ var CanvasExtraState = (function CanvasExtraStateClosure() { @@ -3461,6 +3469,7 @@ var CanvasExtraState = (function CanvasExtraStateClosure() {
// Default fore and background colors
this.fillColor = '#000000';
this.strokeColor = '#000000';
this.patternFill = false;
// Note: fill alpha applies to all non-stroking operations
this.fillAlpha = 1;
this.strokeAlpha = 1;
@ -3513,6 +3522,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3513,6 +3522,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (canvasCtx) {
addContextCurrentTransform(canvasCtx);
}
this.cachedGetSinglePixelWidth = null;
}
function putBinaryImageData(ctx, imgData) {
@ -3533,13 +3543,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3533,13 +3543,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// that's ok; any such pixels are ignored.
var height = imgData.height, width = imgData.width;
var fullChunkHeight = 16;
var fracChunks = height / fullChunkHeight;
var fullChunks = Math.floor(fracChunks);
var totalChunks = Math.ceil(fracChunks);
var partialChunkHeight = height - fullChunks * fullChunkHeight;
var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
var chunkImgData = ctx.createImageData(width, fullChunkHeight);
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
var srcPos = 0, destPos;
var src = imgData.data;
var dest = chunkImgData.data;
@ -3559,7 +3567,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3559,7 +3567,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
0xFF000000 : 0x000000FF;
for (i = 0; i < totalChunks; i++) {
thisChunkHeight =
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
(i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
destPos = 0;
for (j = 0; j < thisChunkHeight; j++) {
var srcDiff = srcLength - srcPos;
@ -3594,19 +3602,19 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3594,19 +3602,19 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
dest32[destPos++] = 0;
}
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
}
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
// RGBA, 32-bits per pixel.
j = 0;
elemsInThisChunk = width * fullChunkHeight * 4;
elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
for (i = 0; i < fullChunks; i++) {
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
srcPos += elemsInThisChunk;
ctx.putImageData(chunkImgData, 0, j);
j += fullChunkHeight;
j += FULL_CHUNK_HEIGHT;
}
if (i < totalChunks) {
elemsInThisChunk = width * partialChunkHeight * 4;
@ -3616,7 +3624,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3616,7 +3624,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} else if (imgData.kind === ImageKind.RGB_24BPP) {
// RGB, 24-bits per pixel.
thisChunkHeight = fullChunkHeight;
thisChunkHeight = FULL_CHUNK_HEIGHT;
elemsInThisChunk = width * thisChunkHeight;
for (i = 0; i < totalChunks; i++) {
if (i >= fullChunks) {
@ -3631,7 +3639,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3631,7 +3639,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
dest[destPos++] = src[srcPos++];
dest[destPos++] = 255;
}
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
}
} else {
error('bad image kind: ' + imgData.kind);
@ -3640,20 +3648,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3640,20 +3648,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
function putBinaryImageMask(ctx, imgData) {
var height = imgData.height, width = imgData.width;
var fullChunkHeight = 16;
var fracChunks = height / fullChunkHeight;
var fullChunks = Math.floor(fracChunks);
var totalChunks = Math.ceil(fracChunks);
var partialChunkHeight = height - fullChunks * fullChunkHeight;
var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
var chunkImgData = ctx.createImageData(width, fullChunkHeight);
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
var srcPos = 0;
var src = imgData.data;
var dest = chunkImgData.data;
for (var i = 0; i < totalChunks; i++) {
var thisChunkHeight =
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
(i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
// Expand the mask so it can be used by the canvas. Any required
// inversion has already been handled.
@ -3670,7 +3676,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3670,7 +3676,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
mask >>= 1;
}
}
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
}
}
@ -3680,14 +3686,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3680,14 +3686,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
'globalCompositeOperation', 'font'];
for (var i = 0, ii = properties.length; i < ii; i++) {
var property = properties[i];
if (property in sourceCtx) {
if (sourceCtx[property] !== undefined) {
destCtx[property] = sourceCtx[property];
}
}
if ('setLineDash' in sourceCtx) {
if (sourceCtx.setLineDash !== undefined) {
destCtx.setLineDash(sourceCtx.getLineDash());
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
} else if ('mozDash' in sourceCtx) {
} else if (sourceCtx.mozDashOffset !== undefined) {
destCtx.mozDash = sourceCtx.mozDash;
destCtx.mozDashOffset = sourceCtx.mozDashOffset;
}
@ -3722,9 +3728,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3722,9 +3728,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
function composeSMaskLuminosity(maskData, layerData) {
var length = maskData.length;
for (var i = 3; i < length; i += 4) {
var y = ((maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000
var y = (maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000
(maskData[i - 2] * 152) + // * 0.59 ....
(maskData[i - 1] * 28)) | 0; // * 0.11 ....
(maskData[i - 1] * 28); // * 0.11 ....
layerData[i] = (layerData[i] * y) >> 16;
}
}
@ -3744,7 +3750,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3744,7 +3750,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
// processing image in chunks to save memory
var PIXELS_TO_PROCESS = 65536;
var PIXELS_TO_PROCESS = 1048576;
var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
for (var row = 0; row < height; row += chunkSize) {
var chunkHeight = Math.min(chunkSize, height - row);
@ -3914,7 +3920,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -3914,7 +3920,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
var ctx = this.ctx;
if ('setLineDash' in ctx) {
if (ctx.setLineDash !== undefined) {
ctx.setLineDash(dashArray);
ctx.lineDashOffset = dashPhase;
} else {
@ -4049,10 +4055,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4049,10 +4055,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current = this.stateStack.pop();
this.ctx.restore();
this.cachedGetSinglePixelWidth = null;
}
},
transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
this.ctx.transform(a, b, c, d, e, f);
this.cachedGetSinglePixelWidth = null;
},
// Path
@ -4126,9 +4136,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4126,9 +4136,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx;
var strokeColor = this.current.strokeColor;
if (this.current.lineWidth === 0) {
ctx.lineWidth = this.getSinglePixelWidth();
}
// Prevent drawing too thin lines by enforcing a minimum line width.
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR,
this.current.lineWidth);
// For stroke we want to temporarily change the global alpha to the
// stroking alpha.
ctx.globalAlpha = this.current.strokeAlpha;
@ -4157,10 +4167,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4157,10 +4167,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx;
var fillColor = this.current.fillColor;
var isPatternFill = this.current.patternFill;
var needRestore = false;
if (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') {
if (isPatternFill) {
ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx, this);
needRestore = true;
@ -4311,9 +4321,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4311,9 +4321,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// Keeping the font at minimal size and using the fontSizeScale to change
// the current transformation matrix before the fillText/strokeText.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
var browserFontSize = size >= MIN_FONT_SIZE ? size : MIN_FONT_SIZE;
this.current.fontSizeScale = browserFontSize !== MIN_FONT_SIZE ? 1.0 :
size / MIN_FONT_SIZE;
var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE :
size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
this.current.fontSizeScale = size / browserFontSize;
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
this.ctx.font = rule;
@ -4453,7 +4463,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4453,7 +4463,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var lineWidth = current.lineWidth;
var scale = current.textMatrixScale;
if (scale === 0 || lineWidth === 0) {
lineWidth = this.getSinglePixelWidth();
var fillStrokeMode = current.textRenderingMode &
TextRenderingMode.FILL_STROKE_MASK;
if (fillStrokeMode === TextRenderingMode.STROKE ||
fillStrokeMode === TextRenderingMode.FILL_STROKE) {
this.cachedGetSinglePixelWidth = null;
lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
}
} else {
lineWidth /= scale;
}
@ -4548,9 +4564,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4548,9 +4564,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var textHScale = current.textHScale * fontDirection;
var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
var glyphsLength = glyphs.length;
var isTextInvisible =
current.textRenderingMode === TextRenderingMode.INVISIBLE;
var i, glyph, width;
if (fontSize === 0) {
if (isTextInvisible || fontSize === 0) {
return;
}
@ -4632,16 +4650,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4632,16 +4650,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},
setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) {
this.current.fillColor = this.getColorN_Pattern(arguments);
this.current.patternFill = true;
},
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments);
var color = Util.makeCssRgb(r, g, b);
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
},
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments);
var color = Util.makeCssRgb(r, g, b);
this.ctx.fillStyle = color;
this.current.fillColor = color;
this.current.patternFill = false;
},
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
@ -4900,11 +4920,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4900,11 +4920,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
var ctx = this.ctx;
var width = img.width, height = img.height;
var fillColor = this.current.fillColor;
var isPatternFill = this.current.patternFill;
var glyph = this.processingType3;
if (COMPILE_TYPE3_GLYPHS && glyph && !('compiled' in glyph)) {
var MAX_SIZE_TO_COMPILE = 1000;
if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
glyph.compiled =
compileType3Glyph({data: img.data, width: width, height: height});
@ -4926,9 +4947,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4926,9 +4947,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
maskCtx.globalCompositeOperation = 'source-in';
var fillColor = this.current.fillColor;
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') ?
maskCtx.fillStyle = isPatternFill ?
fillColor.getPattern(maskCtx, this) : fillColor;
maskCtx.fillRect(0, 0, width, height);
@ -4942,7 +4961,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4942,7 +4961,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
scaleY, positions) {
var width = imgData.width;
var height = imgData.height;
var ctx = this.ctx;
var fillColor = this.current.fillColor;
var isPatternFill = this.current.patternFill;
var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height);
var maskCtx = maskCanvas.context;
@ -4952,14 +4972,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4952,14 +4972,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
maskCtx.globalCompositeOperation = 'source-in';
var fillColor = this.current.fillColor;
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') ?
maskCtx.fillStyle = isPatternFill ?
fillColor.getPattern(maskCtx, this) : fillColor;
maskCtx.fillRect(0, 0, width, height);
maskCtx.restore();
var ctx = this.ctx;
for (var i = 0, ii = positions.length; i < ii; i += 2) {
ctx.save();
ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
@ -4974,6 +4993,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4974,6 +4993,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
function CanvasGraphics_paintImageMaskXObjectGroup(images) {
var ctx = this.ctx;
var fillColor = this.current.fillColor;
var isPatternFill = this.current.patternFill;
for (var i = 0, ii = images.length; i < ii; i++) {
var image = images[i];
var width = image.width, height = image.height;
@ -4986,9 +5007,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -4986,9 +5007,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
maskCtx.globalCompositeOperation = 'source-in';
var fillColor = this.current.fillColor;
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') ?
maskCtx.fillStyle = isPatternFill ?
fillColor.getPattern(maskCtx, this) : fillColor;
maskCtx.fillRect(0, 0, width, height);
@ -5191,11 +5210,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -5191,11 +5210,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
ctx.beginPath();
},
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
if (this.cachedGetSinglePixelWidth === null) {
var inverse = this.ctx.mozCurrentTransformInverse;
// max of the current horizontal and vertical scale
return Math.sqrt(Math.max(
this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(
(inverse[0] * inverse[0] + inverse[1] * inverse[1]),
(inverse[2] * inverse[2] + inverse[3] * inverse[3])));
}
return this.cachedGetSinglePixelWidth;
},
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
var transform = this.ctx.mozCurrentTransform;
@ -5263,7 +5285,7 @@ var WebGLUtils = (function WebGLUtilsClosure() { @@ -5263,7 +5285,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
}
var currentGL, currentCanvas;
function generageGL() {
function generateGL() {
if (currentGL) {
return;
}
@ -5321,7 +5343,7 @@ var WebGLUtils = (function WebGLUtilsClosure() { @@ -5321,7 +5343,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
function initSmaskGL() {
var canvas, gl;
generageGL();
generateGL();
canvas = currentCanvas;
currentCanvas = null;
gl = currentGL;
@ -5453,7 +5475,7 @@ var WebGLUtils = (function WebGLUtilsClosure() { @@ -5453,7 +5475,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
function initFiguresGL() {
var canvas, gl;
generageGL();
generateGL();
canvas = currentCanvas;
currentCanvas = null;
gl = currentGL;
@ -5621,7 +5643,7 @@ var WebGLUtils = (function WebGLUtilsClosure() { @@ -5621,7 +5643,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
}
var enabled = false;
try {
generageGL();
generateGL();
enabled = !!currentGL;
} catch (e) { }
return shadow(this, 'isEnabled', enabled);
@ -6014,7 +6036,7 @@ var TilingPattern = (function TilingPatternClosure() { @@ -6014,7 +6036,7 @@ var TilingPattern = (function TilingPatternClosure() {
context.strokeStyle = ctx.strokeStyle;
break;
case PaintType.UNCOLORED:
var cssColor = Util.makeCssRgb(color);
var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
context.fillStyle = cssColor;
context.strokeStyle = cssColor;
break;
@ -6373,7 +6395,6 @@ var FontFaceObject = (function FontFaceObjectClosure() { @@ -6373,7 +6395,6 @@ var FontFaceObject = (function FontFaceObjectClosure() {
})();
var HIGHLIGHT_OFFSET = 4; // px
var ANNOT_MIN_SIZE = 10; // px
var AnnotationUtils = (function AnnotationUtilsClosure() {
@ -6400,43 +6421,36 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { @@ -6400,43 +6421,36 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
style.fontFamily = fontFamily + fallbackName;
}
// TODO(mack): Remove this, it's not really that helpful.
function getEmptyContainer(tagName, rect, borderWidth) {
var bWidth = borderWidth || 0;
var element = document.createElement(tagName);
element.style.borderWidth = bWidth + 'px';
var width = rect[2] - rect[0] - 2 * bWidth;
var height = rect[3] - rect[1] - 2 * bWidth;
element.style.width = width + 'px';
element.style.height = height + 'px';
return element;
}
function initContainer(item) {
var container = getEmptyContainer('section', item.rect, item.borderWidth);
container.style.backgroundColor = item.color;
function initContainer(item, drawBorder) {
var container = document.createElement('section');
var cstyle = container.style;
var width = item.rect[2] - item.rect[0];
var height = item.rect[3] - item.rect[1];
var bWidth = item.borderWidth || 0;
if (bWidth) {
width = width - 2 * bWidth;
height = height - 2 * bWidth;
cstyle.borderWidth = bWidth + 'px';
var color = item.color;
var rgb = [];
for (var i = 0; i < 3; ++i) {
rgb[i] = Math.round(color[i] * 255);
if (drawBorder && color) {
cstyle.borderStyle = 'solid';
cstyle.borderColor = Util.makeCssRgb(Math.round(color[0] * 255),
Math.round(color[1] * 255),
Math.round(color[2] * 255));
}
item.colorCssRgb = Util.makeCssRgb(rgb);
var highlight = document.createElement('div');
highlight.className = 'annotationHighlight';
highlight.style.left = highlight.style.top = -HIGHLIGHT_OFFSET + 'px';
highlight.style.right = highlight.style.bottom = -HIGHLIGHT_OFFSET + 'px';
highlight.setAttribute('hidden', true);
item.highlightElement = highlight;
container.appendChild(item.highlightElement);
}
cstyle.width = width + 'px';
cstyle.height = height + 'px';
return container;
}
function getHtmlElementForTextWidgetAnnotation(item, commonObjs) {
var element = getEmptyContainer('div', item.rect, 0);
var element = document.createElement('div');
var width = item.rect[2] - item.rect[0];
var height = item.rect[3] - item.rect[1];
element.style.width = width + 'px';
element.style.height = height + 'px';
element.style.display = 'table';
var content = document.createElement('div');
@ -6466,7 +6480,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { @@ -6466,7 +6480,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
rect[2] = rect[0] + (rect[3] - rect[1]); // make it square
}
var container = initContainer(item);
var container = initContainer(item, false);
container.className = 'annotText';
var image = document.createElement('img');
@ -6491,13 +6505,15 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { @@ -6491,13 +6505,15 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
var i, ii;
if (item.hasBgColor) {
var color = item.color;
var rgb = [];
for (i = 0; i < 3; ++i) {
// Enlighten the color (70%)
var c = Math.round(color[i] * 255);
rgb[i] = Math.round((255 - c) * 0.7) + c;
}
content.style.backgroundColor = Util.makeCssRgb(rgb);
var BACKGROUND_ENLIGHT = 0.7;
var r = BACKGROUND_ENLIGHT * (1.0 - color[0]) + color[0];
var g = BACKGROUND_ENLIGHT * (1.0 - color[1]) + color[1];
var b = BACKGROUND_ENLIGHT * (1.0 - color[2]) + color[2];
content.style.backgroundColor = Util.makeCssRgb((r * 255) | 0,
(g * 255) | 0,
(b * 255) | 0);
}
var title = document.createElement('h1');
@ -6573,12 +6589,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { @@ -6573,12 +6589,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
}
function getHtmlElementForLinkAnnotation(item) {
var container = initContainer(item);
var container = initContainer(item, true);
container.className = 'annotLink';
container.style.borderColor = item.colorCssRgb;
container.style.borderStyle = 'solid';
var link = document.createElement('a');
link.href = link.title = item.url || '';
@ -7409,11 +7422,11 @@ var SVGGraphics = (function SVGGraphicsClosure() { @@ -7409,11 +7422,11 @@ var SVGGraphics = (function SVGGraphicsClosure() {
this.current.miterLimit = limit;
},
setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments);
var color = Util.makeCssRgb(r, g, b);
this.current.strokeColor = color;
},
setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments);
var color = Util.makeCssRgb(r, g, b);
this.current.fillColor = color;
this.current.tspan = document.createElementNS(NS, 'svg:tspan');
this.current.xcoords = [];

805
static/js/libs/pdf/pdf.worker.js vendored

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save