latex3 / tagpdf

Tagging support code for LaTeX
59 stars 7 forks source link

Allow to add an AF to the root #48

Closed u-fischer closed 2 years ago

u-fischer commented 2 years ago

that is needed to get a css in the head. Currently it works only manually. It should also be possible to add more than one.

\documentclass{article}
\begin{filecontents}[overwrite,noheader]{testcss.css}
.font-red {color:red;}
\end{filecontents}

\ExplSyntaxOn
\group_begin:
\prop_gput:Nnn \g_pdffile_mimetypes_prop {.css}{text/css}% will not be needed later
\pdfdict_put:nnn{l_pdffile/Filespec}{AFRelationship}{/Supplement}
\pdfdict_put:nnn{l_pdffile/Filespec}{Desc}{(testcss.css)}
\pdffile_embed_file:nnn{testcss.css}{}{tag/csstest}
\__tag_prop_gput:cnx
  { g__tag_struct_0_prop }
  { AF }
  {[\pdf_object_ref:n{tag/csstest}]}
\group_end:

\ExplSyntaxOff  
\tagpdfsetup
 {
   activate-all,
   newattribute = {font-red}{/O /CSS-3 },
 }
%\usepackage{xfp}
\begin{document}
\tagpdfparaOff %for the example
\tagstructbegin{tag=Document} 
\tagstructbegin{tag=H1,attribute-class=font-red}\tagmcbegin{tag=H1}Red section\tagmcend\tagstructend

\tagstructbegin{tag=H1,AF=tag/csstest}\tagmcbegin{tag=H1}Section\tagmcend\tagstructend
\tagstructend
\end{document}
u-fischer commented 2 years ago

added in version 0.93