glib/tests/CMakeLists.txt | 2 +- poppler/Annot.cc | 28 +++++++++++++++++++++++++++- poppler/Annot.h | 3 +++ 3 files changed, 31 insertions(+), 2 deletions(-)
New commits: commit aaf2e8083141fcea5dacbc6af6a679533ad8dc55 Author: Albert Astals Cid <[email protected]> Date: Sun Nov 22 18:01:10 2020 +0100 Tweak the don't use Appearance stream if annot is typeHighlight After playing hand editing files and opening them in Adobe Reader i *think* the condition is "if the appearance stream has a ExtGState in its Resources dict, then use the appearance stream, otherwise draw it ourselves diff --git a/glib/tests/CMakeLists.txt b/glib/tests/CMakeLists.txt index 32eefd01..5f49511c 100644 --- a/glib/tests/CMakeLists.txt +++ b/glib/tests/CMakeLists.txt @@ -47,7 +47,7 @@ poppler_add_testcase(poppler-check-bb checkbox_issue_159.pdf 2.84 14.17 553.18 8 poppler_add_testcase(poppler-check-bb NestedLayers.pdf 0 191 612 792) poppler_add_testcase(poppler-check-bb A6EmbeddedFiles.pdf 18 18 558.36 751.92) poppler_add_testcase(poppler-check-bb latex-hyperref-checkbox-issue-655.pdf 148.71 123.81 308.11 704.57) -poppler_add_testcase(poppler-check-bb utf16le-annot.pdf 52.98 55.61 101.23 95.29) +poppler_add_testcase(poppler-check-bb utf16le-annot.pdf 55.47 54.78 98.74 96.12) poppler_add_testcase(poppler-check-bb type3.pdf -p 10 125.80 130 509.30 695 125.80 132 538.03 693) add_executable(pdfdrawbb pdfdrawbb.c) diff --git a/poppler/Annot.cc b/poppler/Annot.cc index 52fe0ac7..0ba629c4 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -3557,6 +3557,32 @@ void AnnotTextMarkup::setQuadrilaterals(AnnotQuadrilaterals *quadPoints) invalidateAppearance(); } +bool AnnotTextMarkup::shouldCreateApperance(Gfx *gfx) const +{ + if (appearance.isNull()) + return true; + + // Adobe Reader seems to have a complex condition for when to use the + // appearance stream of typeHighlight, which is "use it if it has a Resources dictionary with ExtGState" + // this is reverse engineering of me editing a file by hand and checking what it does so the real + // condition may be more or less complex + if (type == typeHighlight) { + XRef *xref = gfx->getXRef(); + const Object fetchedApperance = appearance.fetch(xref); + if (fetchedApperance.isStream()) { + const Object resources = fetchedApperance.streamGetDict()->lookup("Resources"); + if (resources.isDict()) { + if (resources.dictLookup("ExtGState").isDict()) { + return false; + } + } + } + return true; + } + + return false; +} + void AnnotTextMarkup::draw(Gfx *gfx, bool printing) { double ca = 1; @@ -3566,7 +3592,7 @@ void AnnotTextMarkup::draw(Gfx *gfx, bool printing) return; annotLocker(); - if (appearance.isNull() || type == typeHighlight) { + if (shouldCreateApperance(gfx)) { bool blendMultiply = true; ca = opacity; diff --git a/poppler/Annot.h b/poppler/Annot.h index fe96916c..66f293b8 100644 --- a/poppler/Annot.h +++ b/poppler/Annot.h @@ -1167,6 +1167,9 @@ protected: void initialize(PDFDoc *docA, Dict *dict); std::unique_ptr<AnnotQuadrilaterals> quadrilaterals; // QuadPoints + +private: + bool shouldCreateApperance(Gfx *gfx) const; }; //------------------------------------------------------------------------ _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
