mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #16804 from Snuffleupagus/issue-16800
Take fill-alpha into account with default icons for FileAttachment annotations (issue 16800)
This commit is contained in:
commit
2e9f2e630c
5 changed files with 38 additions and 7 deletions
|
@ -4653,6 +4653,12 @@ class FileAttachmentAnnotation extends MarkupAnnotation {
|
|||
const name = dict.get("Name");
|
||||
this.data.name =
|
||||
name instanceof Name ? stringToPDFString(name.name) : "PushPin";
|
||||
|
||||
const fillAlpha = dict.get("ca");
|
||||
this.data.fillAlpha =
|
||||
typeof fillAlpha === "number" && fillAlpha >= 0 && fillAlpha <= 1
|
||||
? fillAlpha
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2798,8 +2798,9 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||
render() {
|
||||
this.container.classList.add("fileAttachmentAnnotation");
|
||||
|
||||
const { data } = this;
|
||||
let trigger;
|
||||
if (this.data.hasAppearance) {
|
||||
if (data.hasAppearance || data.fillAlpha === 0) {
|
||||
trigger = document.createElement("div");
|
||||
} else {
|
||||
// Unfortunately it seems that it's not clearly specified exactly what
|
||||
|
@ -2809,18 +2810,26 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||
// Additional names may be supported as well. Default value: PushPin.
|
||||
trigger = document.createElement("img");
|
||||
trigger.src = `${this.imageResourcesPath}annotation-${
|
||||
/paperclip/i.test(this.data.name) ? "paperclip" : "pushpin"
|
||||
/paperclip/i.test(data.name) ? "paperclip" : "pushpin"
|
||||
}.svg`;
|
||||
|
||||
if (data.fillAlpha && data.fillAlpha < 1) {
|
||||
trigger.style = `filter: opacity(${Math.round(
|
||||
data.fillAlpha * 100
|
||||
)}%);`;
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
||||
this.container.classList.add("hasFillAlpha");
|
||||
}
|
||||
}
|
||||
}
|
||||
trigger.classList.add("popupTriggerArea");
|
||||
trigger.addEventListener("dblclick", this._download.bind(this));
|
||||
this.#trigger = trigger;
|
||||
|
||||
if (
|
||||
!this.data.popupRef &&
|
||||
(this.data.titleObj?.str ||
|
||||
this.data.contentsObj?.str ||
|
||||
this.data.richText)
|
||||
!data.popupRef &&
|
||||
(data.titleObj?.str || data.contentsObj?.str || data.richText)
|
||||
) {
|
||||
this._createPopup();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue