@ -35,6 +35,7 @@
@@ -35,6 +35,7 @@
} ( this , function ( exports , sharedUtil , corePrimitives , coreStream , coreObj ,
coreParser , coreCrypto , coreEvaluator , coreAnnotation ) {
var OPS = sharedUtil . OPS ;
var MissingDataException = sharedUtil . MissingDataException ;
var Util = sharedUtil . Util ;
var assert = sharedUtil . assert ;
@ -63,7 +64,6 @@ var Linearization = coreParser.Linearization;
@@ -63,7 +64,6 @@ var Linearization = coreParser.Linearization;
var calculateMD5 = coreCrypto . calculateMD5 ;
var OperatorList = coreEvaluator . OperatorList ;
var PartialEvaluator = coreEvaluator . PartialEvaluator ;
var Annotation = coreAnnotation . Annotation ;
var AnnotationFactory = coreAnnotation . AnnotationFactory ;
var Page = ( function PageClosure ( ) {
@ -71,6 +71,11 @@ var Page = (function PageClosure() {
@@ -71,6 +71,11 @@ var Page = (function PageClosure() {
var DEFAULT _USER _UNIT = 1.0 ;
var LETTER _SIZE _MEDIABOX = [ 0 , 0 , 612 , 792 ] ;
function isAnnotationRenderable ( annotation , intent ) {
return ( intent === 'display' && annotation . viewable ) ||
( intent === 'print' && annotation . printable ) ;
}
function Page ( pdfManager , xref , pageIndex , pageDict , ref , fontCache ,
builtInCMapCache ) {
this . pdfManager = pdfManager ;
@ -269,6 +274,8 @@ var Page = (function PageClosure() {
@@ -269,6 +274,8 @@ var Page = (function PageClosure() {
} ) ;
} ) ;
// Fetch the page's annotations and add their operator lists to the
// page's operator list to render them.
var annotationsPromise = pdfManager . ensure ( this , 'annotations' ) ;
return Promise . all ( [ pageListPromise , annotationsPromise ] ) . then (
function ( datas ) {
@ -280,10 +287,23 @@ var Page = (function PageClosure() {
@@ -280,10 +287,23 @@ var Page = (function PageClosure() {
return pageOpList ;
}
var annotationsReadyPromise = Annotation . appendToOperatorList (
annotations , pageOpList , partialEvaluator , task , intent ,
renderInteractiveForms ) ;
return annotationsReadyPromise . then ( function ( ) {
// Collect the operator list promises for the annotations. Each promise
// is resolved with the complete operator list for a single annotation.
var i , ii , opListPromises = [ ] ;
for ( i = 0 , ii = annotations . length ; i < ii ; i ++ ) {
if ( isAnnotationRenderable ( annotations [ i ] , intent ) ) {
opListPromises . push ( annotations [ i ] . getOperatorList (
partialEvaluator , task , renderInteractiveForms ) ) ;
}
}
return Promise . all ( opListPromises ) . then ( function ( opLists ) {
pageOpList . addOp ( OPS . beginAnnotations , [ ] ) ;
for ( i = 0 , ii = opLists . length ; i < ii ; i ++ ) {
pageOpList . addOpList ( opLists [ i ] ) ;
}
pageOpList . addOp ( OPS . endAnnotations , [ ] ) ;
pageOpList . flush ( true ) ;
return pageOpList ;
} ) ;
@ -334,14 +354,10 @@ var Page = (function PageClosure() {
@@ -334,14 +354,10 @@ var Page = (function PageClosure() {
var annotations = this . annotations ;
var annotationsData = [ ] ;
for ( var i = 0 , n = annotations . length ; i < n ; ++ i ) {
if ( intent ) {
if ( ! ( intent === 'display' && annotations [ i ] . viewable ) &&
! ( intent === 'print' && annotations [ i ] . printable ) ) {
continue ;
}
}
if ( ! intent || isAnnotationRenderable ( annotations [ i ] , intent ) ) {
annotationsData . push ( annotations [ i ] . data ) ;
}
}
return annotationsData ;
} ,