mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Don't print hidden annotatons (bug 1815196)
and handle correctly the NoView and NoPrint flags when they're changed from JS.
This commit is contained in:
parent
0e6d141edf
commit
71960bea64
9 changed files with 124 additions and 18 deletions
|
@ -628,8 +628,11 @@ class Annotation {
|
|||
* @private
|
||||
*/
|
||||
_isPrintable(flags) {
|
||||
// In Acrobat, hidden flag cancels the print one
|
||||
// (see annotation_hidden_print.pdf).
|
||||
return (
|
||||
this._hasFlag(flags, AnnotationFlag.PRINT) &&
|
||||
!this._hasFlag(flags, AnnotationFlag.HIDDEN) &&
|
||||
!this._hasFlag(flags, AnnotationFlag.INVISIBLE)
|
||||
);
|
||||
}
|
||||
|
@ -642,11 +645,13 @@ class Annotation {
|
|||
* @public
|
||||
* @memberof Annotation
|
||||
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
|
||||
* @param {boolean} [_renderForms] - if true widgets are rendered thanks to
|
||||
* the annotation layer.
|
||||
*/
|
||||
mustBeViewed(annotationStorage) {
|
||||
const hidden = annotationStorage?.get(this.data.id)?.hidden;
|
||||
if (hidden !== undefined) {
|
||||
return !hidden;
|
||||
mustBeViewed(annotationStorage, _renderForms) {
|
||||
const noView = annotationStorage?.get(this.data.id)?.noView;
|
||||
if (noView !== undefined) {
|
||||
return !noView;
|
||||
}
|
||||
return this.viewable && !this._hasFlag(this.flags, AnnotationFlag.HIDDEN);
|
||||
}
|
||||
|
@ -661,9 +666,9 @@ class Annotation {
|
|||
* @param {AnnotationStorage} [annotationStorage] - Storage for annotation
|
||||
*/
|
||||
mustBePrinted(annotationStorage) {
|
||||
const print = annotationStorage?.get(this.data.id)?.print;
|
||||
if (print !== undefined) {
|
||||
return print;
|
||||
const noPrint = annotationStorage?.get(this.data.id)?.noPrint;
|
||||
if (noPrint !== undefined) {
|
||||
return !noPrint;
|
||||
}
|
||||
return this.printable;
|
||||
}
|
||||
|
@ -1700,7 +1705,9 @@ class WidgetAnnotation extends Annotation {
|
|||
|
||||
data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
|
||||
data.required = this.hasFieldFlag(AnnotationFieldFlag.REQUIRED);
|
||||
data.hidden = this._hasFlag(data.annotationFlags, AnnotationFlag.HIDDEN);
|
||||
data.hidden =
|
||||
this._hasFlag(data.annotationFlags, AnnotationFlag.HIDDEN) ||
|
||||
this._hasFlag(data.annotationFlags, AnnotationFlag.NOVIEW);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1739,6 +1746,26 @@ class WidgetAnnotation extends Annotation {
|
|||
return !!(this.data.fieldFlags & flag);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
_isViewable(flags) {
|
||||
// We don't take into account the `NOVIEW` or `HIDDEN` flags here,
|
||||
// since the visibility can be changed by js code, hence in case
|
||||
// it's made viewable, we should render it (with visibility set to
|
||||
// hidden).
|
||||
return !this._hasFlag(flags, AnnotationFlag.INVISIBLE);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
mustBeViewed(annotationStorage, renderForms) {
|
||||
if (renderForms) {
|
||||
return this.viewable;
|
||||
}
|
||||
return (
|
||||
super.mustBeViewed(annotationStorage, renderForms) &&
|
||||
!this._hasFlag(this.flags, AnnotationFlag.NOVIEW)
|
||||
);
|
||||
}
|
||||
|
||||
getRotationMatrix(annotationStorage) {
|
||||
let rotation = annotationStorage?.get(this.data.id)?.rotation;
|
||||
if (rotation === undefined) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue