1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Merge pull request #13328 from calixteman/js_display1

JS - Add support for display property
This commit is contained in:
Brendan Dahl 2021-05-17 08:47:13 -07:00 committed by GitHub
commit 17e9cfcd2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 197 additions and 141 deletions

View file

@ -69,13 +69,6 @@ import { XRef } from "./xref.js";
const DEFAULT_USER_UNIT = 1.0;
const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
function isAnnotationRenderable(annotation, intent) {
return (
(intent === "display" && annotation.viewable) ||
(intent === "print" && annotation.printable)
);
}
class Page {
constructor({
pdfManager,
@ -270,7 +263,7 @@ class Page {
return this._parsedAnnotations.then(function (annotations) {
const newRefsPromises = [];
for (const annotation of annotations) {
if (!isAnnotationRenderable(annotation, "print")) {
if (!annotation.mustBePrinted(annotationStorage)) {
continue;
}
newRefsPromises.push(
@ -370,8 +363,9 @@ class Page {
const opListPromises = [];
for (const annotation of annotations) {
if (
isAnnotationRenderable(annotation, intent) &&
!annotation.isHidden(annotationStorage)
(intent === "display" &&
annotation.mustBeViewed(annotationStorage)) ||
(intent === "print" && annotation.mustBePrinted(annotationStorage))
) {
opListPromises.push(
annotation
@ -472,7 +466,13 @@ class Page {
return this._parsedAnnotations.then(function (annotations) {
const annotationsData = [];
for (let i = 0, ii = annotations.length; i < ii; i++) {
if (!intent || isAnnotationRenderable(annotations[i], intent)) {
// Get the annotation even if it's hidden because
// JS can change its display.
if (
!intent ||
(intent === "display" && annotations[i].viewable) ||
(intent === "print" && annotations[i].printable)
) {
annotationsData.push(annotations[i].data);
}
}