Browse Source

PDF.js version 1.5.477 - See mozilla/pdf.js@9e927ded937473c2a268fb549eeabd442bc40e55

master v1.5.477
Pdf Bot 9 years ago
parent
commit
4531f4dbcc
  1. 2
      bower.json
  2. 239
      build/pdf.combined.js
  3. 110
      build/pdf.js
  4. 156
      build/pdf.worker.js
  5. 2
      package.json
  6. 22
      web/pdf_viewer.css
  7. 26
      web/pdf_viewer.js

2
bower.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.5.458",
"version": "1.5.477",
"main": [
"build/pdf.js",
"build/pdf.worker.js"

239
build/pdf.combined.js

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfCombined = {})); @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfCombined = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.5.458';
var pdfjsBuild = 'a7c3502';
var pdfjsVersion = '1.5.477';
var pdfjsBuild = '9e927de';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
@ -1100,6 +1100,28 @@ var AnnotationFlag = { @@ -1100,6 +1100,28 @@ var AnnotationFlag = {
LOCKEDCONTENTS: 0x200
};
var AnnotationFieldFlag = {
READONLY: 1,
REQUIRED: 2,
NOEXPORT: 3,
MULTILINE: 13,
PASSWORD: 14,
NOTOGGLETOOFF: 15,
RADIO: 16,
PUSHBUTTON: 17,
COMBO: 18,
EDIT: 19,
SORT: 20,
FILESELECT: 21,
MULTISELECT: 22,
DONOTSPELLCHECK: 23,
DONOTSCROLL: 24,
COMB: 25,
RICHTEXT: 26,
RADIOSINUNISON: 26,
COMMITONSELCHANGE: 27,
};
var AnnotationBorderStyleType = {
SOLID: 1,
DASHED: 2,
@ -3361,6 +3383,7 @@ exports.OPS = OPS; @@ -3361,6 +3383,7 @@ exports.OPS = OPS;
exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
exports.AnnotationFieldFlag = AnnotationFieldFlag;
exports.AnnotationFlag = AnnotationFlag;
exports.AnnotationType = AnnotationType;
exports.FontType = FontType;
@ -24502,7 +24525,9 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() { @@ -24502,7 +24525,9 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() {
*/
var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
function WidgetAnnotationElement(parameters) {
AnnotationElement.call(this, parameters, true);
var isRenderable = parameters.renderInteractiveForms ||
(!parameters.data.hasAppearance && !!parameters.data.fieldValue);
AnnotationElement.call(this, parameters, isRenderable);
}
Util.inherit(WidgetAnnotationElement, AnnotationElement, {
@ -24547,9 +24572,15 @@ var TextWidgetAnnotationElement = ( @@ -24547,9 +24572,15 @@ var TextWidgetAnnotationElement = (
var element = null;
if (this.renderInteractiveForms) {
element = document.createElement('input');
element.type = 'text';
if (this.data.multiLine) {
element = document.createElement('textarea');
} else {
element = document.createElement('input');
element.type = 'text';
}
element.value = this.data.fieldValue;
element.disabled = this.data.readOnly;
if (this.data.maxLen !== null) {
element.maxLength = this.data.maxLen;
@ -25105,14 +25136,20 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -25105,14 +25136,20 @@ var renderTextLayer = (function renderTextLayerClosure() {
return !NonWhitespaceRegexp.test(str);
}
// Text layers may contain many thousand div's, and using `styleBuf` avoids
// creating many intermediate strings when building their 'style' properties.
var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0,
'px; font-family: ', '', ';'];
function appendText(task, geom, styles) {
// Initialize all used properties to keep the caches monomorphic.
var textDiv = document.createElement('div');
var textDivProperties = {
style: null,
angle: 0,
canvasWidth: 0,
isWhitespace: false,
originalTransform: '',
originalTransform: null,
paddingBottom: 0,
paddingLeft: 0,
paddingRight: 0,
@ -25150,10 +25187,12 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -25150,10 +25187,12 @@ var renderTextLayer = (function renderTextLayerClosure() {
left = tx[4] + (fontAscent * Math.sin(angle));
top = tx[5] - (fontAscent * Math.cos(angle));
}
textDiv.style.left = left + 'px';
textDiv.style.top = top + 'px';
textDiv.style.fontSize = fontHeight + 'px';
textDiv.style.fontFamily = style.fontFamily;
styleBuf[1] = left;
styleBuf[3] = top;
styleBuf[5] = fontHeight;
styleBuf[7] = style.fontFamily;
textDivProperties.style = styleBuf.join('');
textDiv.setAttribute('style', textDivProperties.style);
textDiv.textContent = geom.str;
// |fontName| is only used by the Font Inspector. This test will succeed
@ -25560,7 +25599,6 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -25560,7 +25599,6 @@ var renderTextLayer = (function renderTextLayerClosure() {
this._renderTimer = null;
this._bounds = [];
this._enhanceTextSelection = !!enhanceTextSelection;
this._expanded = false;
}
TextLayerRenderTask.prototype = {
get promise() {
@ -25598,18 +25636,20 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -25598,18 +25636,20 @@ var renderTextLayer = (function renderTextLayerClosure() {
if (!this._enhanceTextSelection || !this._renderingDone) {
return;
}
if (!this._expanded) {
if (this._bounds !== null) {
expand(this);
this._expanded = true;
this._bounds.length = 0;
this._bounds = null;
}
for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
var div = this._textDivs[i];
var divProperties = this._textDivProperties.get(div);
if (divProperties.isWhitespace) {
continue;
}
if (expandDivs) {
var transform = '';
var transform = '', padding = '';
if (divProperties.scale !== 1) {
transform = 'scaleX(' + divProperties.scale + ')';
@ -25618,21 +25658,26 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -25618,21 +25658,26 @@ var renderTextLayer = (function renderTextLayerClosure() {
transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
}
if (divProperties.paddingLeft !== 0) {
div.style.paddingLeft =
(divProperties.paddingLeft / divProperties.scale) + 'px';
padding += ' padding-left: ' +
(divProperties.paddingLeft / divProperties.scale) + 'px;';
transform += ' translateX(' +
(-divProperties.paddingLeft / divProperties.scale) + 'px)';
}
if (divProperties.paddingTop !== 0) {
div.style.paddingTop = divProperties.paddingTop + 'px';
padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
transform += ' translateY(' + (-divProperties.paddingTop) + 'px)';
}
if (divProperties.paddingRight !== 0) {
div.style.paddingRight =
(divProperties.paddingRight / divProperties.scale) + 'px';
padding += ' padding-right: ' +
(divProperties.paddingRight / divProperties.scale) + 'px;';
}
if (divProperties.paddingBottom !== 0) {
div.style.paddingBottom = divProperties.paddingBottom + 'px';
padding += ' padding-bottom: ' +
divProperties.paddingBottom + 'px;';
}
if (padding !== '') {
div.setAttribute('style', divProperties.style + padding);
}
if (transform !== '') {
CustomStyle.setProp('transform', div, transform);
@ -25640,7 +25685,7 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -25640,7 +25685,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
} else {
div.style.padding = 0;
CustomStyle.setProp('transform', div,
divProperties.originalTransform);
divProperties.originalTransform || '');
}
}
},
@ -32283,6 +32328,30 @@ function adjustWidths(properties) { @@ -32283,6 +32328,30 @@ function adjustWidths(properties) {
properties.defaultWidth *= scale;
}
function adjustToUnicode(properties, builtInEncoding) {
if (properties.hasIncludedToUnicodeMap) {
return; // The font dictionary has a `ToUnicode` entry.
}
if (properties.hasEncoding) {
return; // The font dictionary has an `Encoding` entry.
}
if (builtInEncoding === properties.defaultEncoding) {
return; // No point in trying to adjust `toUnicode` if the encodings match.
}
if (properties.toUnicode instanceof IdentityToUnicodeMap) {
return;
}
var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
for (var charCode in builtInEncoding) {
var glyphName = builtInEncoding[charCode];
var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
if (unicode !== -1) {
toUnicode[charCode] = String.fromCharCode(unicode);
}
}
properties.toUnicode.amend(toUnicode);
}
function getFontType(type, subtype) {
switch (type) {
case 'Type1':
@ -32381,7 +32450,13 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() { @@ -32381,7 +32450,13 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() {
charCodeOf: function(v) {
return this._map.indexOf(v);
}
},
amend: function (map) {
for (var charCode in map) {
this._map[charCode] = map[charCode];
}
},
};
return ToUnicodeMap;
@ -32417,7 +32492,11 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() { @@ -32417,7 +32492,11 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
charCodeOf: function (v) {
return (isInt(v) && v >= this.firstChar && v <= this.lastChar) ? v : -1;
}
},
amend: function (map) {
error('Should not call amend()');
},
};
return IdentityToUnicodeMap;
@ -32818,6 +32897,7 @@ var Font = (function FontClosure() { @@ -32818,6 +32897,7 @@ var Font = (function FontClosure() {
this.fontMatrix = properties.fontMatrix;
this.widths = properties.widths;
this.defaultWidth = properties.defaultWidth;
this.toUnicode = properties.toUnicode;
this.encoding = properties.baseEncoding;
this.seacMap = properties.seacMap;
@ -34439,10 +34519,8 @@ var Font = (function FontClosure() { @@ -34439,10 +34519,8 @@ var Font = (function FontClosure() {
} else {
// Most of the following logic in this code branch is based on the
// 9.6.6.4 of the PDF spec.
var hasEncoding =
properties.differences.length > 0 || !!properties.baseEncodingName;
var cmapTable =
readCmapTable(tables['cmap'], font, this.isSymbolicFont, hasEncoding);
var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont,
properties.hasEncoding);
var cmapPlatformId = cmapTable.platformId;
var cmapEncodingId = cmapTable.encodingId;
var cmapMappings = cmapTable.mappings;
@ -34451,7 +34529,7 @@ var Font = (function FontClosure() { @@ -34451,7 +34529,7 @@ var Font = (function FontClosure() {
// The spec seems to imply that if the font is symbolic the encoding
// should be ignored, this doesn't appear to work for 'preistabelle.pdf'
// where the the font is symbolic and it has an encoding.
if (hasEncoding &&
if (properties.hasEncoding &&
(cmapPlatformId === 3 && cmapEncodingId === 1 ||
cmapPlatformId === 1 && cmapEncodingId === 0) ||
(cmapPlatformId === -1 && cmapEncodingId === -1 && // Temporary hack
@ -34615,6 +34693,12 @@ var Font = (function FontClosure() { @@ -34615,6 +34693,12 @@ var Font = (function FontClosure() {
// TODO: Check the charstring widths to determine this.
properties.fixedPitch = false;
if (properties.builtInEncoding) {
// For Type1 fonts that do not include either `ToUnicode` or `Encoding`
// data, attempt to use the `builtInEncoding` to improve text selection.
adjustToUnicode(properties, properties.builtInEncoding);
}
var mapping = font.getGlyphMapping(properties);
var newMapping = adjustMapping(mapping, properties);
this.toFontChar = newMapping.toFontChar;
@ -36302,9 +36386,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -36302,9 +36386,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (sourceCtx.setLineDash !== undefined) {
destCtx.setLineDash(sourceCtx.getLineDash());
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
} else if (sourceCtx.mozDashOffset !== undefined) {
destCtx.mozDash = sourceCtx.mozDash;
destCtx.mozDashOffset = sourceCtx.mozDashOffset;
}
}
@ -36560,9 +36641,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -36560,9 +36641,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (ctx.setLineDash !== undefined) {
ctx.setLineDash(dashArray);
ctx.lineDashOffset = dashPhase;
} else {
ctx.mozDash = dashArray;
ctx.mozDashOffset = dashPhase;
}
},
setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
@ -39742,6 +39820,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { @@ -39742,6 +39820,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
* calling of PDFPage.getViewport method.
* @property {string} intent - Rendering intent, can be 'display' or 'print'
* (default value is 'display').
* @property {boolean} renderInteractiveForms - (optional) Whether or not
* interactive form elements are rendered in the display
* layer. If so, we do not render them on canvas as well.
* @property {Array} transform - (optional) Additional transform, applied
* just before viewport transform.
* @property {Object} imageLayer - (optional) An object that has beginLayout,
@ -39850,6 +39931,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { @@ -39850,6 +39931,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.pendingCleanup = false;
var renderingIntent = (params.intent === 'print' ? 'print' : 'display');
var renderInteractiveForms = (params.renderInteractiveForms === true ?
true : /* Default */ false);
if (!this.intentStates[renderingIntent]) {
this.intentStates[renderingIntent] = Object.create(null);
@ -39870,7 +39953,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { @@ -39870,7 +39953,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.stats.time('Page Request');
this.transport.messageHandler.send('RenderPageRequest', {
pageIndex: this.pageNumber - 1,
intent: renderingIntent
intent: renderingIntent,
renderInteractiveForms: renderInteractiveForms,
});
}
@ -42603,13 +42687,6 @@ exports.ColorSpace = ColorSpace; @@ -42603,13 +42687,6 @@ exports.ColorSpace = ColorSpace;
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
true : PDFJS.isEvalSupported);
/**
* Renders interactive form elements.
* @var {boolean}
*/
PDFJS.renderInteractiveForms = (PDFJS.renderInteractiveForms === undefined ?
false : PDFJS.renderInteractiveForms);
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
delete PDFJS.openExternalLinksInNewWindow;
Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
@ -47454,6 +47531,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -47454,6 +47531,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
properties.differences = differences;
properties.baseEncodingName = baseEncodingName;
properties.hasEncoding = !!baseEncodingName || differences.length > 0;
properties.dict = dict;
return toUnicodePromise.then(function(toUnicode) {
properties.toUnicode = toUnicode;
@ -47471,8 +47549,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -47471,8 +47549,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
* {ToUnicodeMap|IdentityToUnicodeMap} object.
*/
buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
properties.hasIncludedToUnicodeMap =
!!properties.toUnicode && properties.toUnicode.length > 0;
// Section 9.10.2 Mapping Character Codes to Unicode Values
if (properties.toUnicode && properties.toUnicode.length !== 0) {
if (properties.hasIncludedToUnicodeMap) {
return Promise.resolve(properties.toUnicode);
}
// According to the spec if the font is a simple font we should only map
@ -49017,6 +49097,7 @@ exports.PartialEvaluator = PartialEvaluator; @@ -49017,6 +49097,7 @@ exports.PartialEvaluator = PartialEvaluator;
coreColorSpace, coreObj, coreEvaluator) {
var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
var AnnotationFlag = sharedUtil.AnnotationFlag;
var AnnotationType = sharedUtil.AnnotationType;
var OPS = sharedUtil.OPS;
@ -49049,10 +49130,14 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { @@ -49049,10 +49130,14 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
/**
* @param {XRef} xref
* @param {Object} ref
* @param {string} uniquePrefix
* @param {Object} idCounters
* @param {boolean} renderInteractiveForms
* @returns {Annotation}
*/
create: function AnnotationFactory_create(xref, ref,
uniquePrefix, idCounters) {
uniquePrefix, idCounters,
renderInteractiveForms) {
var dict = xref.fetchIfRef(ref);
if (!isDict(dict)) {
return;
@ -49071,6 +49156,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { @@ -49071,6 +49156,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
ref: isRef(ref) ? ref : null,
subtype: subtype,
id: id,
renderInteractiveForms: renderInteractiveForms,
};
switch (subtype) {
@ -49605,9 +49691,13 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() { @@ -49605,9 +49691,13 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
var fieldType = Util.getInheritableProperty(dict, 'FT');
data.fieldType = isName(fieldType) ? fieldType.name : null;
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff') || 0;
this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
data.fieldFlags = 0;
}
// Hide signatures because we cannot validate them.
if (data.fieldType === 'Sig') {
this.setFlags(AnnotationFlag.HIDDEN);
@ -49646,7 +49736,22 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() { @@ -49646,7 +49736,22 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
data.fullName = fieldName.join('.');
}
Util.inherit(WidgetAnnotation, Annotation, {});
Util.inherit(WidgetAnnotation, Annotation, {
/**
* Check if a provided field flag is set.
*
* @public
* @memberof WidgetAnnotation
* @param {number} flag - Bit position, numbered from one instead of
* zero, to check
* @return {boolean}
* @see {@link shared/util.js}
*/
hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
var mask = 1 << (flag - 1);
return !!(this.data.fieldFlags & mask);
},
});
return WidgetAnnotation;
})();
@ -49655,6 +49760,8 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { @@ -49655,6 +49760,8 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
function TextWidgetAnnotation(params) {
WidgetAnnotation.call(this, params);
this.renderInteractiveForms = params.renderInteractiveForms;
// Determine the alignment of text in the field.
var alignment = Util.getInheritableProperty(params.dict, 'Q');
if (!isInt(alignment) || alignment < 0 || alignment > 2) {
@ -49668,29 +49775,38 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { @@ -49668,29 +49775,38 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
maximumLength = null;
}
this.data.maxLen = maximumLength;
// Process field flags for the display layer.
this.data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
}
Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator,
task) {
var operatorList = new OperatorList();
// Do not render form elements on the canvas when interactive forms are
// enabled. The display layer is responsible for rendering them instead.
if (this.renderInteractiveForms) {
return Promise.resolve(operatorList);
}
if (this.appearance) {
return Annotation.prototype.getOperatorList.call(this, evaluator, task);
}
var opList = new OperatorList();
var data = this.data;
// Even if there is an appearance stream, ignore it. This is the
// behaviour used by Adobe Reader.
if (!data.defaultAppearance) {
return Promise.resolve(opList);
if (!this.data.defaultAppearance) {
return Promise.resolve(operatorList);
}
var stream = new Stream(stringToBytes(data.defaultAppearance));
return evaluator.getOperatorList(stream, task,
this.fieldResources, opList).
var stream = new Stream(stringToBytes(this.data.defaultAppearance));
return evaluator.getOperatorList(stream, task, this.fieldResources,
operatorList).
then(function () {
return opList;
return operatorList;
});
}
});
@ -50137,7 +50253,8 @@ var Page = (function PageClosure() { @@ -50137,7 +50253,8 @@ var Page = (function PageClosure() {
}.bind(this));
},
getOperatorList: function Page_getOperatorList(handler, task, intent) {
getOperatorList: function Page_getOperatorList(handler, task, intent,
renderInteractiveForms) {
var self = this;
var pdfManager = this.pdfManager;
@ -50177,6 +50294,8 @@ var Page = (function PageClosure() { @@ -50177,6 +50294,8 @@ var Page = (function PageClosure() {
});
});
this.renderInteractiveForms = renderInteractiveForms;
var annotationsPromise = pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(
function(datas) {
@ -50260,7 +50379,8 @@ var Page = (function PageClosure() { @@ -50260,7 +50379,8 @@ var Page = (function PageClosure() {
var annotationRef = annotationRefs[i];
var annotation = annotationFactory.create(this.xref, annotationRef,
this.uniquePrefix,
this.idCounters);
this.idCounters,
this.renderInteractiveForms);
if (annotation) {
annotations.push(annotation);
}
@ -51447,7 +51567,8 @@ var WorkerMessageHandler = { @@ -51447,7 +51567,8 @@ var WorkerMessageHandler = {
var pageNum = pageIndex + 1;
var start = Date.now();
// Pre compile the pdf page and fetch the fonts/images.
page.getOperatorList(handler, task, data.intent).then(
page.getOperatorList(handler, task, data.intent,
data.renderInteractiveForms).then(
function(operatorList) {
finishWorkerTask(task);

110
build/pdf.js

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {})); @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.5.458';
var pdfjsBuild = 'a7c3502';
var pdfjsVersion = '1.5.477';
var pdfjsBuild = '9e927de';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
@ -114,6 +114,28 @@ var AnnotationFlag = { @@ -114,6 +114,28 @@ var AnnotationFlag = {
LOCKEDCONTENTS: 0x200
};
var AnnotationFieldFlag = {
READONLY: 1,
REQUIRED: 2,
NOEXPORT: 3,
MULTILINE: 13,
PASSWORD: 14,
NOTOGGLETOOFF: 15,
RADIO: 16,
PUSHBUTTON: 17,
COMBO: 18,
EDIT: 19,
SORT: 20,
FILESELECT: 21,
MULTISELECT: 22,
DONOTSPELLCHECK: 23,
DONOTSCROLL: 24,
COMB: 25,
RICHTEXT: 26,
RADIOSINUNISON: 26,
COMMITONSELCHANGE: 27,
};
var AnnotationBorderStyleType = {
SOLID: 1,
DASHED: 2,
@ -2375,6 +2397,7 @@ exports.OPS = OPS; @@ -2375,6 +2397,7 @@ exports.OPS = OPS;
exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
exports.AnnotationFieldFlag = AnnotationFieldFlag;
exports.AnnotationFlag = AnnotationFlag;
exports.AnnotationType = AnnotationType;
exports.FontType = FontType;
@ -4697,7 +4720,9 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() { @@ -4697,7 +4720,9 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() {
*/
var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
function WidgetAnnotationElement(parameters) {
AnnotationElement.call(this, parameters, true);
var isRenderable = parameters.renderInteractiveForms ||
(!parameters.data.hasAppearance && !!parameters.data.fieldValue);
AnnotationElement.call(this, parameters, isRenderable);
}
Util.inherit(WidgetAnnotationElement, AnnotationElement, {
@ -4742,9 +4767,15 @@ var TextWidgetAnnotationElement = ( @@ -4742,9 +4767,15 @@ var TextWidgetAnnotationElement = (
var element = null;
if (this.renderInteractiveForms) {
element = document.createElement('input');
element.type = 'text';
if (this.data.multiLine) {
element = document.createElement('textarea');
} else {
element = document.createElement('input');
element.type = 'text';
}
element.value = this.data.fieldValue;
element.disabled = this.data.readOnly;
if (this.data.maxLen !== null) {
element.maxLength = this.data.maxLen;
@ -5300,14 +5331,20 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -5300,14 +5331,20 @@ var renderTextLayer = (function renderTextLayerClosure() {
return !NonWhitespaceRegexp.test(str);
}
// Text layers may contain many thousand div's, and using `styleBuf` avoids
// creating many intermediate strings when building their 'style' properties.
var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0,
'px; font-family: ', '', ';'];
function appendText(task, geom, styles) {
// Initialize all used properties to keep the caches monomorphic.
var textDiv = document.createElement('div');
var textDivProperties = {
style: null,
angle: 0,
canvasWidth: 0,
isWhitespace: false,
originalTransform: '',
originalTransform: null,
paddingBottom: 0,
paddingLeft: 0,
paddingRight: 0,
@ -5345,10 +5382,12 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -5345,10 +5382,12 @@ var renderTextLayer = (function renderTextLayerClosure() {
left = tx[4] + (fontAscent * Math.sin(angle));
top = tx[5] - (fontAscent * Math.cos(angle));
}
textDiv.style.left = left + 'px';
textDiv.style.top = top + 'px';
textDiv.style.fontSize = fontHeight + 'px';
textDiv.style.fontFamily = style.fontFamily;
styleBuf[1] = left;
styleBuf[3] = top;
styleBuf[5] = fontHeight;
styleBuf[7] = style.fontFamily;
textDivProperties.style = styleBuf.join('');
textDiv.setAttribute('style', textDivProperties.style);
textDiv.textContent = geom.str;
// |fontName| is only used by the Font Inspector. This test will succeed
@ -5756,7 +5795,6 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -5756,7 +5795,6 @@ var renderTextLayer = (function renderTextLayerClosure() {
this._renderTimer = null;
this._bounds = [];
this._enhanceTextSelection = !!enhanceTextSelection;
this._expanded = false;
}
TextLayerRenderTask.prototype = {
get promise() {
@ -5794,18 +5832,20 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -5794,18 +5832,20 @@ var renderTextLayer = (function renderTextLayerClosure() {
if (!this._enhanceTextSelection || !this._renderingDone) {
return;
}
if (!this._expanded) {
if (this._bounds !== null) {
expand(this);
this._expanded = true;
this._bounds.length = 0;
this._bounds = null;
}
for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
var div = this._textDivs[i];
var divProperties = this._textDivProperties.get(div);
if (divProperties.isWhitespace) {
continue;
}
if (expandDivs) {
var transform = '';
var transform = '', padding = '';
if (divProperties.scale !== 1) {
transform = 'scaleX(' + divProperties.scale + ')';
@ -5814,21 +5854,26 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -5814,21 +5854,26 @@ var renderTextLayer = (function renderTextLayerClosure() {
transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
}
if (divProperties.paddingLeft !== 0) {
div.style.paddingLeft =
(divProperties.paddingLeft / divProperties.scale) + 'px';
padding += ' padding-left: ' +
(divProperties.paddingLeft / divProperties.scale) + 'px;';
transform += ' translateX(' +
(-divProperties.paddingLeft / divProperties.scale) + 'px)';
}
if (divProperties.paddingTop !== 0) {
div.style.paddingTop = divProperties.paddingTop + 'px';
padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
transform += ' translateY(' + (-divProperties.paddingTop) + 'px)';
}
if (divProperties.paddingRight !== 0) {
div.style.paddingRight =
(divProperties.paddingRight / divProperties.scale) + 'px';
padding += ' padding-right: ' +
(divProperties.paddingRight / divProperties.scale) + 'px;';
}
if (divProperties.paddingBottom !== 0) {
div.style.paddingBottom = divProperties.paddingBottom + 'px';
padding += ' padding-bottom: ' +
divProperties.paddingBottom + 'px;';
}
if (padding !== '') {
div.setAttribute('style', divProperties.style + padding);
}
if (transform !== '') {
CustomStyle.setProp('transform', div, transform);
@ -5836,7 +5881,7 @@ var renderTextLayer = (function renderTextLayerClosure() { @@ -5836,7 +5881,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
} else {
div.style.padding = 0;
CustomStyle.setProp('transform', div,
divProperties.originalTransform);
divProperties.originalTransform || '');
}
}
},
@ -7361,9 +7406,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -7361,9 +7406,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (sourceCtx.setLineDash !== undefined) {
destCtx.setLineDash(sourceCtx.getLineDash());
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
} else if (sourceCtx.mozDashOffset !== undefined) {
destCtx.mozDash = sourceCtx.mozDash;
destCtx.mozDashOffset = sourceCtx.mozDashOffset;
}
}
@ -7619,9 +7661,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -7619,9 +7661,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (ctx.setLineDash !== undefined) {
ctx.setLineDash(dashArray);
ctx.lineDashOffset = dashPhase;
} else {
ctx.mozDash = dashArray;
ctx.mozDashOffset = dashPhase;
}
},
setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
@ -9691,6 +9730,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { @@ -9691,6 +9730,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
* calling of PDFPage.getViewport method.
* @property {string} intent - Rendering intent, can be 'display' or 'print'
* (default value is 'display').
* @property {boolean} renderInteractiveForms - (optional) Whether or not
* interactive form elements are rendered in the display
* layer. If so, we do not render them on canvas as well.
* @property {Array} transform - (optional) Additional transform, applied
* just before viewport transform.
* @property {Object} imageLayer - (optional) An object that has beginLayout,
@ -9799,6 +9841,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { @@ -9799,6 +9841,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.pendingCleanup = false;
var renderingIntent = (params.intent === 'print' ? 'print' : 'display');
var renderInteractiveForms = (params.renderInteractiveForms === true ?
true : /* Default */ false);
if (!this.intentStates[renderingIntent]) {
this.intentStates[renderingIntent] = Object.create(null);
@ -9819,7 +9863,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { @@ -9819,7 +9863,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.stats.time('Page Request');
this.transport.messageHandler.send('RenderPageRequest', {
pageIndex: this.pageNumber - 1,
intent: renderingIntent
intent: renderingIntent,
renderInteractiveForms: renderInteractiveForms,
});
}
@ -11362,13 +11407,6 @@ exports._UnsupportedManager = _UnsupportedManager; @@ -11362,13 +11407,6 @@ exports._UnsupportedManager = _UnsupportedManager;
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
true : PDFJS.isEvalSupported);
/**
* Renders interactive form elements.
* @var {boolean}
*/
PDFJS.renderInteractiveForms = (PDFJS.renderInteractiveForms === undefined ?
false : PDFJS.renderInteractiveForms);
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
delete PDFJS.openExternalLinksInNewWindow;
Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {

156
build/pdf.worker.js vendored

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {})); @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.5.458';
var pdfjsBuild = 'a7c3502';
var pdfjsVersion = '1.5.477';
var pdfjsBuild = '9e927de';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
@ -1100,6 +1100,28 @@ var AnnotationFlag = { @@ -1100,6 +1100,28 @@ var AnnotationFlag = {
LOCKEDCONTENTS: 0x200
};
var AnnotationFieldFlag = {
READONLY: 1,
REQUIRED: 2,
NOEXPORT: 3,
MULTILINE: 13,
PASSWORD: 14,
NOTOGGLETOOFF: 15,
RADIO: 16,
PUSHBUTTON: 17,
COMBO: 18,
EDIT: 19,
SORT: 20,
FILESELECT: 21,
MULTISELECT: 22,
DONOTSPELLCHECK: 23,
DONOTSCROLL: 24,
COMB: 25,
RICHTEXT: 26,
RADIOSINUNISON: 26,
COMMITONSELCHANGE: 27,
};
var AnnotationBorderStyleType = {
SOLID: 1,
DASHED: 2,
@ -3361,6 +3383,7 @@ exports.OPS = OPS; @@ -3361,6 +3383,7 @@ exports.OPS = OPS;
exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
exports.AnnotationFieldFlag = AnnotationFieldFlag;
exports.AnnotationFlag = AnnotationFlag;
exports.AnnotationType = AnnotationType;
exports.FontType = FontType;
@ -27991,6 +28014,30 @@ function adjustWidths(properties) { @@ -27991,6 +28014,30 @@ function adjustWidths(properties) {
properties.defaultWidth *= scale;
}
function adjustToUnicode(properties, builtInEncoding) {
if (properties.hasIncludedToUnicodeMap) {
return; // The font dictionary has a `ToUnicode` entry.
}
if (properties.hasEncoding) {
return; // The font dictionary has an `Encoding` entry.
}
if (builtInEncoding === properties.defaultEncoding) {
return; // No point in trying to adjust `toUnicode` if the encodings match.
}
if (properties.toUnicode instanceof IdentityToUnicodeMap) {
return;
}
var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
for (var charCode in builtInEncoding) {
var glyphName = builtInEncoding[charCode];
var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
if (unicode !== -1) {
toUnicode[charCode] = String.fromCharCode(unicode);
}
}
properties.toUnicode.amend(toUnicode);
}
function getFontType(type, subtype) {
switch (type) {
case 'Type1':
@ -28089,7 +28136,13 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() { @@ -28089,7 +28136,13 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() {
charCodeOf: function(v) {
return this._map.indexOf(v);
}
},
amend: function (map) {
for (var charCode in map) {
this._map[charCode] = map[charCode];
}
},
};
return ToUnicodeMap;
@ -28125,7 +28178,11 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() { @@ -28125,7 +28178,11 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
charCodeOf: function (v) {
return (isInt(v) && v >= this.firstChar && v <= this.lastChar) ? v : -1;
}
},
amend: function (map) {
error('Should not call amend()');
},
};
return IdentityToUnicodeMap;
@ -28526,6 +28583,7 @@ var Font = (function FontClosure() { @@ -28526,6 +28583,7 @@ var Font = (function FontClosure() {
this.fontMatrix = properties.fontMatrix;
this.widths = properties.widths;
this.defaultWidth = properties.defaultWidth;
this.toUnicode = properties.toUnicode;
this.encoding = properties.baseEncoding;
this.seacMap = properties.seacMap;
@ -30147,10 +30205,8 @@ var Font = (function FontClosure() { @@ -30147,10 +30205,8 @@ var Font = (function FontClosure() {
} else {
// Most of the following logic in this code branch is based on the
// 9.6.6.4 of the PDF spec.
var hasEncoding =
properties.differences.length > 0 || !!properties.baseEncodingName;
var cmapTable =
readCmapTable(tables['cmap'], font, this.isSymbolicFont, hasEncoding);
var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont,
properties.hasEncoding);
var cmapPlatformId = cmapTable.platformId;
var cmapEncodingId = cmapTable.encodingId;
var cmapMappings = cmapTable.mappings;
@ -30159,7 +30215,7 @@ var Font = (function FontClosure() { @@ -30159,7 +30215,7 @@ var Font = (function FontClosure() {
// The spec seems to imply that if the font is symbolic the encoding
// should be ignored, this doesn't appear to work for 'preistabelle.pdf'
// where the the font is symbolic and it has an encoding.
if (hasEncoding &&
if (properties.hasEncoding &&
(cmapPlatformId === 3 && cmapEncodingId === 1 ||
cmapPlatformId === 1 && cmapEncodingId === 0) ||
(cmapPlatformId === -1 && cmapEncodingId === -1 && // Temporary hack
@ -30323,6 +30379,12 @@ var Font = (function FontClosure() { @@ -30323,6 +30379,12 @@ var Font = (function FontClosure() {
// TODO: Check the charstring widths to determine this.
properties.fixedPitch = false;
if (properties.builtInEncoding) {
// For Type1 fonts that do not include either `ToUnicode` or `Encoding`
// data, attempt to use the `builtInEncoding` to improve text selection.
adjustToUnicode(properties, properties.builtInEncoding);
}
var mapping = font.getGlyphMapping(properties);
var newMapping = adjustMapping(mapping, properties);
this.toFontChar = newMapping.toFontChar;
@ -38599,6 +38661,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -38599,6 +38661,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
properties.differences = differences;
properties.baseEncodingName = baseEncodingName;
properties.hasEncoding = !!baseEncodingName || differences.length > 0;
properties.dict = dict;
return toUnicodePromise.then(function(toUnicode) {
properties.toUnicode = toUnicode;
@ -38616,8 +38679,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { @@ -38616,8 +38679,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
* {ToUnicodeMap|IdentityToUnicodeMap} object.
*/
buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
properties.hasIncludedToUnicodeMap =
!!properties.toUnicode && properties.toUnicode.length > 0;
// Section 9.10.2 Mapping Character Codes to Unicode Values
if (properties.toUnicode && properties.toUnicode.length !== 0) {
if (properties.hasIncludedToUnicodeMap) {
return Promise.resolve(properties.toUnicode);
}
// According to the spec if the font is a simple font we should only map
@ -40162,6 +40227,7 @@ exports.PartialEvaluator = PartialEvaluator; @@ -40162,6 +40227,7 @@ exports.PartialEvaluator = PartialEvaluator;
coreColorSpace, coreObj, coreEvaluator) {
var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
var AnnotationFlag = sharedUtil.AnnotationFlag;
var AnnotationType = sharedUtil.AnnotationType;
var OPS = sharedUtil.OPS;
@ -40194,10 +40260,14 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { @@ -40194,10 +40260,14 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
/**
* @param {XRef} xref
* @param {Object} ref
* @param {string} uniquePrefix
* @param {Object} idCounters
* @param {boolean} renderInteractiveForms
* @returns {Annotation}
*/
create: function AnnotationFactory_create(xref, ref,
uniquePrefix, idCounters) {
uniquePrefix, idCounters,
renderInteractiveForms) {
var dict = xref.fetchIfRef(ref);
if (!isDict(dict)) {
return;
@ -40216,6 +40286,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { @@ -40216,6 +40286,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
ref: isRef(ref) ? ref : null,
subtype: subtype,
id: id,
renderInteractiveForms: renderInteractiveForms,
};
switch (subtype) {
@ -40750,9 +40821,13 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() { @@ -40750,9 +40821,13 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
var fieldType = Util.getInheritableProperty(dict, 'FT');
data.fieldType = isName(fieldType) ? fieldType.name : null;
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff') || 0;
this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
data.fieldFlags = 0;
}
// Hide signatures because we cannot validate them.
if (data.fieldType === 'Sig') {
this.setFlags(AnnotationFlag.HIDDEN);
@ -40791,7 +40866,22 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() { @@ -40791,7 +40866,22 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
data.fullName = fieldName.join('.');
}
Util.inherit(WidgetAnnotation, Annotation, {});
Util.inherit(WidgetAnnotation, Annotation, {
/**
* Check if a provided field flag is set.
*
* @public
* @memberof WidgetAnnotation
* @param {number} flag - Bit position, numbered from one instead of
* zero, to check
* @return {boolean}
* @see {@link shared/util.js}
*/
hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
var mask = 1 << (flag - 1);
return !!(this.data.fieldFlags & mask);
},
});
return WidgetAnnotation;
})();
@ -40800,6 +40890,8 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { @@ -40800,6 +40890,8 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
function TextWidgetAnnotation(params) {
WidgetAnnotation.call(this, params);
this.renderInteractiveForms = params.renderInteractiveForms;
// Determine the alignment of text in the field.
var alignment = Util.getInheritableProperty(params.dict, 'Q');
if (!isInt(alignment) || alignment < 0 || alignment > 2) {
@ -40813,29 +40905,38 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { @@ -40813,29 +40905,38 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
maximumLength = null;
}
this.data.maxLen = maximumLength;
// Process field flags for the display layer.
this.data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
}
Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator,
task) {
var operatorList = new OperatorList();
// Do not render form elements on the canvas when interactive forms are
// enabled. The display layer is responsible for rendering them instead.
if (this.renderInteractiveForms) {
return Promise.resolve(operatorList);
}
if (this.appearance) {
return Annotation.prototype.getOperatorList.call(this, evaluator, task);
}
var opList = new OperatorList();
var data = this.data;
// Even if there is an appearance stream, ignore it. This is the
// behaviour used by Adobe Reader.
if (!data.defaultAppearance) {
return Promise.resolve(opList);
if (!this.data.defaultAppearance) {
return Promise.resolve(operatorList);
}
var stream = new Stream(stringToBytes(data.defaultAppearance));
return evaluator.getOperatorList(stream, task,
this.fieldResources, opList).
var stream = new Stream(stringToBytes(this.data.defaultAppearance));
return evaluator.getOperatorList(stream, task, this.fieldResources,
operatorList).
then(function () {
return opList;
return operatorList;
});
}
});
@ -41282,7 +41383,8 @@ var Page = (function PageClosure() { @@ -41282,7 +41383,8 @@ var Page = (function PageClosure() {
}.bind(this));
},
getOperatorList: function Page_getOperatorList(handler, task, intent) {
getOperatorList: function Page_getOperatorList(handler, task, intent,
renderInteractiveForms) {
var self = this;
var pdfManager = this.pdfManager;
@ -41322,6 +41424,8 @@ var Page = (function PageClosure() { @@ -41322,6 +41424,8 @@ var Page = (function PageClosure() {
});
});
this.renderInteractiveForms = renderInteractiveForms;
var annotationsPromise = pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(
function(datas) {
@ -41405,7 +41509,8 @@ var Page = (function PageClosure() { @@ -41405,7 +41509,8 @@ var Page = (function PageClosure() {
var annotationRef = annotationRefs[i];
var annotation = annotationFactory.create(this.xref, annotationRef,
this.uniquePrefix,
this.idCounters);
this.idCounters,
this.renderInteractiveForms);
if (annotation) {
annotations.push(annotation);
}
@ -42592,7 +42697,8 @@ var WorkerMessageHandler = { @@ -42592,7 +42697,8 @@ var WorkerMessageHandler = {
var pageNum = pageIndex + 1;
var start = Date.now();
// Pre compile the pdf page and fetch the fonts/images.
page.getOperatorList(handler, task, data.intent).then(
page.getOperatorList(handler, task, data.intent,
data.renderInteractiveForms).then(
function(operatorList) {
finishWorkerTask(task);

2
package.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.5.458",
"version": "1.5.477",
"main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.",
"keywords": [

22
web/pdf_viewer.css

@ -110,7 +110,8 @@ @@ -110,7 +110,8 @@
cursor: pointer;
}
.annotationLayer .textWidgetAnnotation input {
.annotationLayer .textWidgetAnnotation input,
.annotationLayer .textWidgetAnnotation textarea {
background-color: rgba(0, 54, 255, 0.13);
border: 1px solid transparent;
box-sizing: border-box;
@ -121,11 +122,26 @@ @@ -121,11 +122,26 @@
width: 100%;
}
.annotationLayer .textWidgetAnnotation input:hover {
.annotationLayer .textWidgetAnnotation textarea {
font: message-box;
font-size: 9px;
resize: none;
}
.annotationLayer .textWidgetAnnotation input[disabled],
.annotationLayer .textWidgetAnnotation textarea[disabled] {
background: none;
border: 1px solid transparent;
cursor: not-allowed;
}
.annotationLayer .textWidgetAnnotation input:hover,
.annotationLayer .textWidgetAnnotation textarea:hover {
border: 1px solid #000;
}
.annotationLayer .textWidgetAnnotation input:focus {
.annotationLayer .textWidgetAnnotation input:focus,
.annotationLayer .textWidgetAnnotation textarea:focus {
background: none;
border: 1px solid transparent;
}

26
web/pdf_viewer.js

@ -2285,6 +2285,8 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms @@ -2285,6 +2285,8 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms
* @property {IPDFAnnotationLayerFactory} annotationLayerFactory
* @property {boolean} enhanceTextSelection - Turns on the text selection
* enhancement. The default is `false`.
* @property {boolean} renderInteractiveForms - Turns on rendering of
* interactive form elements. The default is `false`.
*/
/**
@ -2305,6 +2307,7 @@ var PDFPageView = (function PDFPageViewClosure() { @@ -2305,6 +2307,7 @@ var PDFPageView = (function PDFPageViewClosure() {
var textLayerFactory = options.textLayerFactory;
var annotationLayerFactory = options.annotationLayerFactory;
var enhanceTextSelection = options.enhanceTextSelection || false;
var renderInteractiveForms = options.renderInteractiveForms || false;
this.id = id;
this.renderingId = 'page' + id;
@ -2315,6 +2318,7 @@ var PDFPageView = (function PDFPageViewClosure() { @@ -2315,6 +2318,7 @@ var PDFPageView = (function PDFPageViewClosure() {
this.pdfPageRotate = defaultViewport.rotation;
this.hasRestrictedScaling = false;
this.enhanceTextSelection = enhanceTextSelection;
this.renderInteractiveForms = renderInteractiveForms;
this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
this.renderingQueue = renderingQueue;
@ -2729,6 +2733,7 @@ var PDFPageView = (function PDFPageViewClosure() { @@ -2729,6 +2733,7 @@ var PDFPageView = (function PDFPageViewClosure() {
canvasContext: ctx,
transform: transform,
viewport: this.viewport,
renderInteractiveForms: this.renderInteractiveForms,
// intent: 'default', // === 'display'
};
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
@ -2754,7 +2759,8 @@ var PDFPageView = (function PDFPageViewClosure() { @@ -2754,7 +2759,8 @@ var PDFPageView = (function PDFPageViewClosure() {
if (this.annotationLayerFactory) {
if (!this.annotationLayer) {
this.annotationLayer = this.annotationLayerFactory.
createAnnotationLayerBuilder(div, this.pdfPage);
createAnnotationLayerBuilder(div, this.pdfPage,
this.renderInteractiveForms);
}
this.annotationLayer.render(this.viewport, 'display');
}
@ -3217,6 +3223,7 @@ var SimpleLinkService = pdfLinkService.SimpleLinkService; @@ -3217,6 +3223,7 @@ var SimpleLinkService = pdfLinkService.SimpleLinkService;
* @typedef {Object} AnnotationLayerBuilderOptions
* @property {HTMLDivElement} pageDiv
* @property {PDFPage} pdfPage
* @property {boolean} renderInteractiveForms
* @property {IPDFLinkService} linkService
* @property {DownloadManager} downloadManager
*/
@ -3232,6 +3239,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() { @@ -3232,6 +3239,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
function AnnotationLayerBuilder(options) {
this.pageDiv = options.pageDiv;
this.pdfPage = options.pdfPage;
this.renderInteractiveForms = options.renderInteractiveForms;
this.linkService = options.linkService;
this.downloadManager = options.downloadManager;
@ -3258,9 +3266,9 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() { @@ -3258,9 +3266,9 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
div: self.div,
annotations: annotations,
page: self.pdfPage,
renderInteractiveForms: self.renderInteractiveForms,
linkService: self.linkService,
downloadManager: self.downloadManager,
renderInteractiveForms: pdfjsLib.PDFJS.renderInteractiveForms,
};
if (self.div) {
@ -3307,12 +3315,15 @@ DefaultAnnotationLayerFactory.prototype = { @@ -3307,12 +3315,15 @@ DefaultAnnotationLayerFactory.prototype = {
/**
* @param {HTMLDivElement} pageDiv
* @param {PDFPage} pdfPage
* @param {boolean} renderInteractiveForms
* @returns {AnnotationLayerBuilder}
*/
createAnnotationLayerBuilder: function (pageDiv, pdfPage) {
createAnnotationLayerBuilder: function (pageDiv, pdfPage,
renderInteractiveForms) {
return new AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
renderInteractiveForms: renderInteractiveForms,
linkService: new SimpleLinkService(),
});
}
@ -3374,6 +3385,8 @@ var DEFAULT_CACHE_SIZE = 10; @@ -3374,6 +3385,8 @@ var DEFAULT_CACHE_SIZE = 10;
* around the pages. The default is false.
* @property {boolean} enhanceTextSelection - (optional) Enables the improved
* text selection behaviour. The default is `false`.
* @property {boolean} renderInteractiveForms - (optional) Enables rendering of
* interactive form elements. The default is `false`.
*/
/**
@ -3426,6 +3439,7 @@ var PDFViewer = (function pdfViewer() { @@ -3426,6 +3439,7 @@ var PDFViewer = (function pdfViewer() {
this.downloadManager = options.downloadManager || null;
this.removePageBorders = options.removePageBorders || false;
this.enhanceTextSelection = options.enhanceTextSelection || false;
this.renderInteractiveForms = options.renderInteractiveForms || false;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
@ -3653,6 +3667,7 @@ var PDFViewer = (function pdfViewer() { @@ -3653,6 +3667,7 @@ var PDFViewer = (function pdfViewer() {
textLayerFactory: textLayerFactory,
annotationLayerFactory: this,
enhanceTextSelection: this.enhanceTextSelection,
renderInteractiveForms: this.renderInteractiveForms,
});
bindOnAfterAndBeforeDraw(pageView);
this._pages.push(pageView);
@ -4150,12 +4165,15 @@ var PDFViewer = (function pdfViewer() { @@ -4150,12 +4165,15 @@ var PDFViewer = (function pdfViewer() {
/**
* @param {HTMLDivElement} pageDiv
* @param {PDFPage} pdfPage
* @param {boolean} renderInteractiveForms
* @returns {AnnotationLayerBuilder}
*/
createAnnotationLayerBuilder: function (pageDiv, pdfPage) {
createAnnotationLayerBuilder: function (pageDiv, pdfPage,
renderInteractiveForms) {
return new AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
renderInteractiveForms: renderInteractiveForms,
linkService: this.linkService,
downloadManager: this.downloadManager
});

Loading…
Cancel
Save