@ -15,7 +15,8 @@
@@ -15,7 +15,8 @@
/ * g l o b a l s P D F J S , U t i l , i s D i c t , i s N a m e , s t r i n g T o P D F S t r i n g , w a r n , D i c t , S t r e a m ,
stringToBytes , Promise , isArray , ObjectLoader , OperatorList ,
isValidUrl , OPS , createPromiseCapability , AnnotationType ,
stringToUTF8String , AnnotationBorderStyleType , ColorSpace * /
stringToUTF8String , AnnotationBorderStyleType , ColorSpace ,
AnnotationFlag , isInt * /
'use strict' ;
@ -121,7 +122,8 @@ var Annotation = (function AnnotationClosure() {
@@ -121,7 +122,8 @@ var Annotation = (function AnnotationClosure() {
var data = this . data = { } ;
data . subtype = dict . get ( 'Subtype' ) . name ;
data . annotationFlags = dict . get ( 'F' ) ;
this . setFlags ( dict . get ( 'F' ) ) ;
this . setRectangle ( dict . get ( 'Rect' ) ) ;
data . rect = this . rectangle ;
@ -138,6 +140,64 @@ var Annotation = (function AnnotationClosure() {
@@ -138,6 +140,64 @@ var Annotation = (function AnnotationClosure() {
}
Annotation . prototype = {
/ * *
* @ return { boolean }
* /
get viewable ( ) {
if ( this . flags ) {
return ! this . hasFlag ( AnnotationFlag . INVISIBLE ) &&
! this . hasFlag ( AnnotationFlag . HIDDEN ) &&
! this . hasFlag ( AnnotationFlag . NOVIEW ) ;
}
return true ;
} ,
/ * *
* @ return { boolean }
* /
get printable ( ) {
if ( this . flags ) {
return this . hasFlag ( AnnotationFlag . PRINT ) &&
! this . hasFlag ( AnnotationFlag . INVISIBLE ) &&
! this . hasFlag ( AnnotationFlag . HIDDEN ) ;
}
return false ;
} ,
/ * *
* Set the flags .
*
* @ public
* @ memberof Annotation
* @ param { number } flags - Unsigned 32 - bit integer specifying annotation
* characteristics
* @ see { @ link shared / util . js }
* /
setFlags : function Annotation _setFlags ( flags ) {
if ( isInt ( flags ) ) {
this . flags = flags ;
} else {
this . flags = 0 ;
}
} ,
/ * *
* Check if a provided flag is set .
*
* @ public
* @ memberof Annotation
* @ param { number } flag - Hexadecimal representation for an annotation
* characteristic
* @ return { boolean }
* @ see { @ link shared / util . js }
* /
hasFlag : function Annotation _hasFlag ( flag ) {
if ( this . flags ) {
return ( this . flags & flag ) > 0 ;
}
return false ;
} ,
/ * *
* Set the rectangle .
*
@ -237,32 +297,6 @@ var Annotation = (function AnnotationClosure() {
@@ -237,32 +297,6 @@ var Annotation = (function AnnotationClosure() {
}
} ,
isInvisible : function Annotation _isInvisible ( ) {
var data = this . data ;
return ! ! ( data &&
data . annotationFlags && // Default: not invisible
data . annotationFlags & 0x1 ) ; // Invisible
} ,
isViewable : function Annotation _isViewable ( ) {
var data = this . data ;
return ! ! ( ! this . isInvisible ( ) &&
data &&
( ! data . annotationFlags ||
! ( data . annotationFlags & 0x22 ) ) && // Hidden or NoView
data . rect ) ; // rectangle is necessary
} ,
isPrintable : function Annotation _isPrintable ( ) {
var data = this . data ;
return ! ! ( ! this . isInvisible ( ) &&
data &&
data . annotationFlags && // Default: not printable
data . annotationFlags & 0x4 && // Print
! ( data . annotationFlags & 0x2 ) && // Hidden
data . rect ) ; // rectangle is necessary
} ,
loadResources : function Annotation _loadResources ( keys ) {
return new Promise ( function ( resolve , reject ) {
this . appearance . dict . getAsync ( 'Resources' ) . then ( function ( resources ) {
@ -329,8 +363,8 @@ var Annotation = (function AnnotationClosure() {
@@ -329,8 +363,8 @@ var Annotation = (function AnnotationClosure() {
var annotationPromises = [ ] ;
for ( var i = 0 , n = annotations . length ; i < n ; ++ i ) {
if ( intent === 'display' && annotations [ i ] . isViewable ( ) ||
intent === 'print' && annotations [ i ] . isPrintable ( ) ) {
if ( intent === 'display' && annotations [ i ] . viewable ||
intent === 'print' && annotations [ i ] . printable ) {
annotationPromises . push (
annotations [ i ] . getOperatorList ( partialEvaluator , task ) ) ;
}
@ -506,6 +540,12 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
@@ -506,6 +540,12 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
data . fieldFlags = Util . getInheritableProperty ( dict , 'Ff' ) || 0 ;
this . fieldResources = Util . getInheritableProperty ( dict , 'DR' ) || Dict . empty ;
// Hide unsupported Widget signatures.
if ( data . fieldType === 'Sig' ) {
warn ( 'unimplemented annotation type: Widget signature' ) ;
this . setFlags ( AnnotationFlag . HIDDEN ) ;
}
// Building the full field name by collecting the field and
// its ancestors 'T' data and joining them using '.'.
var fieldName = [ ] ;
@ -539,17 +579,7 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
@@ -539,17 +579,7 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
data . fullName = fieldName . join ( '.' ) ;
}
var parent = Annotation . prototype ;
Util . inherit ( WidgetAnnotation , Annotation , {
isViewable : function WidgetAnnotation _isViewable ( ) {
if ( this . data . fieldType === 'Sig' ) {
warn ( 'unimplemented annotation type: Widget signature' ) ;
return false ;
}
return parent . isViewable . call ( this ) ;
}
} ) ;
Util . inherit ( WidgetAnnotation , Annotation , { } ) ;
return WidgetAnnotation ;
} ) ( ) ;