Browse Source

PDF.js version 1.8.186 - See mozilla/pdf.js@32e01cda960e8dd7af3badf9b7d47ae4e3904fe3

master v1.8.186
pdfjsbot 8 years ago
parent
commit
b3d83b6e72
  1. 2
      bower.json
  2. 86
      build/pdf.combined.js
  3. 67
      build/pdf.js
  4. 12
      build/pdf.min.js
  5. 23
      build/pdf.worker.js
  6. 2
      build/pdf.worker.min.js
  7. 19
      lib/core/annotation.js
  8. 55
      lib/display/annotation_layer.js
  9. 4
      lib/display/api.js
  10. 4
      lib/display/global.js
  11. 4
      lib/pdf.js
  12. 4
      lib/pdf.worker.js
  13. 17
      lib/test/unit/annotation_spec.js
  14. 2
      package.json
  15. 1
      web/pdf_viewer.css

2
bower.json

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

86
build/pdf.combined.js

@ -10906,6 +10906,8 @@ AnnotationElementFactory.prototype = { @@ -10906,6 +10906,8 @@ AnnotationElementFactory.prototype = {
return new WidgetAnnotationElement(parameters);
case AnnotationType.POPUP:
return new PopupAnnotationElement(parameters);
case AnnotationType.LINE:
return new LineAnnotationElement(parameters);
case AnnotationType.HIGHLIGHT:
return new HighlightAnnotationElement(parameters);
case AnnotationType.UNDERLINE:
@ -10922,7 +10924,7 @@ AnnotationElementFactory.prototype = { @@ -10922,7 +10924,7 @@ AnnotationElementFactory.prototype = {
}
};
var AnnotationElement = function AnnotationElementClosure() {
function AnnotationElement(parameters, isRenderable) {
function AnnotationElement(parameters, isRenderable, ignoreBorder) {
this.isRenderable = isRenderable || false;
this.data = parameters.data;
this.layer = parameters.layer;
@ -10933,11 +10935,11 @@ var AnnotationElement = function AnnotationElementClosure() { @@ -10933,11 +10935,11 @@ var AnnotationElement = function AnnotationElementClosure() {
this.imageResourcesPath = parameters.imageResourcesPath;
this.renderInteractiveForms = parameters.renderInteractiveForms;
if (isRenderable) {
this.container = this._createContainer();
this.container = this._createContainer(ignoreBorder);
}
}
AnnotationElement.prototype = {
_createContainer: function AnnotationElement_createContainer() {
_createContainer: function AnnotationElement_createContainer(ignoreBorder) {
var data = this.data,
page = this.page,
viewport = this.viewport;
@ -10948,7 +10950,7 @@ var AnnotationElement = function AnnotationElementClosure() { @@ -10948,7 +10950,7 @@ var AnnotationElement = function AnnotationElementClosure() {
var rect = Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
if (data.borderStyle.width > 0) {
if (!ignoreBorder && data.borderStyle.width > 0) {
container.style.borderWidth = data.borderStyle.width + 'px';
if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
width = width - 2 * data.borderStyle.width;
@ -11231,6 +11233,7 @@ var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosur @@ -11231,6 +11233,7 @@ var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosur
return ChoiceWidgetAnnotationElement;
}();
var PopupAnnotationElement = function PopupAnnotationElementClosure() {
var IGNORE_TYPES = ['Line'];
function PopupAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
@ -11238,6 +11241,9 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() { @@ -11238,6 +11241,9 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() {
Util.inherit(PopupAnnotationElement, AnnotationElement, {
render: function PopupAnnotationElement_render() {
this.container.className = 'popupAnnotation';
if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) {
return this.container;
}
var selector = '[data-annotation-id="' + this.data.parentId + '"]';
var parentElement = this.layer.querySelector(selector);
if (!parentElement) {
@ -11338,10 +11344,43 @@ var PopupElement = function PopupElementClosure() { @@ -11338,10 +11344,43 @@ var PopupElement = function PopupElementClosure() {
};
return PopupElement;
}();
var LineAnnotationElement = function LineAnnotationElementClosure() {
var SVG_NS = 'http://www.w3.org/2000/svg';
function LineAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(LineAnnotationElement, AnnotationElement, {
render: function LineAnnotationElement_render() {
this.container.className = 'lineAnnotation';
var data = this.data;
var width = data.rect[2] - data.rect[0];
var height = data.rect[3] - data.rect[1];
var svg = document.createElementNS(SVG_NS, 'svg:svg');
svg.setAttributeNS(null, 'version', '1.1');
svg.setAttributeNS(null, 'width', width + 'px');
svg.setAttributeNS(null, 'height', height + 'px');
svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
svg.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height);
var line = document.createElementNS(SVG_NS, 'svg:line');
line.setAttributeNS(null, 'x1', data.rect[2] - data.lineCoordinates[0]);
line.setAttributeNS(null, 'y1', data.rect[3] - data.lineCoordinates[1]);
line.setAttributeNS(null, 'x2', data.rect[2] - data.lineCoordinates[2]);
line.setAttributeNS(null, 'y2', data.rect[3] - data.lineCoordinates[3]);
line.setAttributeNS(null, 'stroke-width', data.borderStyle.width);
line.setAttributeNS(null, 'stroke', 'transparent');
svg.appendChild(line);
this.container.append(svg);
this._createPopup(this.container, line, this.data);
return this.container;
}
});
return LineAnnotationElement;
}();
var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
function HighlightAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(HighlightAnnotationElement, AnnotationElement, {
render: function HighlightAnnotationElement_render() {
@ -11357,7 +11396,7 @@ var HighlightAnnotationElement = function HighlightAnnotationElementClosure() { @@ -11357,7 +11396,7 @@ var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
function UnderlineAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
render: function UnderlineAnnotationElement_render() {
@ -11373,7 +11412,7 @@ var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() { @@ -11373,7 +11412,7 @@ var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
function SquigglyAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
render: function SquigglyAnnotationElement_render() {
@ -11389,7 +11428,7 @@ var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() { @@ -11389,7 +11428,7 @@ var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
function StrikeOutAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
render: function StrikeOutAnnotationElement_render() {
@ -12737,8 +12776,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -12737,8 +12776,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}
};
}();
exports.version = '1.8.183';
exports.build = '22744655';
exports.version = '1.8.186';
exports.build = '32e01cda';
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker;
@ -27971,8 +28010,8 @@ if (!globalScope.PDFJS) { @@ -27971,8 +28010,8 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {};
}
var PDFJS = globalScope.PDFJS;
PDFJS.version = '1.8.183';
PDFJS.build = '22744655';
PDFJS.version = '1.8.186';
PDFJS.build = '32e01cda';
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
sharedUtil.setVerbosityLevel(PDFJS.verbosity);
@ -28152,6 +28191,8 @@ AnnotationFactory.prototype = { @@ -28152,6 +28191,8 @@ AnnotationFactory.prototype = {
return new WidgetAnnotation(parameters);
case 'Popup':
return new PopupAnnotation(parameters);
case 'Line':
return new LineAnnotation(parameters);
case 'Highlight':
return new HighlightAnnotation(parameters);
case 'Underline':
@ -28646,6 +28687,8 @@ var PopupAnnotation = function PopupAnnotationClosure() { @@ -28646,6 +28687,8 @@ var PopupAnnotation = function PopupAnnotationClosure() {
warn('Popup annotation has a missing or invalid parent annotation.');
return;
}
var parentSubtype = parentItem.get('Subtype');
this.data.parentType = isName(parentSubtype) ? parentSubtype.name : null;
this.data.parentId = dict.getRaw('Parent').toString();
this.data.title = stringToPDFString(parentItem.get('T') || '');
this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
@ -28665,12 +28708,22 @@ var PopupAnnotation = function PopupAnnotationClosure() { @@ -28665,12 +28708,22 @@ var PopupAnnotation = function PopupAnnotationClosure() {
Util.inherit(PopupAnnotation, Annotation, {});
return PopupAnnotation;
}();
var LineAnnotation = function LineAnnotationClosure() {
function LineAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.LINE;
var dict = parameters.dict;
this.data.lineCoordinates = Util.normalizeRect(dict.getArray('L'));
this._preparePopup(dict);
}
Util.inherit(LineAnnotation, Annotation, {});
return LineAnnotation;
}();
var HighlightAnnotation = function HighlightAnnotationClosure() {
function HighlightAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.HIGHLIGHT;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(HighlightAnnotation, Annotation, {});
return HighlightAnnotation;
@ -28680,7 +28733,6 @@ var UnderlineAnnotation = function UnderlineAnnotationClosure() { @@ -28680,7 +28733,6 @@ var UnderlineAnnotation = function UnderlineAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.UNDERLINE;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(UnderlineAnnotation, Annotation, {});
return UnderlineAnnotation;
@ -28690,7 +28742,6 @@ var SquigglyAnnotation = function SquigglyAnnotationClosure() { @@ -28690,7 +28742,6 @@ var SquigglyAnnotation = function SquigglyAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.SQUIGGLY;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(SquigglyAnnotation, Annotation, {});
return SquigglyAnnotation;
@ -28700,7 +28751,6 @@ var StrikeOutAnnotation = function StrikeOutAnnotationClosure() { @@ -28700,7 +28751,6 @@ var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.STRIKEOUT;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(StrikeOutAnnotation, Annotation, {});
return StrikeOutAnnotation;
@ -43498,8 +43548,8 @@ exports.TilingPattern = TilingPattern; @@ -43498,8 +43548,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.183';
var pdfjsBuild = '22744655';
var pdfjsVersion = '1.8.186';
var pdfjsBuild = '32e01cda';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
var pdfjsDisplayAPI = __w_pdfjs_require__(10);

67
build/pdf.js

@ -1512,6 +1512,8 @@ AnnotationElementFactory.prototype = { @@ -1512,6 +1512,8 @@ AnnotationElementFactory.prototype = {
return new WidgetAnnotationElement(parameters);
case AnnotationType.POPUP:
return new PopupAnnotationElement(parameters);
case AnnotationType.LINE:
return new LineAnnotationElement(parameters);
case AnnotationType.HIGHLIGHT:
return new HighlightAnnotationElement(parameters);
case AnnotationType.UNDERLINE:
@ -1528,7 +1530,7 @@ AnnotationElementFactory.prototype = { @@ -1528,7 +1530,7 @@ AnnotationElementFactory.prototype = {
}
};
var AnnotationElement = function AnnotationElementClosure() {
function AnnotationElement(parameters, isRenderable) {
function AnnotationElement(parameters, isRenderable, ignoreBorder) {
this.isRenderable = isRenderable || false;
this.data = parameters.data;
this.layer = parameters.layer;
@ -1539,11 +1541,11 @@ var AnnotationElement = function AnnotationElementClosure() { @@ -1539,11 +1541,11 @@ var AnnotationElement = function AnnotationElementClosure() {
this.imageResourcesPath = parameters.imageResourcesPath;
this.renderInteractiveForms = parameters.renderInteractiveForms;
if (isRenderable) {
this.container = this._createContainer();
this.container = this._createContainer(ignoreBorder);
}
}
AnnotationElement.prototype = {
_createContainer: function AnnotationElement_createContainer() {
_createContainer: function AnnotationElement_createContainer(ignoreBorder) {
var data = this.data,
page = this.page,
viewport = this.viewport;
@ -1554,7 +1556,7 @@ var AnnotationElement = function AnnotationElementClosure() { @@ -1554,7 +1556,7 @@ var AnnotationElement = function AnnotationElementClosure() {
var rect = Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
if (data.borderStyle.width > 0) {
if (!ignoreBorder && data.borderStyle.width > 0) {
container.style.borderWidth = data.borderStyle.width + 'px';
if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
width = width - 2 * data.borderStyle.width;
@ -1837,6 +1839,7 @@ var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosur @@ -1837,6 +1839,7 @@ var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosur
return ChoiceWidgetAnnotationElement;
}();
var PopupAnnotationElement = function PopupAnnotationElementClosure() {
var IGNORE_TYPES = ['Line'];
function PopupAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
@ -1844,6 +1847,9 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() { @@ -1844,6 +1847,9 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() {
Util.inherit(PopupAnnotationElement, AnnotationElement, {
render: function PopupAnnotationElement_render() {
this.container.className = 'popupAnnotation';
if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) {
return this.container;
}
var selector = '[data-annotation-id="' + this.data.parentId + '"]';
var parentElement = this.layer.querySelector(selector);
if (!parentElement) {
@ -1944,10 +1950,43 @@ var PopupElement = function PopupElementClosure() { @@ -1944,10 +1950,43 @@ var PopupElement = function PopupElementClosure() {
};
return PopupElement;
}();
var LineAnnotationElement = function LineAnnotationElementClosure() {
var SVG_NS = 'http://www.w3.org/2000/svg';
function LineAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(LineAnnotationElement, AnnotationElement, {
render: function LineAnnotationElement_render() {
this.container.className = 'lineAnnotation';
var data = this.data;
var width = data.rect[2] - data.rect[0];
var height = data.rect[3] - data.rect[1];
var svg = document.createElementNS(SVG_NS, 'svg:svg');
svg.setAttributeNS(null, 'version', '1.1');
svg.setAttributeNS(null, 'width', width + 'px');
svg.setAttributeNS(null, 'height', height + 'px');
svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
svg.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height);
var line = document.createElementNS(SVG_NS, 'svg:line');
line.setAttributeNS(null, 'x1', data.rect[2] - data.lineCoordinates[0]);
line.setAttributeNS(null, 'y1', data.rect[3] - data.lineCoordinates[1]);
line.setAttributeNS(null, 'x2', data.rect[2] - data.lineCoordinates[2]);
line.setAttributeNS(null, 'y2', data.rect[3] - data.lineCoordinates[3]);
line.setAttributeNS(null, 'stroke-width', data.borderStyle.width);
line.setAttributeNS(null, 'stroke', 'transparent');
svg.appendChild(line);
this.container.append(svg);
this._createPopup(this.container, line, this.data);
return this.container;
}
});
return LineAnnotationElement;
}();
var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
function HighlightAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(HighlightAnnotationElement, AnnotationElement, {
render: function HighlightAnnotationElement_render() {
@ -1963,7 +2002,7 @@ var HighlightAnnotationElement = function HighlightAnnotationElementClosure() { @@ -1963,7 +2002,7 @@ var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
function UnderlineAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
render: function UnderlineAnnotationElement_render() {
@ -1979,7 +2018,7 @@ var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() { @@ -1979,7 +2018,7 @@ var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
function SquigglyAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
render: function SquigglyAnnotationElement_render() {
@ -1995,7 +2034,7 @@ var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() { @@ -1995,7 +2034,7 @@ var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
function StrikeOutAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
render: function StrikeOutAnnotationElement_render() {
@ -3451,8 +3490,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -3451,8 +3490,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}
};
}();
exports.version = '1.8.183';
exports.build = '22744655';
exports.version = '1.8.186';
exports.build = '32e01cda';
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker;
@ -5391,8 +5430,8 @@ if (!globalScope.PDFJS) { @@ -5391,8 +5430,8 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {};
}
var PDFJS = globalScope.PDFJS;
PDFJS.version = '1.8.183';
PDFJS.build = '22744655';
PDFJS.version = '1.8.186';
PDFJS.build = '32e01cda';
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
sharedUtil.setVerbosityLevel(PDFJS.verbosity);
@ -7893,8 +7932,8 @@ exports.TilingPattern = TilingPattern; @@ -7893,8 +7932,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.183';
var pdfjsBuild = '22744655';
var pdfjsVersion = '1.8.186';
var pdfjsBuild = '32e01cda';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
var pdfjsDisplayAPI = __w_pdfjs_require__(3);

12
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

23
build/pdf.worker.js vendored

@ -24481,6 +24481,8 @@ AnnotationFactory.prototype = { @@ -24481,6 +24481,8 @@ AnnotationFactory.prototype = {
return new WidgetAnnotation(parameters);
case 'Popup':
return new PopupAnnotation(parameters);
case 'Line':
return new LineAnnotation(parameters);
case 'Highlight':
return new HighlightAnnotation(parameters);
case 'Underline':
@ -24975,6 +24977,8 @@ var PopupAnnotation = function PopupAnnotationClosure() { @@ -24975,6 +24977,8 @@ var PopupAnnotation = function PopupAnnotationClosure() {
warn('Popup annotation has a missing or invalid parent annotation.');
return;
}
var parentSubtype = parentItem.get('Subtype');
this.data.parentType = isName(parentSubtype) ? parentSubtype.name : null;
this.data.parentId = dict.getRaw('Parent').toString();
this.data.title = stringToPDFString(parentItem.get('T') || '');
this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
@ -24994,12 +24998,22 @@ var PopupAnnotation = function PopupAnnotationClosure() { @@ -24994,12 +24998,22 @@ var PopupAnnotation = function PopupAnnotationClosure() {
Util.inherit(PopupAnnotation, Annotation, {});
return PopupAnnotation;
}();
var LineAnnotation = function LineAnnotationClosure() {
function LineAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.LINE;
var dict = parameters.dict;
this.data.lineCoordinates = Util.normalizeRect(dict.getArray('L'));
this._preparePopup(dict);
}
Util.inherit(LineAnnotation, Annotation, {});
return LineAnnotation;
}();
var HighlightAnnotation = function HighlightAnnotationClosure() {
function HighlightAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.HIGHLIGHT;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(HighlightAnnotation, Annotation, {});
return HighlightAnnotation;
@ -25009,7 +25023,6 @@ var UnderlineAnnotation = function UnderlineAnnotationClosure() { @@ -25009,7 +25023,6 @@ var UnderlineAnnotation = function UnderlineAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.UNDERLINE;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(UnderlineAnnotation, Annotation, {});
return UnderlineAnnotation;
@ -25019,7 +25032,6 @@ var SquigglyAnnotation = function SquigglyAnnotationClosure() { @@ -25019,7 +25032,6 @@ var SquigglyAnnotation = function SquigglyAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.SQUIGGLY;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(SquigglyAnnotation, Annotation, {});
return SquigglyAnnotation;
@ -25029,7 +25041,6 @@ var StrikeOutAnnotation = function StrikeOutAnnotationClosure() { @@ -25029,7 +25041,6 @@ var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.STRIKEOUT;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(StrikeOutAnnotation, Annotation, {});
return StrikeOutAnnotation;
@ -36946,8 +36957,8 @@ exports.Type1Parser = Type1Parser; @@ -36946,8 +36957,8 @@ exports.Type1Parser = Type1Parser;
"use strict";
var pdfjsVersion = '1.8.183';
var pdfjsBuild = '22744655';
var pdfjsVersion = '1.8.186';
var pdfjsBuild = '32e01cda';
var pdfjsCoreWorker = __w_pdfjs_require__(8);
{
__w_pdfjs_require__(19);

2
build/pdf.worker.min.js vendored

File diff suppressed because one or more lines are too long

19
lib/core/annotation.js

@ -80,6 +80,8 @@ AnnotationFactory.prototype = { @@ -80,6 +80,8 @@ AnnotationFactory.prototype = {
return new WidgetAnnotation(parameters);
case 'Popup':
return new PopupAnnotation(parameters);
case 'Line':
return new LineAnnotation(parameters);
case 'Highlight':
return new HighlightAnnotation(parameters);
case 'Underline':
@ -574,6 +576,8 @@ var PopupAnnotation = function PopupAnnotationClosure() { @@ -574,6 +576,8 @@ var PopupAnnotation = function PopupAnnotationClosure() {
warn('Popup annotation has a missing or invalid parent annotation.');
return;
}
var parentSubtype = parentItem.get('Subtype');
this.data.parentType = isName(parentSubtype) ? parentSubtype.name : null;
this.data.parentId = dict.getRaw('Parent').toString();
this.data.title = stringToPDFString(parentItem.get('T') || '');
this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
@ -593,12 +597,22 @@ var PopupAnnotation = function PopupAnnotationClosure() { @@ -593,12 +597,22 @@ var PopupAnnotation = function PopupAnnotationClosure() {
Util.inherit(PopupAnnotation, Annotation, {});
return PopupAnnotation;
}();
var LineAnnotation = function LineAnnotationClosure() {
function LineAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.LINE;
var dict = parameters.dict;
this.data.lineCoordinates = Util.normalizeRect(dict.getArray('L'));
this._preparePopup(dict);
}
Util.inherit(LineAnnotation, Annotation, {});
return LineAnnotation;
}();
var HighlightAnnotation = function HighlightAnnotationClosure() {
function HighlightAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.HIGHLIGHT;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(HighlightAnnotation, Annotation, {});
return HighlightAnnotation;
@ -608,7 +622,6 @@ var UnderlineAnnotation = function UnderlineAnnotationClosure() { @@ -608,7 +622,6 @@ var UnderlineAnnotation = function UnderlineAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.UNDERLINE;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(UnderlineAnnotation, Annotation, {});
return UnderlineAnnotation;
@ -618,7 +631,6 @@ var SquigglyAnnotation = function SquigglyAnnotationClosure() { @@ -618,7 +631,6 @@ var SquigglyAnnotation = function SquigglyAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.SQUIGGLY;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(SquigglyAnnotation, Annotation, {});
return SquigglyAnnotation;
@ -628,7 +640,6 @@ var StrikeOutAnnotation = function StrikeOutAnnotationClosure() { @@ -628,7 +640,6 @@ var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.STRIKEOUT;
this._preparePopup(parameters.dict);
this.data.borderStyle.setWidth(0);
}
Util.inherit(StrikeOutAnnotation, Annotation, {});
return StrikeOutAnnotation;

55
lib/display/annotation_layer.js

@ -54,6 +54,8 @@ AnnotationElementFactory.prototype = { @@ -54,6 +54,8 @@ AnnotationElementFactory.prototype = {
return new WidgetAnnotationElement(parameters);
case AnnotationType.POPUP:
return new PopupAnnotationElement(parameters);
case AnnotationType.LINE:
return new LineAnnotationElement(parameters);
case AnnotationType.HIGHLIGHT:
return new HighlightAnnotationElement(parameters);
case AnnotationType.UNDERLINE:
@ -70,7 +72,7 @@ AnnotationElementFactory.prototype = { @@ -70,7 +72,7 @@ AnnotationElementFactory.prototype = {
}
};
var AnnotationElement = function AnnotationElementClosure() {
function AnnotationElement(parameters, isRenderable) {
function AnnotationElement(parameters, isRenderable, ignoreBorder) {
this.isRenderable = isRenderable || false;
this.data = parameters.data;
this.layer = parameters.layer;
@ -81,11 +83,11 @@ var AnnotationElement = function AnnotationElementClosure() { @@ -81,11 +83,11 @@ var AnnotationElement = function AnnotationElementClosure() {
this.imageResourcesPath = parameters.imageResourcesPath;
this.renderInteractiveForms = parameters.renderInteractiveForms;
if (isRenderable) {
this.container = this._createContainer();
this.container = this._createContainer(ignoreBorder);
}
}
AnnotationElement.prototype = {
_createContainer: function AnnotationElement_createContainer() {
_createContainer: function AnnotationElement_createContainer(ignoreBorder) {
var data = this.data,
page = this.page,
viewport = this.viewport;
@ -96,7 +98,7 @@ var AnnotationElement = function AnnotationElementClosure() { @@ -96,7 +98,7 @@ var AnnotationElement = function AnnotationElementClosure() {
var rect = Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
if (data.borderStyle.width > 0) {
if (!ignoreBorder && data.borderStyle.width > 0) {
container.style.borderWidth = data.borderStyle.width + 'px';
if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
width = width - 2 * data.borderStyle.width;
@ -379,6 +381,7 @@ var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosur @@ -379,6 +381,7 @@ var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosur
return ChoiceWidgetAnnotationElement;
}();
var PopupAnnotationElement = function PopupAnnotationElementClosure() {
var IGNORE_TYPES = ['Line'];
function PopupAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
@ -386,6 +389,9 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() { @@ -386,6 +389,9 @@ var PopupAnnotationElement = function PopupAnnotationElementClosure() {
Util.inherit(PopupAnnotationElement, AnnotationElement, {
render: function PopupAnnotationElement_render() {
this.container.className = 'popupAnnotation';
if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) {
return this.container;
}
var selector = '[data-annotation-id="' + this.data.parentId + '"]';
var parentElement = this.layer.querySelector(selector);
if (!parentElement) {
@ -486,10 +492,43 @@ var PopupElement = function PopupElementClosure() { @@ -486,10 +492,43 @@ var PopupElement = function PopupElementClosure() {
};
return PopupElement;
}();
var LineAnnotationElement = function LineAnnotationElementClosure() {
var SVG_NS = 'http://www.w3.org/2000/svg';
function LineAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(LineAnnotationElement, AnnotationElement, {
render: function LineAnnotationElement_render() {
this.container.className = 'lineAnnotation';
var data = this.data;
var width = data.rect[2] - data.rect[0];
var height = data.rect[3] - data.rect[1];
var svg = document.createElementNS(SVG_NS, 'svg:svg');
svg.setAttributeNS(null, 'version', '1.1');
svg.setAttributeNS(null, 'width', width + 'px');
svg.setAttributeNS(null, 'height', height + 'px');
svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
svg.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height);
var line = document.createElementNS(SVG_NS, 'svg:line');
line.setAttributeNS(null, 'x1', data.rect[2] - data.lineCoordinates[0]);
line.setAttributeNS(null, 'y1', data.rect[3] - data.lineCoordinates[1]);
line.setAttributeNS(null, 'x2', data.rect[2] - data.lineCoordinates[2]);
line.setAttributeNS(null, 'y2', data.rect[3] - data.lineCoordinates[3]);
line.setAttributeNS(null, 'stroke-width', data.borderStyle.width);
line.setAttributeNS(null, 'stroke', 'transparent');
svg.appendChild(line);
this.container.append(svg);
this._createPopup(this.container, line, this.data);
return this.container;
}
});
return LineAnnotationElement;
}();
var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
function HighlightAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(HighlightAnnotationElement, AnnotationElement, {
render: function HighlightAnnotationElement_render() {
@ -505,7 +544,7 @@ var HighlightAnnotationElement = function HighlightAnnotationElementClosure() { @@ -505,7 +544,7 @@ var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
function UnderlineAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
render: function UnderlineAnnotationElement_render() {
@ -521,7 +560,7 @@ var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() { @@ -521,7 +560,7 @@ var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
function SquigglyAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
render: function SquigglyAnnotationElement_render() {
@ -537,7 +576,7 @@ var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() { @@ -537,7 +576,7 @@ var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
function StrikeOutAnnotationElement(parameters) {
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
AnnotationElement.call(this, parameters, isRenderable);
AnnotationElement.call(this, parameters, isRenderable, true);
}
Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
render: function StrikeOutAnnotationElement_render() {

4
lib/display/api.js

@ -1377,8 +1377,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -1377,8 +1377,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}
};
}();
exports.version = '1.8.183';
exports.build = '22744655';
exports.version = '1.8.186';
exports.build = '32e01cda';
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker;

4
lib/display/global.js

@ -31,8 +31,8 @@ if (!globalScope.PDFJS) { @@ -31,8 +31,8 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {};
}
var PDFJS = globalScope.PDFJS;
PDFJS.version = '1.8.183';
PDFJS.build = '22744655';
PDFJS.version = '1.8.186';
PDFJS.build = '32e01cda';
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
sharedUtil.setVerbosityLevel(PDFJS.verbosity);

4
lib/pdf.js

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.183';
var pdfjsBuild = '22744655';
var pdfjsVersion = '1.8.186';
var pdfjsBuild = '32e01cda';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.183';
var pdfjsBuild = '22744655';
var pdfjsVersion = '1.8.186';
var pdfjsBuild = '32e01cda';
var pdfjsCoreWorker = require('./core/worker.js');
{
require('./core/network.js');

17
lib/test/unit/annotation_spec.js

@ -1001,6 +1001,23 @@ describe('annotation', function () { @@ -1001,6 +1001,23 @@ describe('annotation', function () {
expect(data.multiSelect).toEqual(true);
});
});
describe('LineAnnotation', function () {
it('should set the line coordinates', function () {
var lineDict = new Dict();
lineDict.set('Type', Name.get('Annot'));
lineDict.set('Subtype', Name.get('Line'));
lineDict.set('L', [1, 2, 3, 4]);
var lineRef = new Ref(122, 0);
var xref = new XRefMock([{
ref: lineRef,
data: lineDict
}]);
var annotation = annotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock);
var data = annotation.data;
expect(data.annotationType).toEqual(AnnotationType.LINE);
expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
});
});
describe('FileAttachmentAnnotation', function () {
it('should correctly parse a file attachment', function () {
var fileStream = new StringStream('<<\n' + '/Type /EmbeddedFile\n' + '/Subtype /text#2Fplain\n' + '>>\n' + 'stream\n' + 'Test attachment' + 'endstream\n');

2
package.json

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

1
web/pdf_viewer.css

@ -212,6 +212,7 @@ @@ -212,6 +212,7 @@
.annotationLayer .underlineAnnotation,
.annotationLayer .squigglyAnnotation,
.annotationLayer .strikeoutAnnotation,
.annotationLayer .lineAnnotation svg line,
.annotationLayer .fileAttachmentAnnotation {
cursor: pointer;
}

Loading…
Cancel
Save