Skip to content

Fix calculation of TextAnnotation size

... so that select/move rectangle fits exactly around icons regardless of PDF page size and DPI settings

This is a patch by @tobiasdeiminger moved here from https://phabricator.kde.org/D9615. Tobias wrote:

BUG: 387639

BUG: 388458

I'd consider it only as partial fix. Poppler forces us to use 24x24 pts, else we'd never get a match. Poppler silently ignores what size applications set in Poppler::Annotation::setBoundary or what comes from the PDF objects /Rect entry, in the case of an external writer. This should IMHO get fixed at Poppler side, or at least it should be clarified why forcing 24x24 pts was necessary. The PDF standard just says "readers shall provide predefined icon appearances for standard names: Comment, Key, Note, Help, NewParagraph, Paragraph, Insert" [12.5.6.4]. It doesn't say anything about a predefined size. It says, the /Rect entry defines position and size [12.5.2, 12.5.3].

Patch in https://phabricator.kde.org/F5620896 shows how poppler could help out.

Some further references to get an idea why 24x24 enforcement was done in Poppler:

Test Plan

Add TextAnnotations (the ones from the top entry of the annotation toolbar) to PDF documents with various page sizes (e.g. A3, A4, letter, ...).

  1. Select the icon by left-click. The size of the drawn rectangle shall match with the rendered icon.
  2. Move the icon around by left-click + dragging. The size of the drawn rectangle shall match with the rendered icon.

Open a file with externally created (e.g. LaTeX) text annotation, and repeat steps from above.

Start Okular with different hidpi setting, e.g.

$ QT_SCREEN_SCALE_FACTORS='DVI-I-1=2' okular

Repeat steps from above.

Merge request reports