0

I’m using tagpdf.sty to make accessible pdf from LaTeX. So far I can do everything except add the UA metadata. But there is a minor issue with (re)definig \href. Here is a simplified version of what I am using. I need the URI, an anchor text and a comment in the pdf, which can be produced by \pdftag in LaTeX or LuaLaTeX.

The problem is that #2 might be split over a line. So, in principle, we might need two or more \pdfannots. Can anyone suggest a method to handle this?

\newlength{\@Href@Width}
\newlength{\@Href@Height}
\newlength{\@Href@Depth}
\newcommand\Href[3]{%  URI/text/comment
  \tagstructbegin{tag=Link}
  \push@mc{16}% Link
  \tagmcbegin{tag=Link}
  \settowidth{\@Href@Width}{#2}
  \settoheight{\@Href@Height}{\vphantom{(}#2}
  \settodepth{\@Href@Depth}{\vphantom{(}#2}
  \addtolength{\@Href@Width}{1pt}
  \addtolength{\@Href@Height}{1pt}
  \addtolength{\@Href@Depth}{1pt}
  \pdfannot width \@Href@Width height \@Href@Height depth
  \@Href@Depth {/Subtype/Link/Contents(#3)/Border[ 0 0 0.5 [1 1] ]
    /C[ 0 0.5 1 ] /A << /S/URI/Type/Action/URI(#1) >> }#2
  \ifthenelse{\boolean{mc@fza}}{\emc}{}
  \pop@mc%
  \tagstructend% Link
}
6
  • I don't think that this is correct, you are missing the /StructParent entry. Also as a warning: the documentation of tagpdf says that this is experimental, and this is meant in earnest. I made many changes in the last months in the development branches. I won't remove the user commands, but you should not rely on some internals. Also newer versions will only works with newer latex. Regarding the link: use \pdfstartlink/\pdfendlink if you want breakable links. Aug 4 '20 at 16:31
  • Beside this: we (the LaTeX team) are quite interested in feedback and examples of where tagging works and where not as we are working on improving LaTeX in this area. Aug 4 '20 at 16:35
  • Thanks. I should have spotted the missing /StructParent. I’m not sure I can fix this without resorting to undocumented macros but I can see how to use \pdfstartlink.
    – John Lamb
    Aug 8 '20 at 9:34
  • If you are interested in feedback on tagpdf, what kind of feedback and where? I’m well aware that it is experimental, but quite happy to test it.
    – John Lamb
    Aug 8 '20 at 9:36
  • I do have correct code for the links - the documentation uses it and has correctly tagged links. You can add feedbacks e.g. to the github, or sent me a mail. Aug 8 '20 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.