diff --git a/src/core/annotation.js b/src/core/annotation.js index 41457cb60..725353e4f 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -16,8 +16,8 @@ */ /* globals PDFJS, Util, isDict, isName, stringToPDFString, warn, Dict, Stream, stringToBytes, assert, Promise, isArray, ObjectLoader, OperatorList, - isValidUrl, OPS, createPromiseCapability, AnnotationType, - stringToUTF8String */ + isValidUrl, OPS, createPromiseCapability, AnnotationType, + stringToUTF8String, AnnotationBorderStyleType */ 'use strict'; @@ -148,6 +148,41 @@ var Annotation = (function AnnotationClosure() { } Annotation.prototype = { + /** + * Set the border style (as AnnotationBorderStyle object). + * + * @public + * @memberof Annotation + * @param {Dict} borderStyle - The border style dictionary + */ + setBorderStyle: function Annotation_setBorderStyle(borderStyle) { + if (!isDict(borderStyle)) { + return; + } + if (borderStyle.has('BS')) { + var dict = borderStyle.get('BS'); + var dictType; + + if (!dict.has('Type') || (isName(dictType = dict.get('Type')) && + dictType.name === 'Border')) { + this.borderStyle.setWidth(dict.get('W')); + this.borderStyle.setStyle(dict.get('S')); + this.borderStyle.setDashArray(dict.get('D')); + } + } else if (borderStyle.has('Border')) { + var array = borderStyle.get('Border'); + if (isArray(array) && array.length >= 3) { + this.borderStyle.setHorizontalCornerRadius(array[0]); + this.borderStyle.setVerticalCornerRadius(array[1]); + this.borderStyle.setWidth(array[2]); + this.borderStyle.setStyle('S'); + + if (array.length === 4) { // Dash array available + this.borderStyle.setDashArray(array[3]); + } + } + } + }, getData: function Annotation_getData() { return this.data;