<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - PDF compliance: Always respect Annot Rect"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=105692">105692</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>PDF compliance: Always respect Annot Rect
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>poppler
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>general
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>poppler-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>haxtibal@posteo.de
          </td>
        </tr></table>
      <p>
        <div>
        <pre>To be compliant to ISO 32k, we always have to respect the geometry of Annot
/Rect. See [0]. Currently there are cases where poppler draws annotations at
another size. Namely this happens when poppler generates appearances at runtime
to substitute missing AP entries for AnnotText, AnnotLine, AnnotTextMarkup,
AnnotPolygon and AnnotInk (e.g. [1], [2]).

For example, you can end up with a popup note drawn as 24 x 24 pts even if
Annot Rect says 16 x 16 pts. Poppler does not update Annot Rect, it keeps
telling 16 x 16. Therefore the new size is also not reflected in public APIs.
So the bug is not only about PDF non-conformance, but it also leaves clients
unaware of the actually rendered size [4].

ISO 32k contains a detailed description about how to fit appearance streams
into Annot Rect. See "Algorithm: Appearance streams" from ISO 32000-1:2008,
12.5.5. To sum up:
a) make a quadrilateral from AP BBox by applying apperances transformation
Matrix, and calculate a temporary transformed AP BBox that encompasses the
quadrilateral
b) calculate a temporary Matrix A that scales the transformed AP BBox into
Annot Rect
c) use this Matrix A to draw the appearance

The existing method Gfx::drawAnnot nicely implements this algorithm. We just
have to call Gfx::drawAnnot with the original Annot Rect size instead passing
other values.

Patches will follow, comments are appreciated in advance.

[0] <a href="https://lists.freedesktop.org/archives/poppler/2018-March/012909.html">https://lists.freedesktop.org/archives/poppler/2018-March/012909.html</a>
[1]
<a href="https://cgit.freedesktop.org/poppler/poppler/tree/poppler/Annot.cc?h=poppler-0.63.0#n2486">https://cgit.freedesktop.org/poppler/poppler/tree/poppler/Annot.cc?h=poppler-0.63.0#n2486</a>
[2]
<a href="https://cgit.freedesktop.org/poppler/poppler/tree/poppler/Annot.cc?h=poppler-0.63.0#n5890">https://cgit.freedesktop.org/poppler/poppler/tree/poppler/Annot.cc?h=poppler-0.63.0#n5890</a>
[3]
<a href="https://cgit.freedesktop.org/poppler/poppler/tree/poppler/Gfx.cc?h=poppler-0.63.0#n5125">https://cgit.freedesktop.org/poppler/poppler/tree/poppler/Gfx.cc?h=poppler-0.63.0#n5125</a>
[4] <a href="https://bugs.kde.org/show_bug.cgi?id=388458">https://bugs.kde.org/show_bug.cgi?id=388458</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>