|
@@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfCombined = {}));
|
|
|
// Use strict in our context only - users might not want it
|
|
|
'use strict';
|
|
|
|
|
|
-var pdfjsVersion = '1.4.87';
|
|
|
-var pdfjsBuild = 'c53581f';
|
|
|
+var pdfjsVersion = '1.4.91';
|
|
|
+var pdfjsBuild = '41efb92';
|
|
|
|
|
|
var pdfjsFilePath =
|
|
|
typeof document !== 'undefined' && document.currentScript ?
|
|
@@ -2692,6 +2692,17 @@ var UNSUPPORTED_FEATURES = PDFJS.UNSUPPORTED_FEATURES = {
|
|
|
font: 'font'
|
|
|
};
|
|
|
|
|
|
+// Gets the file name from a given URL.
|
|
|
+function getFilenameFromUrl(url) {
|
|
|
+ var anchor = url.indexOf('#');
|
|
|
+ var query = url.indexOf('?');
|
|
|
+ var end = Math.min(
|
|
|
+ anchor > 0 ? anchor : url.length,
|
|
|
+ query > 0 ? query : url.length);
|
|
|
+ return url.substring(url.lastIndexOf('/', end) + 1, end);
|
|
|
+}
|
|
|
+PDFJS.getFilenameFromUrl = getFilenameFromUrl;
|
|
|
+
|
|
|
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
|
|
|
// absolute URL, it will be returned as is.
|
|
|
function combineUrl(baseUrl, url) {
|
|
@@ -4763,6 +4774,7 @@ exports.combineUrl = combineUrl;
|
|
|
exports.createPromiseCapability = createPromiseCapability;
|
|
|
exports.deprecated = deprecated;
|
|
|
exports.error = error;
|
|
|
+exports.getFilenameFromUrl = getFilenameFromUrl;
|
|
|
exports.getLookupTableFactory = getLookupTableFactory;
|
|
|
exports.info = info;
|
|
|
exports.isArray = isArray;
|
|
@@ -18412,6 +18424,7 @@ var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
|
|
|
var AnnotationType = sharedUtil.AnnotationType;
|
|
|
var Util = sharedUtil.Util;
|
|
|
var addLinkAttributes = sharedUtil.addLinkAttributes;
|
|
|
+var getFilenameFromUrl = sharedUtil.getFilenameFromUrl;
|
|
|
var warn = sharedUtil.warn;
|
|
|
var CustomStyle = displayDOMUtils.CustomStyle;
|
|
|
|
|
@@ -18422,6 +18435,7 @@ var CustomStyle = displayDOMUtils.CustomStyle;
|
|
|
* @property {PDFPage} page
|
|
|
* @property {PageViewport} viewport
|
|
|
* @property {IPDFLinkService} linkService
|
|
|
+ * @property {DownloadManager} downloadManager
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -18463,6 +18477,9 @@ AnnotationElementFactory.prototype =
|
|
|
case AnnotationType.STRIKEOUT:
|
|
|
return new StrikeOutAnnotationElement(parameters);
|
|
|
|
|
|
+ case AnnotationType.FILEATTACHMENT:
|
|
|
+ return new FileAttachmentAnnotationElement(parameters);
|
|
|
+
|
|
|
default:
|
|
|
return new AnnotationElement(parameters);
|
|
|
}
|
|
@@ -18481,6 +18498,7 @@ var AnnotationElement = (function AnnotationElementClosure() {
|
|
|
this.page = parameters.page;
|
|
|
this.viewport = parameters.viewport;
|
|
|
this.linkService = parameters.linkService;
|
|
|
+ this.downloadManager = parameters.downloadManager;
|
|
|
|
|
|
if (isRenderable) {
|
|
|
this.container = this._createContainer();
|
|
@@ -19101,6 +19119,76 @@ var StrikeOutAnnotationElement = (
|
|
|
return StrikeOutAnnotationElement;
|
|
|
})();
|
|
|
|
|
|
+/**
|
|
|
+ * @class
|
|
|
+ * @alias FileAttachmentAnnotationElement
|
|
|
+ */
|
|
|
+var FileAttachmentAnnotationElement = (
|
|
|
+ function FileAttachmentAnnotationElementClosure() {
|
|
|
+ function FileAttachmentAnnotationElement(parameters) {
|
|
|
+ AnnotationElement.call(this, parameters, true);
|
|
|
+
|
|
|
+ this.filename = getFilenameFromUrl(parameters.data.file.filename);
|
|
|
+ this.content = parameters.data.file.content;
|
|
|
+ }
|
|
|
+
|
|
|
+ Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
|
|
|
+ /**
|
|
|
+ * Render the file attachment annotation's HTML element in the empty
|
|
|
+ * container.
|
|
|
+ *
|
|
|
+ * @public
|
|
|
+ * @memberof FileAttachmentAnnotationElement
|
|
|
+ * @returns {HTMLSectionElement}
|
|
|
+ */
|
|
|
+ render: function FileAttachmentAnnotationElement_render() {
|
|
|
+ this.container.className = 'fileAttachmentAnnotation';
|
|
|
+
|
|
|
+ var trigger = document.createElement('div');
|
|
|
+ trigger.style.height = this.container.style.height;
|
|
|
+ trigger.style.width = this.container.style.width;
|
|
|
+ trigger.addEventListener('dblclick', this._download.bind(this));
|
|
|
+
|
|
|
+ if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
|
|
|
+ var popupElement = new PopupElement({
|
|
|
+ container: this.container,
|
|
|
+ trigger: trigger,
|
|
|
+ color: this.data.color,
|
|
|
+ title: this.data.title,
|
|
|
+ contents: this.data.contents,
|
|
|
+ hideWrapper: true
|
|
|
+ });
|
|
|
+ var popup = popupElement.render();
|
|
|
+
|
|
|
+ // Position the popup next to the FileAttachment annotation's
|
|
|
+ // container.
|
|
|
+ popup.style.left = this.container.style.width;
|
|
|
+
|
|
|
+ this.container.appendChild(popup);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.container.appendChild(trigger);
|
|
|
+ return this.container;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Download the file attachment associated with this annotation.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @memberof FileAttachmentAnnotationElement
|
|
|
+ */
|
|
|
+ _download: function FileAttachmentAnnotationElement_download() {
|
|
|
+ if (!this.downloadManager) {
|
|
|
+ warn('Download cannot be started due to unavailable download manager');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.downloadManager.downloadData(this.content, this.filename, '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return FileAttachmentAnnotationElement;
|
|
|
+})();
|
|
|
+
|
|
|
/**
|
|
|
* @typedef {Object} AnnotationLayerParameters
|
|
|
* @property {PageViewport} viewport
|
|
@@ -19137,7 +19225,8 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
|
|
|
layer: parameters.div,
|
|
|
page: parameters.page,
|
|
|
viewport: parameters.viewport,
|
|
|
- linkService: parameters.linkService
|
|
|
+ linkService: parameters.linkService,
|
|
|
+ downloadManager: parameters.downloadManager
|
|
|
};
|
|
|
var element = annotationElementFactory.create(properties);
|
|
|
if (element.isRenderable) {
|
|
@@ -44052,6 +44141,7 @@ var ObjectLoader = (function() {
|
|
|
exports.Catalog = Catalog;
|
|
|
exports.ObjectLoader = ObjectLoader;
|
|
|
exports.XRef = XRef;
|
|
|
+exports.FileSpec = FileSpec;
|
|
|
}));
|
|
|
|
|
|
|
|
@@ -47862,6 +47952,7 @@ var isName = corePrimitives.isName;
|
|
|
var Stream = coreStream.Stream;
|
|
|
var ColorSpace = coreColorSpace.ColorSpace;
|
|
|
var ObjectLoader = coreObj.ObjectLoader;
|
|
|
+var FileSpec = coreObj.FileSpec;
|
|
|
var OperatorList = coreEvaluator.OperatorList;
|
|
|
|
|
|
/**
|
|
@@ -47887,6 +47978,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
|
|
|
|
|
// Return the right annotation object based on the subtype and field type.
|
|
|
var parameters = {
|
|
|
+ xref: xref,
|
|
|
dict: dict,
|
|
|
ref: ref
|
|
|
};
|
|
@@ -47920,6 +48012,9 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
|
|
case 'StrikeOut':
|
|
|
return new StrikeOutAnnotation(parameters);
|
|
|
|
|
|
+ case 'FileAttachment':
|
|
|
+ return new FileAttachmentAnnotation(parameters);
|
|
|
+
|
|
|
default:
|
|
|
warn('Unimplemented annotation type "' + subtype + '", ' +
|
|
|
'falling back to base annotation');
|
|
@@ -48664,6 +48759,31 @@ var StrikeOutAnnotation = (function StrikeOutAnnotationClosure() {
|
|
|
return StrikeOutAnnotation;
|
|
|
})();
|
|
|
|
|
|
+var FileAttachmentAnnotation = (function FileAttachmentAnnotationClosure() {
|
|
|
+ function FileAttachmentAnnotation(parameters) {
|
|
|
+ Annotation.call(this, parameters);
|
|
|
+
|
|
|
+ var dict = parameters.dict;
|
|
|
+ var file = new FileSpec(dict.get('FS'), parameters.xref);
|
|
|
+
|
|
|
+ this.data.annotationType = AnnotationType.FILEATTACHMENT;
|
|
|
+ this.data.file = file.serializable;
|
|
|
+
|
|
|
+ if (!dict.has('C')) {
|
|
|
+ // Fall back to the default background color.
|
|
|
+ this.data.color = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.data.hasPopup = dict.has('Popup');
|
|
|
+ this.data.title = stringToPDFString(dict.get('T') || '');
|
|
|
+ this.data.contents = stringToPDFString(dict.get('Contents') || '');
|
|
|
+ }
|
|
|
+
|
|
|
+ Util.inherit(FileAttachmentAnnotation, Annotation, {});
|
|
|
+
|
|
|
+ return FileAttachmentAnnotation;
|
|
|
+})();
|
|
|
+
|
|
|
exports.Annotation = Annotation;
|
|
|
exports.AnnotationBorderStyle = AnnotationBorderStyle;
|
|
|
exports.AnnotationFactory = AnnotationFactory;
|