1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Implement creation date only for markup annotations

The specification states that `CreationDate` is only available for
markup annotations instead of for all annotation types.

Moreover, popup annotations are not markup annotations according to the
specification, so the creation date inheritance from the parent
annotation is also removed there (note that only the modification date
is used in e.g., the viewer).
This commit is contained in:
Tim van der Meij 2019-05-25 15:25:52 +02:00
parent cf07918ccb
commit bc1eb49a77
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
2 changed files with 47 additions and 41 deletions

View file

@ -176,7 +176,6 @@ class Annotation {
const dict = params.dict;
this.setContents(dict.get('Contents'));
this.setCreationDate(dict.get('CreationDate'));
this.setModificationDate(dict.get('M'));
this.setFlags(dict.get('F'));
this.setRectangle(dict.getArray('Rect'));
@ -190,7 +189,6 @@ class Annotation {
borderStyle: this.borderStyle,
color: this.color,
contents: this.contents,
creationDate: this.creationDate,
hasAppearance: !!this.appearance,
id: params.id,
modificationDate: this.modificationDate,
@ -257,18 +255,6 @@ class Annotation {
this.contents = stringToPDFString(contents || '');
}
/**
* Set the creation date.
*
* @public
* @memberof Annotation
* @param {string} creationDate - PDF date string that indicates when the
* annotation was originally created
*/
setCreationDate(creationDate) {
this.creationDate = isString(creationDate) ? creationDate : null;
}
/**
* Set the modification date.
*
@ -629,16 +615,31 @@ class AnnotationBorderStyle {
class MarkupAnnotation extends Annotation {
constructor(parameters) {
super(parameters);
const dict = parameters.dict;
const dict = parameters.dict;
if (!dict.has('C')) {
// Fall back to the default background color.
this.data.color = null;
}
this.setCreationDate(dict.get('CreationDate'));
this.data.creationDate = this.creationDate;
this.data.hasPopup = dict.has('Popup');
this.data.title = stringToPDFString(dict.get('T') || '');
}
/**
* Set the creation date.
*
* @public
* @memberof MarkupAnnotation
* @param {string} creationDate - PDF date string that indicates when the
* annotation was originally created
*/
setCreationDate(creationDate) {
this.creationDate = isString(creationDate) ? creationDate : null;
}
}
class WidgetAnnotation extends Annotation {
@ -989,13 +990,6 @@ class PopupAnnotation extends Annotation {
this.data.title = stringToPDFString(parentItem.get('T') || '');
this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
if (!parentItem.has('CreationDate')) {
this.data.creationDate = null;
} else {
this.setCreationDate(parentItem.get('CreationDate'));
this.data.creationDate = this.creationDate;
}
if (!parentItem.has('M')) {
this.data.modificationDate = null;
} else {
@ -1179,4 +1173,5 @@ export {
Annotation,
AnnotationBorderStyle,
AnnotationFactory,
MarkupAnnotation,
};