Implement setBorderStyle for annotations

This commit is contained in:
Tim van der Meij 2014-12-25 20:24:28 +01:00
parent 88b2059ed9
commit 9ba4f74370

View File

@ -17,7 +17,7 @@
/* globals PDFJS, Util, isDict, isName, stringToPDFString, warn, Dict, Stream,
stringToBytes, assert, Promise, isArray, ObjectLoader, OperatorList,
isValidUrl, OPS, createPromiseCapability, AnnotationType,
stringToUTF8String */
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;