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

Work-around for HighlightAnnotations without a top-level /ExtGState-entry (issue 13242)

For HighlightAnnotations with a built-in appearance stream, we still rely on it to specify the opacity correctly via a suitable blend mode. However, if the Annotation-drawing operators are placed *within* a /XObject of the /Form-type, the /ExtGState won't apply to the final rendering and the result is that the highlighting obscures the underlying text.

The more *correct* and general solution would likely be to somehow modify the implementation in `src/display/canvas.js`, to special-case handling of /Form-type /XObjects when rendering Annotations. Since we can very easily work-around this problem for now by using the "no appearance stream" code-path, doing *something* here ought to be preferable.

This patch is (obviously) merely a work-around, but given that the referenced issue is (as far as I know) the first case we've seen of this problem a simple solution will hopefully suffice for now.
This commit is contained in:
Jonas Jenwald 2021-05-28 13:30:18 +02:00
parent e499521b78
commit 707a9e3b02
4 changed files with 19 additions and 1 deletions

View file

@ -2676,7 +2676,17 @@ class HighlightAnnotation extends MarkupAnnotation {
null
));
if (quadPoints) {
if (!this.appearance) {
const resources =
this.appearance && this.appearance.dict.get("Resources");
if (!this.appearance || !(resources && resources.has("ExtGState"))) {
if (this.appearance) {
// Workaround for cases where there's no /ExtGState-entry directly
// available, e.g. when the appearance stream contains a /XObject of
// the /Form-type, since that causes the highlighting to completely
// obsure the PDF content below it (fixes issue13242.pdf).
warn("HighlightAnnotation - ignoring built-in appearance stream.");
}
// Default color is yellow in Acrobat Reader
const fillColor = this.color
? Array.from(this.color).map(c => c / 255)