A comment using \pdfmarkupcomment will be divided into several comments

Issue #19 new
Zhiwei Liu created an issue

Hi! When I use \pdfmarkupcoment to make a comment, if the content of the comment is so much that it can be divided into several lines in the final compiled pdf, the comment will be split to several comments too. Is it possible to keep the comment not being split into several same comments ?

My code is like this:

\pdfmarkupcomment[color=green]{Under the assumption that the speech recognizer’s acoustic models are adequate to the task, the first step to finding alternative word hypotheses is to recover the phoneme sequence that is underlying the ASR hypothesis. While this task is often solved by simple pronunciation dictionaries that map every character to its phonemic representation, this would be insufficient given the very large (and unknown) vocabulary of the cloud speech recognizer.}{Copy from the paper of DOCKS}.

And the final pdf opened in Adobe Reader: exp1.png exp2.png

Comments (3)

  1. Yukai Chou

    Try the following patch.

    %%
    %% pdfcomment-patch.tex
    %%
    %% let `\pdfmarkupcomment` create only one annotation for text spreading 
    %% multi lines
    %%
    
    \usepackage{xpatch}
    
    \makeatletter
    
    % delete the first, and the extra \SOUL@, as described in issue 23
    % https://bitbucket.org/kleberj/pdfcomment/issues/23
    \xpatchcmd\pdfmarkupcomment
      {\SOUL@{#2}}
      {#2}
      {}{\ddt}
    
    % patch the second \SOUL@
    \xpatchcmd\pdfmarkupcomment
      {\SOUL@{#2}}
      {%
        % clear \pc@annot@quadpoints
        \def\pc@annot@quadpoints{}%
        \SOUL@{#2}%
        % execute real annotation action, producing only one annotation
        \pc@annot@addAnnot
      }
      {}{\ddt}
    
    
    \renewcommand{\pc@annot@complete}%
    {%
      \renewcommand{\pc@x@one}{\pc@pttobp{\pc@Sposx}}%
      \renewcommand{\pc@x@two}{\pc@pttobp{\pc@Eposx}}%
      \renewcommand{\pc@x@three}{\pc@pttobp{\pc@Sposx}}%
      \renewcommand{\pc@x@four}{\pc@pttobp{\pc@Eposx}}%
      \renewcommand{\pc@y@one}{\pc@pttobp{\dimexpr \pc@Sposy + \pc@box@height + 1pt\relax}}%
      \renewcommand{\pc@y@two}{\pc@pttobp{\dimexpr \pc@Eposy + \pc@box@height + 1pt\relax}}%
      \renewcommand{\pc@y@three}{\pc@pttobp{\dimexpr \pc@Sposy - \pc@box@depth - 1pt\relax}}%
      \renewcommand{\pc@y@four}{\pc@pttobp{\dimexpr \pc@Eposy - \pc@box@depth - 1pt\relax}}%
      \ifthenelse{\equal{\pc@annot@quadpoints}{}}%
      {%
        \xdef\pc@annot@quadpoints{%
          \pc@x@one\space\pc@y@one\space
          \pc@x@two\space\pc@y@two\space
          \pc@x@three\space\pc@y@three\space
          \pc@x@four\space\pc@y@four}%
      }%
      {%
        % if not empty, append positions to \pc@annot@quadpoints
        % see PDF Reference v1.7, Table 8.30 in Sec. 8.4.5
        \xdef\pc@annot@quadpoints{%
          \pc@annot@quadpoints\space
          \pc@x@one\space\pc@y@one\space
          \pc@x@two\space\pc@y@two\space
          \pc@x@three\space\pc@y@three\space
          \pc@x@four\space\pc@y@four}%
      }%
      % move codes of real annotation action into new command \pc@annot@addAnnot
    }%
    
    \newcommand\pc@annot@addAnnot{%
      \ifpdf
        \pc@annot@markup@pdf
        \ifthenelse{\equal{\pc@lopt@id}{}}%
        {}%
        {\xdef\pc@collect@PDFOBJID{\pc@collect@PDFOBJID,\the\pdflastannot}}%
      \else
        \ifpc@gopt@dvipdfmx
          \pc@annot@markup@dvipdfmx
        \else
          \pc@annot@markup@dvips
        \fi
      \fi
    }
    
    \makeatother
    
  2. Josef Kleber repo owner

    This works great for the first section on page 1 of the pdfcomment example Unfortunately, it does at least up to now break the support for page breaks. The annotations are just on page 2 in the section "large" section, but are gone in the last lines of page 1.

  3. Yukai Chou

    Searching in the related pages of PDF Reference and testing by Acrobat Reader, the facts, as far as I know, are

    • PDF format does not support multi-page text markup annotation, and
    • Adding text markup annotation to text spreading multiple pages would lead to adding one annotation for each page, as Acrobat Reader does.

    An instant solution would be hooking into "page break". I test the atbegshi package, however it shows the \pc@annot@quadpoints is empty inside \AtBeginShipout.

    Working on it

  4. Log in to comment