[poppler] poppler/Annot.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 17 20:17:04 UTC 2020


 poppler/Annot.cc |   23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

New commits:
commit 331f2f092b7cb3be97a1f5c0665d41cd10e85a8d
Author: Oliver Sander <oliver.sander at tu-dresden.de>
Date:   Sat Nov 14 22:03:25 2020 +0100

    Fix annotation line width if no appearance stream or style are given
    
    When handling annotations without appearance stream, the behavior
    of poppler deviated from what the pdf spec says:  Poppler would
    only take the boundary width from a border style (BS) dictionary
    if the 'style (S)' field was also present, even though the spec
    clearly says that both are optional, and does not mention
    one depending on the other.
    
    This behavior was deliberate, because apparently Acroread 8
    did it that way.  See the comment by Jeff Muizelaar in 28967940.
    But it seems that Acroread behavior has changed, newer versions
    do take the 'width' field into account even when there is no
    'style (S)' field.  The Chromium pdf renderer does the same.
    
    So let's change the code back to following the spec rather
    than an old version of Acroread.
    
    BUG: 988

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 4363475d..52fe0ac7 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -586,20 +586,14 @@ AnnotBorderBS::AnnotBorderBS() { }
 
 AnnotBorderBS::AnnotBorderBS(Dict *dict)
 {
-    Object obj1, obj2;
-
-    // acroread 8 seems to need both W and S entries for
-    // any border to be drawn, even though the spec
-    // doesn't claim anything of that sort. We follow
-    // that behaviour by verifying both entries exist
-    // otherwise we set the borderWidth to 0
-    // --jrmuizel
-    obj1 = dict->lookup("W");
-    obj2 = dict->lookup("S");
-    if (obj1.isNum() && obj2.isName()) {
-        const char *styleName = obj2.getName();
+    // Border width (in points)
+    Object obj1 = dict->lookup("W");
+    width = obj1.getNumWithDefaultValue(1.0);
 
-        width = obj1.getNum();
+    // Border style
+    obj1 = dict->lookup("S");
+    if (obj1.isName()) {
+        const char *styleName = obj1.getName();
 
         if (!strcmp(styleName, "S")) {
             style = borderSolid;
@@ -615,9 +609,10 @@ AnnotBorderBS::AnnotBorderBS(Dict *dict)
             style = borderSolid;
         }
     } else {
-        width = 0;
+        style = borderSolid;
     }
 
+    // Border dash style
     if (style == borderDashed) {
         obj1 = dict->lookup("D");
         if (obj1.isArray())


More information about the poppler mailing list