Skip to content

Commit

Permalink
add key for root-supplement
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Feb 22, 2025
1 parent 0eab471 commit 16dddb0
Show file tree
Hide file tree
Showing 7 changed files with 569 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to the `tagpdf` package since the
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
this project uses date-based 'snapshot' version identifiers.

## [Unreleased]

### Added
- root-supplemental-file key to embed css and html files.

## [2025-02-17]
Version 0.99m

Expand Down
8 changes: 5 additions & 3 deletions doc/tagpdf.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1799,9 +1799,11 @@ \subsubsection{Commands to define the structure}
\item[\PrintKeyName{root-AF}] This key allows to reference an
associated file in the root structure element. Using the root can
be e.g. useful to add a css-file. When converting the pdf to a
html with e.g. ngpdf this css-file is then referenced in the head
of the html.

html with e.g. ngpdf \cite{ngpdf} this css-file is then referenced in the head of the html.

\item[\PrintKeyName{root-supplemental-file}] This is a variant of the previous key. It takes as argument a file name. It then embeds this file with \texttt{/AFRelationship /Supplement} and appends it as associated file to the structure root. ngpdf \cite{ngpdf} will store a \texttt{.css} attached in this way and reference it in the head of the html. If a \texttt{html} is attached in this way, ngpdf will
copy the content into the head of the derived html. This means that the content of such an html file should normally be some html snippet suitable for the head, e.g. some css-code inside \texttt{<style>} tags.


\item[\PrintKeyName{AFinline}] This key allows to embed an
associated file with inline content. The value is some text,
Expand Down
25 changes: 25 additions & 0 deletions tagpdf-struct.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,31 @@
}
% \end{macrocode}
% \end{setupkeydecl}
%
% \begin{setupkeydecl}{root-supplemental-file}
% This key allows to add a file as root-AF with relationship Supplement.
% This is typically need to add a css or an html
% \begin{macrocode}
\keys_define:nn { @@ / setup }
{
root-supplemental-file .code:n =
{
\group_begin:
\pdfdict_put:nnn {l_pdffile/Filespec} {AFRelationship}{/Supplement}
\int_gincr:N \g_@@_unique_cnt_int
\pdffile_embed_file:eee
{#1}
{#1}
{__tag_latex_css_\int_use:N\g_@@_unique_cnt_int}
\keys_set:nn
{__tag / setup}
{root-AF={__tag_latex_css_\int_use:N\g_@@_unique_cnt_int}}
\group_end:
}
}
% \end{macrocode}
% \end{setupkeydecl}
%
% \section{User commands}
% We allow to set a language by default
% \begin{macro}{\l_@@_struct_lang_tl}
Expand Down
10 changes: 10 additions & 0 deletions tagpdf.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,15 @@
\bool_new:N \g_@@_softhyphen_bool
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{\g_@@_unique_cnt_int}
% If tagpdf has to create unique names (e.g. for object names when embedding files)
% it can use this integer to get an unique name. At every use it should be increased
% \begin{macrocode}
\int_new:N \g_@@_unique_cnt_int
% \end{macrocode}
% \end{variable}

% \section{Variants of l3 commands}
% \begin{macrocode}
\prg_generate_conditional_variant:Nnn \pdf_object_if_exist:n {e}{T,F,TF}
Expand All @@ -427,6 +436,7 @@
\cs_generate_variant:Nn \seq_set_split:Nnn{Nne} %** unneeded
\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon }
\cs_generate_variant:Nn \clist_map_inline:nn {on}
\cs_generate_variant:Nn \pdffile_embed_file:nnn {eee}
% \end{macrocode}
%
% \section{Label and Reference commands}
Expand Down
11 changes: 11 additions & 0 deletions testfiles-luatex/root-file.pvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\ExplSyntaxOn
\sys_gset_rand_seed:n{42}
\ExplSyntaxOff
\DocumentMetadata{testphase={latest},pdfversion=2.0}
\input{regression-test}
\documentclass[]{article}
\tagpdfsetup{root-supplemental-file=testcss.css, root-supplemental-file=test-css.html}
\begin{document}
\START
some text
\end{document}
Loading

0 comments on commit 16dddb0

Please sign in to comment.