| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: l3pdfmanagement.dtx |
| 4 |
% |
| 5 |
% Copyright (C) 2018-2026 The LaTeX Project |
| 6 |
% |
| 7 |
% It may be distributed and/or modified under the conditions of the |
| 8 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 9 |
% license or (at your option) any later version. The latest version |
| 10 |
% of this license is in the file |
| 11 |
% |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% This file is part of the "LaTeX PDF management bundle" (The Work in LPPL) |
| 15 |
% and all files in that bundle must be distributed together. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/latex3/pdfresources |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
% |
| 25 |
%<*driver> |
| 26 |
\DocumentMetadata{tagging=on,pdfstandard=ua-2} |
| 27 |
\documentclass[full]{l3doc} |
| 28 |
\usepackage{latex-lab-testphase-l3doc} |
| 29 |
|
| 30 |
\usepackage{tabularx} |
| 31 |
\usepackage{array,booktabs} |
| 32 |
\hypersetup{pdfauthor=The LaTeX Project,pdftitle=l3pdfmanagement (LaTeX PDF management bundle)} |
| 33 |
|
| 34 |
\providecommand\potentialclash{\noindent\llap{\dbend\ }} |
| 35 |
\pdfextension glyphtounicode{char7f}{2621} |
| 36 |
% Fixing footnotes in functions and variables: this should be in l3doc! |
| 37 |
\newcommand\fixfootnote[2]{\footnotemark |
| 38 |
\AddToHookNext{env/#1/after}{\footnotetext{#2}}} |
| 39 |
\AddToHook{env/function/begin}{\def\footnote{\fixfootnote{function}}} |
| 40 |
\AddToHook{env/variable/begin}{\def\footnote{\fixfootnote{variable}}} |
| 41 |
|
| 42 |
\begin{document} |
| 43 |
\DocInput{\jobname.dtx} |
| 44 |
\end{document} |
| 45 |
%</driver> |
| 46 |
% \fi |
| 47 |
% |
| 48 |
% \title{^^A |
| 49 |
% The \pkg{l3pdfmanagement} module\\ Managing central PDF resources ^^A |
| 50 |
% \\\LaTeX{} PDF management bundle |
| 51 |
% } |
| 52 |
% |
| 53 |
% \author{^^A |
| 54 |
% The \LaTeX{} Project\thanks |
| 55 |
% {^^A |
| 56 |
% E-mail: |
| 57 |
% \href{mailto:[email protected]} |
| 58 |
% {[email protected]}^^A |
| 59 |
% }^^A |
| 60 |
% } |
| 61 |
% |
| 62 |
% \date{Version 0.97c, released 2026-05-26} |
| 63 |
% |
| 64 |
% \maketitle |
| 65 |
% \begin{documentation} |
| 66 |
% |
| 67 |
% \section{\pkg{l3pdfmanagement} documentation} |
| 68 |
% When creating a pdf a number of objects, dictionaries and entries to |
| 69 |
% central \enquote{core} dictionaries must be created. |
| 70 |
% |
| 71 |
% The commands in this module offer interfaces to this core PDF dictionaries |
| 72 |
% They unify a number of primitives like the pdftex |
| 73 |
% registers and commands \cs{pdfcatalog}, \cs{pdfpageattr}, |
| 74 |
% \cs{pdfpagesattr}, \cs{pdfinfo}, \cs{pdfpageresources} |
| 75 |
% and similar commands of the other backends in a backend independent way. |
| 76 |
% |
| 77 |
% The supported backends are pdflatex, lualatex, (x)dvipdfmx (latex, xelatex |
| 78 |
% and---starting in texlive 2021--lualatex) |
| 79 |
% and dvips with ps2pdf (not completely yet). dvips with distiller could work too |
| 80 |
% but is untested. |
| 81 |
% |
| 82 |
% That the interfaces are backend independent doesn't mean that the results and even |
| 83 |
% the compilation behavior is identical. The backends are too different to allow |
| 84 |
% this. Some backends expand arguments e.g. in a \cs{special} while other don't. |
| 85 |
% Some backends can insert a resource at the first compilation, while another uses |
| 86 |
% the aux-file and a label and so needs at least two. Some backends create and |
| 87 |
% manage resources automatically which must be managed manually by other backends. |
| 88 |
% |
| 89 |
% The dictionaries and resources handled by this module are inserted only |
| 90 |
% once in a PDF or only once per page. Examples are the Catalog dictionary, |
| 91 |
% the Info dictionary, the page resources. For these dictionaries and resources |
| 92 |
% management by the \LaTeX{} kernel is necessary to avoid |
| 93 |
% that packages overwrite settings from |
| 94 |
% other packages which would lead to clashes and incompatibilities. |
| 95 |
% It is therefore necessary that \emph{all} packages which want to add content to these |
| 96 |
% dictionaries and resources use the interface provided by this module. |
| 97 |
% |
| 98 |
% As these dictionaries and resources are so central for the PDF format values to these |
| 99 |
% dictionaries are always added globally. Through the interface values |
| 100 |
% can be added (and in many cases also removed) by users and packages, |
| 101 |
% but the actually writing of the |
| 102 |
% dictionary entries and resources to the PDF is handled by |
| 103 |
% the kernel code. |
| 104 |
% |
| 105 |
% The interface uses as main name to address the resources \emph{Paths} |
| 106 |
% which follow the names and structure described in the PDF reference. This |
| 107 |
% should make it easy to identify the names needed to insert a specific |
| 108 |
% PDF resources with the new interfaces. |
| 109 |
% All \emph{Paths} have names starting with an uppercase letter. |
| 110 |
% |
| 111 |
% The following tabular summarize the \emph{Paths} and which pdftex primitive they |
| 112 |
% replace: |
| 113 |
% |
| 114 |
% \begin{tabular}{ll} |
| 115 |
% Info & \cs{pdfinfo} \\ |
| 116 |
% Catalog \& various subdictionaries & \cs{pdfcatalog} \\ |
| 117 |
% Pages & \cs{pdfpagesattr} \\ |
| 118 |
% Page, ThisPage & \cs{pdfpageattr} \\ |
| 119 |
% Page/Resources/ExtGState & \cs{pdfpageresources} \\ |
| 120 |
% Page/Resources/Shading & \cs{pdfpageresources} \\ |
| 121 |
% Page/Resources/Pattern & \cs{pdfpageresources} \\ |
| 122 |
% Page/Resources/ColorSpace & \cs{pdfpageresources} \\% |
| 123 |
% \end{tabular} |
| 124 |
% |
| 125 |
% There is no \texttt{Page/Resources/Properties} dictionary in the list, |
| 126 |
% because this dictionary is not filled directly, but |
| 127 |
% managed through side effects when setting BDC-marks. |
| 128 |
% |
| 129 |
% \subsection{User Commands} |
| 130 |
% To avoid problems with older documents the resource management of this |
| 131 |
% module is not activated unconditionally. The values are pushed out to the |
| 132 |
% dictionaries only if a boolean has been set to true. The state can be tested |
| 133 |
% with a conditional. |
| 134 |
% \begin{function}[EXP,pTF,added=2020-07-04] |
| 135 |
% {\pdfmanagement_if_active:} |
| 136 |
% This conditional tests if the resource management code is active. |
| 137 |
% \end{function} |
| 138 |
% \begin{function}[added=2021-07-23] |
| 139 |
% {\IfPDFManagementActiveTF} |
| 140 |
% This is a LaTeX2e version of the conditional |
| 141 |
% \end{function} |
| 142 |
|
| 143 |
% \begin{function}[added = 2020-04-06,updated=2021-07-23] |
| 144 |
% {\pdfmanagement_add:nnn,\pdfmanagement_add:nne,\pdfmanagement_add:nee,\pdfmanagement_add:eee, |
| 145 |
% \PDFManagementAdd} |
| 146 |
% \begin{syntax} |
| 147 |
% \cs{pdfmanagement_add:nnn} \Arg{resource path} \Arg{name} \Arg{value} |
| 148 |
% \end{syntax} |
| 149 |
% This function puts \Arg{name} \Arg{value} in the PDF resource described by |
| 150 |
% the symbolic name \Arg{resource path}. Technically it stores it globally in an internal |
| 151 |
% property lists and writes it later into the right PDF dictionary\footnote{Currently all |
| 152 |
% resources are PDF dictionaries, so resource and dictionary mean the same.} |
| 153 |
% Which values for \Arg{resource path} exist is described in the following. |
| 154 |
% \Arg{name} should be a PDF Name without the starting slash. Like with all |
| 155 |
% keys used in PDF dictionaries (see the l3pdfdict module) the name is escaped |
| 156 |
% with \cs{str_convert_pdfname:n} when stored. |
| 157 |
% \Arg{value} should be a valid PDF value for this Name in the |
| 158 |
% target dictionary. |\PDFManagementAdd| is a copy of |\pdfmanagement_add:eee| |
| 159 |
% and so expands all its arguments. |
| 160 |
% |
| 161 |
% |
| 162 |
% The code works with all major engines but not necessarily |
| 163 |
% in the same way. Most importantly |
| 164 |
% \begin{itemize} |
| 165 |
% \item The expansion behaviour of the backends can differ. Some backends expand a |
| 166 |
% value always fully when writing to the PDF, with other backends command names |
| 167 |
% could end as strings in the PDF. So one should neither rely on \Arg{name} |
| 168 |
% \Arg{value} to be expanded nor not expanded by the backend commands. |
| 169 |
% \item The number of compilations needed can differ between the engines and |
| 170 |
% backends. Some engines have to use labels and the aux-file to setup |
| 171 |
% the dictionaries and so need at least two compilations to put everything |
| 172 |
% in place. |
| 173 |
% \item dvips doesn't support everything. It is for example not possible |
| 174 |
% to add manually or through side effects |
| 175 |
% a name tree like /AP or /JavaScript, pdfmark doesn't provide a handler |
| 176 |
% here---at least I didn't find anything suitable. |
| 177 |
% \end{itemize} |
| 178 |
% \end{function} |
| 179 |
% |
| 180 |
% \begin{function}[added = 2020-04-08] |
| 181 |
% {\pdfmanagement_show:n } |
| 182 |
% \begin{syntax} |
| 183 |
% \cs{pdfmanagement_show:n} \Arg{resource path} |
| 184 |
% \end{syntax} |
| 185 |
% This shows the content of the dictionary targeted by |
| 186 |
% \Arg{resource path} in the log and on the terminal if possible. |
| 187 |
% |
| 188 |
% It is not reliable for page resources as these are filled at shipout. |
| 189 |
% |
| 190 |
% It also doesn't show necessarily all the content. |
| 191 |
% For example most backends add automatically |
| 192 |
% entries to the Info dictionary. |
| 193 |
% \end{function} |
| 194 |
% |
| 195 |
% \begin{function}[added = 2020-04-07] |
| 196 |
% { |
| 197 |
% \pdfmanagement_remove:nn, |
| 198 |
% } |
| 199 |
% \begin{syntax} |
| 200 |
% \cs{pdfmanagement_remove:nn} \Arg{resource path} \Arg{name} |
| 201 |
% \end{syntax} |
| 202 |
% Removes |/|\meta{name} and its associated \meta{value} from the |
| 203 |
% dictionary described with \Arg{resource path} |
| 204 |
% The removal is global. |
| 205 |
% If \meta{name} is not found no change occurs, |
| 206 |
% \emph{i.e}~there is no need to test for the existence of a name before |
| 207 |
% trying to remove it. |
| 208 |
% Values from the special Catalog entries where the values are collected in arrays |
| 209 |
% can't be removed (but should ever a use case appear it could be added). |
| 210 |
% \end{function} |
| 211 |
% |
| 212 |
% \subsection{Description of the resource paths} |
| 213 |
% \subsubsection{Info: The Info dictionary} |
| 214 |
% \begin{NOTE}{UF} |
| 215 |
% path: Info |
| 216 |
% The info dictionary is filled by e.g. \cs{pdfinfo}. Multiple appearances of |
| 217 |
% \cs{pdfinfo} are concatenated, so one could end with multiple /Title or /Author entries. |
| 218 |
% It is then viewer dependent which one is showed, so it is better to avoid this. |
| 219 |
% We therefore setup a property which is filled and written to the info |
| 220 |
% directory in one go. According to hyperref a few odd drivers (hvtex, dvipsone, dviwind) |
| 221 |
% don't support arbitrary keys, but this should be handle elsewhere. |
| 222 |
% As entries with empty content |
| 223 |
% should be omitted we add a test. The string command should perhaps escape the argument, |
| 224 |
% but for now we are assuming that the argument is pdf safe. |
| 225 |
% hyperref writes to the info dictionary at the shipout of the first page -- |
| 226 |
% probably to catch the case that \cs{title} is issued after the begin of the document. |
| 227 |
% We are outputting at the last page -- this needs a second compilation but |
| 228 |
% this is needed anyway. |
| 229 |
% \end{NOTE} |
| 230 |
% \potentialclash If the primitive commands of the engines are used too there will |
| 231 |
% be double entries in the pdf (at least with the backend pdftex and luatex). |
| 232 |
% How pdf viewer handles this is unpredictable. |
| 233 |
% |
| 234 |
% \begin{function} |
| 235 |
% { |
| 236 |
% pdfmanagement: Info |
| 237 |
% } |
| 238 |
% \begin{syntax} |
| 239 |
% \cs{pdfmanagement_add:nnn} \{Info\} \Arg{name} \Arg{value} |
| 240 |
% \end{syntax} |
| 241 |
% Adds |/|\meta{name} and the \meta{value} to the Info dictionary. |
| 242 |
% \meta{name} should be a PDF name without the leading slash, |
| 243 |
% Like with all |
| 244 |
% keys used in PDF dictionaries (see the l3pdfdict module) the name is escaped |
| 245 |
% with \cs{str_convert_pdfname:n} when stored. |
| 246 |
% \meta{value} should be a valid pdf value. Any escaping or (re)encoding must be |
| 247 |
% done explicitly. |
| 248 |
% If a \meta{name} is used twice, only the last \meta{value} |
| 249 |
% set will be used. The Info dictionary is written at the end of the compilation, |
| 250 |
% so values can be set at any time. |
| 251 |
% The Info dictionary expects utf16be in the strings, so a conversion like this is |
| 252 |
% normally sensible: |
| 253 |
% \begin{verbatim} |
| 254 |
% \str_set_convert:Nnnn \l_tmpa_str { Grüße }{ default } {utf16/string} |
| 255 |
% \pdfmanagement_add:nne {Info} {Title}{(\l_tmpa_str)} |
| 256 |
% \end{verbatim} |
| 257 |
% \end{function} |
| 258 |
% |
| 259 |
% The entries in Info dictionary are rather special as the engines/backends adds some |
| 260 |
% core entries, and changing or removing these entries is not always possible. |
| 261 |
% |
| 262 |
% The special entries are |
| 263 |
% \begin{description} |
| 264 |
% \item[Producer] Added by all engines and backends. Removing the entry is only possible |
| 265 |
% with luatex with |\pdfvariable suppressoptionalinfo 128|. Changing is possible |
| 266 |
% with \cs{pdfmanagement_add:nnn} with the exception of dvips/pstopdf where the entry is |
| 267 |
% always something like |GPL Ghostscript 9.53.3|. |
| 268 |
% \item[Creator] Added by all engines and backends. Removal only possible in luatex by adding |
| 269 |
% 16 to the bitset. Changing is possible with the management command. |
| 270 |
% \item[CreationDate] Added by all engines and backends. With the exception of |dvips/ps2pdf| |
| 271 |
% |SOURCE_DATE_EPOCH| is honored. With pdftex it is possible to suppress it with |
| 272 |
% |\pdfinfoomitdate = 1|, and in luatex by adding 32 to the bitset. |
| 273 |
% Changing is possible with the management command and will overwrite an epoch setting. |
| 274 |
% \item[ModDate] Added by all engines and backends with the exception of xdvipdfmx. |
| 275 |
% With the exception of |dvips/ps2pdf| |SOURCE_DATE_EPOCH| is honored. |
| 276 |
% Suppressing it is possible in pdftex with |
| 277 |
% |\pdfinfoomitdate = 1|, and in luatex by adding 64 to the bitset. Changing is possible with |
| 278 |
% the management command. |
| 279 |
% \item[Trapped] Added by pdftex and luatex. Removal only possible in |
| 280 |
% luatex by adding 256 to the bitset. Changing (and adding in the other backends) is |
| 281 |
% possible with the management command. |
| 282 |
% \item[PTEX.Fullbanner] Added by pdftex and luatex. Removal possible in pdftex with |
| 283 |
% |\pdfsuppressptexinfo-1|, in luatex by adding 512 to the bitset. |
| 284 |
% Changing is not possible. |
| 285 |
% \item[Title] Added by dvips/ps2pdf and set to |filename.dvi|. Removal is probably |
| 286 |
% not possible, but it can be overwritten with the management command.% |
| 287 |
% \end{description} |
| 288 |
% \subsubsection{Pages: The \enquote{Pages} dictionary} |
| 289 |
% \potentialclash As the content of this dictionary is written at the end it will |
| 290 |
% in pdftex and luatex overwrite values added with the primitive commands (e.g. |
| 291 |
% \cs{pdfpagesattr}. |
| 292 |
% Package authors should use the management commands instead. |
| 293 |
|
| 294 |
% By using this path with the pdfmanagement interface, |
| 295 |
% values can be added to the /Pages object. |
| 296 |
% This replaces for example \cs{pdfpagesattr}. |
| 297 |
% |
| 298 |
% \begin{function}{pdfmanagement: Pages} |
| 299 |
% \begin{syntax} |
| 300 |
% \cs{pdfmanagement_add:nnn} \{Pages\} \Arg{name} \Arg{value} |
| 301 |
% \end{syntax} |
| 302 |
% |
| 303 |
% Adds |/|\meta{name} \meta{value} to the |/Pages| dictionary. |
| 304 |
% It is always stored globally. The content is written to the pdf |
| 305 |
% at the end of the compilation, so values can be added, changed or |
| 306 |
% removed until then. |
| 307 |
% \meta{name} should be a valid pdf name without the leading slash, |
| 308 |
% \meta{value} should be a valid pdf value. Any escaping or (re)encoding must |
| 309 |
% be done explicitly. Some backends expand the value but this should not be |
| 310 |
% relied on. If a \meta{name} is used twice, only the last \meta{value} |
| 311 |
% set will be used. |
| 312 |
% |
| 313 |
% \end{function} |
| 314 |
% |
| 315 |
% \subsubsection{\enquote{Page} and \enquote{ThisPage}} |
| 316 |
% \begin{NOTE}{UF} |
| 317 |
% Open is the question if one need a command to set attribute on a page by page number. |
| 318 |
% Open is the setter for /AF (and perhaps /OutputIntents). |
| 319 |
% See also https://tex.stackexchange.com/questions/479812/extension-of-rotating-package-to-set-pdf-rotation |
| 320 |
% (should work now) |
| 321 |
% \end{NOTE} |
| 322 |
% \begin{function}[added = 2020-04-12] |
| 323 |
% {pdfmanagement: Page} |
| 324 |
% \begin{syntax} |
| 325 |
% \cs{pdfmanagement_add:nnn} \{Page\} \Arg{name} \Arg{value} |
| 326 |
% \end{syntax} |
| 327 |
% Values added with the path \texttt{Page} are added to the page dictionary |
| 328 |
% of the current page and the following pages. The current page means the page |
| 329 |
% on which the command is \emph{executed}. \meta{name} should be a valid pdf name |
| 330 |
% without the leading slash. Typical names used here are e.g. |
| 331 |
% \texttt{Rotate} and \texttt{CropBox}. |
| 332 |
% \meta{value} should be a valid pdf value. |
| 333 |
% Any escaping or (re)encoding must be done explicitly. Some backends expand the |
| 334 |
% value but this should not be relied on. |
| 335 |
% To avoid problems with the asynchronous page breaking |
| 336 |
% the command should be used after \cs{newpage} or in the header. |
| 337 |
% It should not be used in a float, as it will then quite probably be executed |
| 338 |
% on the wrong page. |
| 339 |
% The value is assigned directly and is always stored globally. |
| 340 |
% If a \meta{name} is used twice, only the last \meta{value} |
| 341 |
% set will be used. Names set with \cs{pdfmanagement_add:nnn}|{ThisPage}| will overwrite |
| 342 |
% names set with \cs{pdfmanagement_add:nnn}|{Page}| if there is a clash. |
| 343 |
% Values can be removed again with \cs{pdfmanagement_remove:nn}. |
| 344 |
% This replaces \cs{pdfpageattr}. |
| 345 |
% \end{function} |
| 346 |
% \begin{function}[added = 2020-04-12] |
| 347 |
% { pdfmanagement: ThisPage} |
| 348 |
% \begin{syntax} |
| 349 |
% \cs{pdfmanagement_add:nnn} \{ThisPage\} \Arg{name} \Arg{value} |
| 350 |
% \end{syntax} |
| 351 |
% Adds |/|\meta{name} \meta{value} at \emph{shipout} to the page dictionary of the |
| 352 |
% current page. Current page means here the \emph{shipout} page. \emph{shipout} means |
| 353 |
% at the end of the \texttt{shipout/background} hook. Code that wants to set a value |
| 354 |
% in a shipout hook should use the \texttt{shipout/background} hook too. Other hooks |
| 355 |
% are either too early or too late.% |
| 356 |
% It is always stored globally. |
| 357 |
% If \Arg{name} has already a value set in the \texttt{Page} |
| 358 |
% dictionary it will be overwritten for this page. |
| 359 |
% \meta{name} should be a valid pdf name without the leading slash, |
| 360 |
% \meta{value} should be a valid pdf value. Any escaping or (re)encoding must be |
| 361 |
% done explicitly. If a \meta{name} is used twice, only the last \meta{value} |
| 362 |
% set will be used. |
| 363 |
% With the engine pdflatex (at least) a second compilation is needed. |
| 364 |
% Values added to \texttt{ThisPage} can not be removed. It is not possible to |
| 365 |
% show the content of this dictionary with \cs{pdfmanagement_show:n}. |
| 366 |
% \end{function} |
| 367 |
% |
| 368 |
% \paragraph{Changing the \texttt{/MediaBox}}: It is possible to change |
| 369 |
% the \texttt{/MediaBox} of one or more pages by setting it for the \texttt{Page} |
| 370 |
% or \texttt{ThisPage} path (using \texttt{Pages} doesn't work, the engines |
| 371 |
% overwrite this)---this works even with dvips and allows to create |
| 372 |
% pages of different sizes. But you must be careful with the values. |
| 373 |
% If you set e.g. with pdflatex \cs{pdfpageheight} to 300bp you get a mediabox of |
| 374 |
% |0 0 595 300|, but pdflatex measure from the top and will also move |
| 375 |
% the reference point up, so effectively |
| 376 |
% you get the \emph{upper} third of the page. If you set the \texttt{/MediaBox} |
| 377 |
% to |0 0 595 300| with \cs{pdfmanagement_add:nnn} you get the \emph{lower} third. |
| 378 |
% In general it is better to use only the primitive commands to avoid confusing |
| 379 |
% results. |
| 380 |
% |
| 381 |
% \subsubsection{\enquote{Page/Resources}: ExtGState, ColorSpace, Shading, Pattern} |
| 382 |
% \begin{NOTE}{UF} |
| 383 |
% Only for pdf/luatex and xdvipdfmx backend- and pdf-code is needed to add values |
| 384 |
% to these resources. |
| 385 |
% With dvips the resources are added through high-level code (e.g. transparency), so the |
| 386 |
% backend/pdf commands are no-ops. |
| 387 |
% For every resources there is only one object. References to these objects are added to |
| 388 |
% all pages starting from the page where the first time something has been added to the |
| 389 |
% resource and to all XObjects. For luatex and pdftex it must be done together |
| 390 |
% with the /Properties, see above. |
| 391 |
% I don't see a need to set e.g. /ColorSpace page wise: preflight handles this |
| 392 |
% fine, see experiment colorspace-resources. |
| 393 |
% As pgf does the same, there is a need to patch it for now. Ditto for package colorspace. |
| 394 |
% \end{NOTE} |
| 395 |
% \begin{function}[updated = 2020-04-10] |
| 396 |
% { |
| 397 |
% pdfmanagement: Page/Resources/ExtGState, |
| 398 |
% pdfmanagement: Page/Resources/ColorSpace, |
| 399 |
% pdfmanagement: Page/Resources/Shading, |
| 400 |
% pdfmanagement: Page/Resources/Pattern, |
| 401 |
% } |
| 402 |
% \begin{syntax} |
| 403 |
% \cs{pdfmanagement_add:nnn} \{Page/Resources/\meta{resource}\} \Arg{name} \Arg{value} |
| 404 |
% \end{syntax} |
| 405 |
% Adds |/|\meta{name} \meta{value} to the page resource \meta{resource}. |
| 406 |
% \meta{resource} can be |ExtGState|, |ColorSpace|, |Pattern| or |Shading|. |
| 407 |
% The values are always stored globally. The content is written to the pdf |
| 408 |
% at the end of the compilation, so values can be added until then. |
| 409 |
% \meta{name} should be a valid pdf name without the leading slash, |
| 410 |
% \meta{value} should be a valid pdf value for the resource. |
| 411 |
% Any escaping or (re)encoding must be done explicitly. If a \meta{name} is |
| 412 |
% used twice, only the last \meta{value} set will be used. |
| 413 |
% |
| 414 |
% With the dvips backend the command does nothing: these resources are managed by |
| 415 |
% ghostscript or the distiller if e.\,g. transparency is used. |
| 416 |
% |
| 417 |
% The resources are added to all pages starting with the first where something has |
| 418 |
% been added to a resources. That means that for example |
| 419 |
% all ExtGState resources are combined in one |
| 420 |
% dictionary object and every page with a ExtGState resource refer to this object% |
| 421 |
% \footnote{This is similar to how pgf handles this resources}. |
| 422 |
% |
| 423 |
% \potentialclash The primitive commands (e.g. \cs{pdfpageresources}) |
| 424 |
% to set the resources should not be used |
| 425 |
% together with this code as the calls will overwrite each other and values |
| 426 |
% will be lost. This means that currently there are clashes with the packages tikz, |
| 427 |
% transparent and colorspace. |
| 428 |
% \end{function} |
| 429 |
% \subsubsection{\enquote{Catalog} \& subdirectories} |
| 430 |
% \begin{NOTE}{UF} |
| 431 |
% Perhaps some tools to create the AF-file specification dictionaries is useful. |
| 432 |
% Open for now: |
| 433 |
% /Extensions (dict, pdf 2.0) |
| 434 |
% /Dests ? difference to subdict in Names? |
| 435 |
% /DSS (dict, pdf 2.0) |
| 436 |
% /Acroform/DR/ExtGState etc probably unneeded. |
| 437 |
% \end{NOTE} |
| 438 |
% The catalog is a central dictionary in a PDF with a number of subdictionaries. |
| 439 |
% Entries to the top level of the catalog can be added with\\ |
| 440 |
% |\pdfmanagement_add:nnn {Catalog}|\Arg{Name}\Arg{Value}. |
| 441 |
% Entries to subdictionaries by using in the first |
| 442 |
% argument one of the paths described later. |
| 443 |
% The entries in the catalog have varying requirements regarding the |
| 444 |
% PDF management. Some entries (like \texttt{/Lang}) are simple values |
| 445 |
% where new values should |
| 446 |
% overwrite existing values, other like for example \texttt{/OutputIntents} |
| 447 |
% can contain a number of values and can be filled from more than one source. |
| 448 |
% In some cases the values that needs to be added are not at the top-level |
| 449 |
% but in some subsubdictionary or are actually part of an array. |
| 450 |
% To handle the pdf management uses a variety of internal, special handlers. |
| 451 |
% |
| 452 |
% \potentialclash In some cases entries are added implicitly. |
| 453 |
% For example entries to the name |
| 454 |
% tree of the \texttt{/EmbeddedFiles} key in the \texttt{/Names} directory are |
| 455 |
% added with the commands of the \texttt{l3pdffile} module. This clashes with |
| 456 |
% e.g. the embedfile package which should not be used! |
| 457 |
% |
| 458 |
% |
| 459 |
% \paragraph{Entries at the top level of the catalog} |
| 460 |
% The Names in the following tabular are entries that are added to the |
| 461 |
% top level of the catalog. |
| 462 |
% |
| 463 |
% If \meta{Name} gets assigned a value more than once the last one wins. |
| 464 |
% There is no check that the values have the correct type and format. |
| 465 |
% It is up to the user to ensure that the value does what is intended. |
| 466 |
% |
| 467 |
% The required PDF version is only mentioned if it is larger than 1.5. |
| 468 |
% |
| 469 |
% Example: |\pdfmanagement_add:nnn {Catalog}{PageMode}{/UseNone}| |
| 470 |
% |
| 471 |
% \medskip |
| 472 |
% \noindent |
| 473 |
% \begin{tabularx}{\linewidth}{ll>{\raggedright\arraybackslash}X} |
| 474 |
% \bfseries Name & \bfseries Value & \bfseries Remark \\\midrule |
| 475 |
% Collection & objref or dict & the content should be |
| 476 |
% build by external packages (see eg embedfile) \\ |
| 477 |
% DPartRoot & objref or dict & PDF 2.0 \\ |
| 478 |
% Lang & string & e.g. \texttt{(de-DE)} \\ |
| 479 |
% Legal & objref or dict \\ |
| 480 |
% Metadata & objref or stream \\ |
| 481 |
% NeedsRendering & boolean & PDF 1.7\\ |
| 482 |
% OpenAction & array (dest) or dict (action) \\ |
| 483 |
% PageLabels & objref or dict & number tree \\ |
| 484 |
% PageLayout & name & one of /SinglePage, /OneColumn, |
| 485 |
% /TwoColumnLeft, /TwoColumnRight, |
| 486 |
% /TwoPageLeft, |
| 487 |
% /TwoPageRight \\ |
| 488 |
% PageMode & name & one of /UseNone, /UseOutlines, /UseThumbs, |
| 489 |
% /UseOC, /UseAttachments (PDF 1.6)\\ |
| 490 |
% Perms & objref or dict & permissions\\ |
| 491 |
% PieceInfo & objref or dict \\ |
| 492 |
% SpiderInfo & objref or dict \\ |
| 493 |
% StructTreeRoot & objref or dict \\ |
| 494 |
% Threads & objref to an array\\ |
| 495 |
% URI & objref or dict \\ |
| 496 |
% Version & name & eg. \texttt{/1.7} \\ |
| 497 |
% \meta{unknown} & & an unknown \meta{name} will be |
| 498 |
% inserted without a warning.\\ |
| 499 |
% \end{tabularx} |
| 500 |
% \par\medskip |
| 501 |
% |
| 502 |
% \paragraph{Simple entries in subdictionaries of the catalog} |
| 503 |
% The following resource paths have been predeclared and allow to |
| 504 |
% add values to the respective subdictionaries of the catalog. The |
| 505 |
% names of the dictionaries follow the naming and location of the dictionaries |
| 506 |
% in the PDF reference. |
| 507 |
% If \meta{Name} gets assigned two values the last one wins. |
| 508 |
% |
| 509 |
% Example: |\pdfmanagement_add:nnn {Catalog/MarkInfo}{Marked}{true}| |
| 510 |
% |
| 511 |
% \medskip |
| 512 |
% \noindent |
| 513 |
% \begin{tabularx}{\linewidth}{lll>{\raggedright\arraybackslash}X} |
| 514 |
% \bfseries Path/dictionary & \bfseries Names & \bfseries Value & \bfseries Remark |
| 515 |
% \\\midrule |
| 516 |
% Catalog/AA &WC, WS, DS, WP,DP& all dict \\ |
| 517 |
% Catalog/AcroForm & NeedAppearances& boolean & In pdf 2.0 |
| 518 |
% NeedAppearances |
| 519 |
% is deprecated, |
| 520 |
% it is then required |
| 521 |
% that every widget has |
| 522 |
% an appearance streams.\\ |
| 523 |
% & SigFlags & Integer\\ |
| 524 |
% & DA & String \\ |
| 525 |
% & Q & Integer\\ |
| 526 |
% & XFA & stream or array & pdf 1.5\\ |
| 527 |
% Catalog/AcroForm/DR & \meta{name} & & probably unneeded \\ |
| 528 |
% Catalog/AcroForm/DR/Font & \meta{name} & dict & \\ |
| 529 |
% Catalog/MarkInfo & Marked & boolean \\ |
| 530 |
% & UserProperties & boolean \\ |
| 531 |
% & Suspects & boolean \\ |
| 532 |
% Catalog/ViewerPreferences & HideToolbar & boolean \\ |
| 533 |
% & Direction & /R2L or /L2R \\ |
| 534 |
% & \ldots & & many more, see the reference \\ |
| 535 |
% \end{tabularx} |
| 536 |
% |
| 537 |
% |
| 538 |
% \paragraph{Catalog entries with multiple values in arrays} |
| 539 |
% The following entries are special: Their values are arrays and |
| 540 |
% it must be possible to append to such arrays. This means that a new |
| 541 |
% call to set this value doesn't replace the value but appends it. |
| 542 |
% The value is an object reference. It is sensible to declare the object |
| 543 |
% first. E.g. |
| 544 |
% \begin{verbatim} |
| 545 |
% \pdf_object_new:n {module/intent} |
| 546 |
% \pdf_object_write:nnn {module/intent}{dict}{...} |
| 547 |
% \pdfmanagement_add:nne {Catalog} {OutputIntents}{\pdf_object_ref:n {module/intent}} |
| 548 |
% \end{verbatim} |
| 549 |
% |
| 550 |
% or |
| 551 |
% \begin{verbatim} |
| 552 |
% \pdf_object_unnamed_write:nn {dict} { ... } |
| 553 |
% \pdfmanagement_add:nne {Catalog} {OutputIntents}{\pdf_object_ref_last:} |
| 554 |
% \end{verbatim} |
| 555 |
% |
| 556 |
% |
| 557 |
% \medskip |
| 558 |
% \noindent |
| 559 |
% \begin{tabularx}{\linewidth}{lll>{\raggedright\arraybackslash}X} |
| 560 |
% \bfseries Path/dictionary &\bfseries Name & \bfseries Value & \bfseries Remark \\\midrule |
| 561 |
% Catalog/AcroForm & Fields & object reference\\ |
| 562 |
% Catalog/AcroForm & CO & object reference\\ |
| 563 |
% Catalog & AF & object reference & PDF 2.0, associated files\\ |
| 564 |
% Catalog/OCProperties & OCGs & object reference &if there are OCProperties, OCGs and D are required.\\ |
| 565 |
% Catalog/OCProperties & Configs & object reference \\ |
| 566 |
% Catalog/OCProperties & D & object reference & This is actually a single value as |
| 567 |
% there can be only one default. |
| 568 |
% If the value is set twice, the |
| 569 |
% second wins, and the first is |
| 570 |
% added to OCProperties/Configs.\\ |
| 571 |
% Catalog & OutputIntents & object reference\\ |
| 572 |
% Catalog & Requirements & object reference & PDF 1.7 \\ |
| 573 |
% Catalog/Names & EmbeddedFiles & object reference & This should reference a filespec dictionary. It will |
| 574 |
% attach the file to the file panel. |
| 575 |
% \end{tabularx} |
| 576 |
% |
| 577 |
% \paragraph{Catalog entries for name trees} |
| 578 |
% |
| 579 |
% \emph{Not supported in the dvips backend, pdfmark doesn't have an interface here}. |
| 580 |
% |
| 581 |
% In various places the PDF format allows to reference objects by name instead |
| 582 |
% of by object reference. The relationship between a name and the object reference |
| 583 |
% are store in so-called \emph{name trees}, which are stored in the |
| 584 |
% Catalog/Names dictionary. The |/Dests| and the |/EmbeddedFiles| name trees are |
| 585 |
% handled implicitly if destinations or files are added. Names to the other |
| 586 |
% name trees can be added with |\pdfmanagement_add:nnn|, e.g. to add an value to |
| 587 |
% the AP names (for appearance streams) use |
| 588 |
% |
| 589 |
% \begin{verbatim} |
| 590 |
% \pdfmanagement_add:nne { Catalog / Names / AP } {myAPname} {\pdf_object_ref_last:} |
| 591 |
% \end{verbatim} |
| 592 |
% |
| 593 |
% Remarks: |
| 594 |
% \begin{itemize} |
| 595 |
% \item The name |myAPname| is processed through |\pdf_string_from_unicode:nnN{utf8/string}| |
| 596 |
% and parentheses are added automatically. Ensure that the use of the name |
| 597 |
% handles it in the same way. |
| 598 |
% \item It is currently not possible to test if a name has already been used |
| 599 |
% by another package or previous code, |
| 600 |
% so use names where you can be confident that they are unique. |
| 601 |
% (It would be possible to split up the first part and test, but it would slow |
| 602 |
% down the compilation and I'm not sure if it is worth the trouble) |
| 603 |
% \item The value is not preprocessed, it is up-to-you to ensure that it does the |
| 604 |
% right thing. |
| 605 |
% \item Currently the structure of the name tree is flat, it doesn't use |
| 606 |
% Kids. But this can be changed if the need arise. |
| 607 |
% \end{itemize} |
| 608 |
% |
| 609 |
% The following name trees can be filled with this method. Currently only the |
| 610 |
% first three are activated. For the first, |EmbeddedFiles| there are two methods |
| 611 |
% to add a value:\\ |
| 612 |
% |\pdfmanagement_add:nnn{Catalog/Names/EmbeddedFiles}{name}{reference}| |
| 613 |
% and |
| 614 |
% |\pdfmanagement_add:nnn{Catalog/Names}{EmbeddedFiles}{reference}|. |
| 615 |
% This is intended, the second methods creates a name on the fly (with the prefix l3ef) |
| 616 |
% |
| 617 |
% \medskip |
| 618 |
% \noindent |
| 619 |
% \begin{tabularx}{\linewidth}{ll>{\raggedright\arraybackslash}X} |
| 620 |
% Catalog/Names/EmbeddedFiles & A name tree mapping name strings to file |
| 621 |
% specifications for embedded file streams. The value should be a reference to a filespec |
| 622 |
% dictionary\\ |
| 623 |
% Catalog/Names/AP & A name tree mapping name strings to annotation appearance streams\\ |
| 624 |
% Catalog/Names/JavaScript & A name tree mapping name strings to documentlevel ECMAScript actions\\ |
| 625 |
% (inactive) Catalog/Names/Pages & A name tree mapping name strings to visible pages for use in interactive forms\\ |
| 626 |
% (inactive) Catalog/Names/Templates & A name tree mapping name strings to invisible pages for use in interactive forms\\ |
| 627 |
% (inactive) Catalog/Names/IDS & A name tree mapping digital identifiers to Web.Capture content sets\\ |
| 628 |
% (inactive) Catalog/Names/URLS & A name tree mapping name strings to documentlevel ECMAScript actions\\ |
| 629 |
% (inactive) Catalog/Names/Renditions & A name tree mapping name strings (which shall have Unicode encoding) to rendition objects |
| 630 |
% (it is not quite clear yet, what unicode encoding means here. Perhaps this string will need special handling)\\ |
| 631 |
% \end{tabularx} |
| 632 |
% \end{documentation} |
| 633 |
% |
| 634 |
% \begin{implementation} |
| 635 |
% \section{\pkg{l3pdfmanagement} implementation} |
| 636 |
% \begin{macrocode} |
| 637 |
%<@@=pdfmanagement> |
| 638 |
%<*header> |
| 639 |
% |
| 640 |
\ProvidesExplPackage{l3pdfmanagement}{2026-05-26}{0.97c} |
| 641 |
{Management of core PDF dictionaries (LaTeX PDF management bundle)} |
| 642 |
%</header> |
| 643 |
% \end{macrocode} |
| 644 |
% \subsection{Messages} |
| 645 |
% \begin{macrocode} |
| 646 |
%<*package> |
| 647 |
\msg_new:nnn { pdfmanagement } { unknown-dict } |
| 648 |
{ The~PDF~management~resource~'#1'~is~unknown. } |
| 649 |
|
| 650 |
\msg_new:nnn { pdfmanagement } { empty-value } |
| 651 |
{ The~value~for~#1~is~empty~and~will~be~ignored } |
| 652 |
|
| 653 |
\msg_new:nnn { pdfmanagement } { no-removal } |
| 654 |
{ It~is~not~possible~to~remove~values~from~'#1'.} |
| 655 |
|
| 656 |
\msg_new:nnn { pdfmanagement } { no-show } |
| 657 |
{ It~is~not~possible~to~show~the~content~of~'#1'.} |
| 658 |
|
| 659 |
\msg_new:nnn { pdfmanagement } { name-exist } |
| 660 |
{ The~name~'#1'~has~already~been~used~for~name~tree~'#2'.} |
| 661 |
|
| 662 |
\msg_new:nnn { pdfmanagement } { show-dict } |
| 663 |
{ |
| 664 |
The~PDF~resource~'#1'~ |
| 665 |
\tl_if_empty:nTF {#2} |
| 666 |
{ is~empty \\>~ . } |
| 667 |
{ contains~the~pairs~(without~outer~braces): #2 . } |
| 668 |
} |
| 669 |
\msg_new:nnn { pdfmanagement } { dict-already-defined } |
| 670 |
{ |
| 671 |
The~path~'#1'~is~already~defined. |
| 672 |
} |
| 673 |
\msg_new:nnn { pdfmanagement } { inactive } |
| 674 |
{ |
| 675 |
The~PDF~resources~management~is~not~active\\ |
| 676 |
command~'#1'~ignored. |
| 677 |
} |
| 678 |
% \end{macrocode} |
| 679 |
% |
| 680 |
% \begin{variable}{\l_@@_tmpa_tl,\l_@@_tmpb_tl,\l_@@_tmpa_seq} |
| 681 |
% Some temp variables |
| 682 |
% \begin{macrocode} |
| 683 |
\tl_new:N \l_@@_tmpa_tl |
| 684 |
\tl_new:N \l_@@_tmpb_tl |
| 685 |
\seq_new:N \l_@@_tmpa_seq |
| 686 |
% \end{macrocode} |
| 687 |
% \end{variable} |
| 688 |
|
| 689 |
% \begin{variable}{\g_@@_active_bool} |
| 690 |
% This boolean will controlled the activation of the management code. |
| 691 |
% It is now a noop and always true. |
| 692 |
% \begin{macrocode} |
| 693 |
\bool_new:N \g_@@_active_bool |
| 694 |
\bool_gset_true:N \g_@@_active_bool |
| 695 |
% \end{macrocode} |
| 696 |
% \end{variable} |
| 697 |
% A user predicate to test if the management code is active |
| 698 |
% \begin{macrocode} |
| 699 |
\prg_new_conditional:Npnn \@@_if_active: { p , T , F , TF } |
| 700 |
{ |
| 701 |
\prg_return_true: |
| 702 |
} |
| 703 |
\prg_set_eq_conditional:NNn |
| 704 |
\pdfmanagement_if_active: \@@_if_active: { p , T , F , TF } |
| 705 |
|
| 706 |
\cs_set_eq:NN \IfPDFManagementActiveTF\use_i:nn |
| 707 |
% \end{macrocode} |
| 708 |
% We use a hook, to collect value added before the backend is ready. |
| 709 |
% \begin{macrocode} |
| 710 |
\hook_new:n {pdfmanagement/add} |
| 711 |
\cs_new_protected:Npn \pdfmanagement_add:nnn #1 #2 #3 |
| 712 |
{ |
| 713 |
\pdfdict_if_exist:nTF { g__pdf_Core/#1 } |
| 714 |
{ |
| 715 |
\hook_gput_code:nnn |
| 716 |
{pdfmanagement/add} |
| 717 |
{pdfmanagement} |
| 718 |
{ |
| 719 |
\@@_handler_gput:nnn { #1 }{ #2 }{ #3 } |
| 720 |
} |
| 721 |
} |
| 722 |
{ |
| 723 |
\msg_error:nnn{pdfmanagement}{unknown-dict}{#1} |
| 724 |
} |
| 725 |
} |
| 726 |
|
| 727 |
\cs_generate_variant:Nn \pdfmanagement_add:nnn {nne,nee,eee,nnx,nxx,xxx} |
| 728 |
\cs_set_eq:NN \PDFManagementAdd \pdfmanagement_add:eee |
| 729 |
% \end{macrocode} |
| 730 |
% \subsection{Hooks -- shipout and end of run code} |
| 731 |
% Code is executed in three places: At shipout of every page, |
| 732 |
% at shipout of the last page, at the end of the document |
| 733 |
% (after the last clearpage). Due to backend differences the code in the |
| 734 |
% three places (and the exact timing) can be different: pdflatex/lualatex |
| 735 |
% can execute code after the last \cs{clearpage} which the dvi-based |
| 736 |
% drivers have to add on a shipout page. |
| 737 |
% |
| 738 |
% \begin{variable} |
| 739 |
% { |
| 740 |
% \g__kernel_pdfmanagement_thispage_shipout_code_tl |
| 741 |
% \g__kernel_pdfmanagement_lastpage_shipout_code_tl |
| 742 |
% \g__kernel_pdfmanagement_end_run_code_tl |
| 743 |
% } |
| 744 |
% This variables contain the code run in the three places. |
| 745 |
% \begin{macrocode} |
| 746 |
\tl_new:N \g__kernel_pdfmanagement_thispage_shipout_code_tl |
| 747 |
\tl_new:N \g__kernel_pdfmanagement_lastpage_shipout_code_tl |
| 748 |
\tl_new:N \g__kernel_pdfmanagement_end_run_code_tl |
| 749 |
% \end{macrocode} |
| 750 |
% \end{variable} |
| 751 |
% \begin{macrocode} |
| 752 |
\tl_gset:Nn \g__kernel_pdfmanagement_thispage_shipout_code_tl |
| 753 |
{ |
| 754 |
\exp_args:NV \__pdf_backend_ThisPage_gpush:n { \g_shipout_readonly_int } |
| 755 |
\exp_args:NV \__pdf_backend_PageResources_gpush:n { \g_shipout_readonly_int } |
| 756 |
} |
| 757 |
|
| 758 |
\tl_gset:Nn \g__kernel_pdfmanagement_end_run_code_tl |
| 759 |
{ |
| 760 |
\__pdf_backend_PageResources_obj_gpush: %ExtGState etc |
| 761 |
\@@_Pages_gpush: %pagesattr |
| 762 |
\@@_Info_gpush: %pdfinfo |
| 763 |
\@@_Catalog_gpush: |
| 764 |
} |
| 765 |
% \end{macrocode} |
| 766 |
% \subsection{Naming convention} |
| 767 |
|
| 768 |
% Currently the following names are used: ^^A!!!!! check, compare with g_@@_gnames_seq |
| 769 |
% All have internally additionally a \texttt{Core} before the slash, to |
| 770 |
% hide the real name a bit. |
| 771 |
% \begin{verbatim} |
| 772 |
% /Info % (\pdfinfo) |
| 773 |
% /Catalog % (\pdfcatalog) |
| 774 |
% /Catalog/AA % |
| 775 |
% /Catalog/AcroForm |
| 776 |
% /Catalog/OCProperties |
| 777 |
% /Catalog/OutputIntents |
| 778 |
% /Catalog/AcroForm/DR |
| 779 |
% /Catalog/AcroForm/DR/Font |
| 780 |
% /Catalog/MarkInfo |
| 781 |
% /Catalog/ViewerPreferences |
| 782 |
% /Pages % (\pagesattr) |
| 783 |
% /Page % (\pageattr) |
| 784 |
% /ThisPage % (\pageattr) |
| 785 |
% /backend_PageN/Resources/Properties % this is only internal. |
| 786 |
% /Page/Resources/ExtGState |
| 787 |
% /Page/Resources/ColorSpace |
| 788 |
% /Page/Resources/Pattern |
| 789 |
% /Page/Resources/Shading |
| 790 |
% /Page/Resources/Properties |
| 791 |
% /Xform/Resources/Properties |
| 792 |
% \end{verbatim} |
| 793 |
|
| 794 |
% \begin{macro}{ |
| 795 |
% \@@_handler_gput:nnn, |
| 796 |
% \@@_get:nnN, |
| 797 |
% \@@_gremove:nn, |
| 798 |
% \@@_show:n |
| 799 |
% } |
| 800 |
% \cs{@@_handler_gput:nnn} is the main command to fill the dictionaries. |
| 801 |
% In simple cases it directly fill the property list, but if a handler exists |
| 802 |
% this is called. It is important to use it only in places where this make sense. |
| 803 |
% |
| 804 |
% \begin{macrocode} |
| 805 |
|
| 806 |
%global |
| 807 |
\cs_new_protected:Npn \@@_handler_gput:nnn #1 #2 #3 %#1 dict, #2 name, #3 value |
| 808 |
{ |
| 809 |
\tl_if_empty:nTF { #3 } |
| 810 |
{ |
| 811 |
\msg_none:nnn { pdfmanagement }{ empty-value }{ /#1/#2 } |
| 812 |
} |
| 813 |
{ |
| 814 |
\pdfdict_if_exist:nTF { g__pdf_Core/#1 } |
| 815 |
{ |
| 816 |
\cs_if_exist:cTF |
| 817 |
{ @@_handler/#1/?_gput:nn } %general, name independent handler |
| 818 |
{ \use:c {@@_handler/#1/?_gput:nn} {#2} {#3} } |
| 819 |
{ |
| 820 |
\cs_if_exist:cTF |
| 821 |
{ @@_handler/#1/#2_gput:n } |
| 822 |
{ \use:c {@@_handler/#1/#2_gput:n} {#3} } %special handler |
| 823 |
{ |
| 824 |
\exp_args:Nne |
| 825 |
\prop_gput:cnn |
| 826 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/#1 } } |
| 827 |
{ \str_convert_pdfname:n { #2 } } |
| 828 |
{ #3 } |
| 829 |
} |
| 830 |
} |
| 831 |
} |
| 832 |
{ |
| 833 |
\msg_error:nnn { pdfmanagement } { unknown-dict } { #1 } |
| 834 |
} |
| 835 |
} |
| 836 |
} |
| 837 |
|
| 838 |
|
| 839 |
\cs_generate_variant:Nn \@@_handler_gput:nnn {nee} |
| 840 |
|
| 841 |
\cs_new_protected:Npn \@@_get:nnN #1 #2 #3 %path,key,macro |
| 842 |
{ |
| 843 |
\exp_args:Nne |
| 844 |
\prop_get:cnN |
| 845 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/#1 } } |
| 846 |
{ \str_convert_pdfname:n {#2} } #3 |
| 847 |
} |
| 848 |
|
| 849 |
|
| 850 |
\cs_new_protected:Npn \@@_handler_gremove:nn #1 #2 %path,key |
| 851 |
{ |
| 852 |
\pdfdict_if_exist:nTF { g__pdf_Core/#1 } |
| 853 |
{ |
| 854 |
\cs_if_exist:cTF |
| 855 |
{ @@_handler/#1/?_gremove:n } %general, name independent handler |
| 856 |
{ \use:c {@@_handler/#1/?_gremove:n} {#2} } |
| 857 |
{ |
| 858 |
\cs_if_exist:cTF |
| 859 |
{ @@_handler/#1/#2_gremove: } |
| 860 |
{ \use:c {@@_handler/#1/#2_gremove:} } %special handler |
| 861 |
{ |
| 862 |
\exp_args:Nne |
| 863 |
\prop_gremove:cn |
| 864 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/#1 } } |
| 865 |
{ \str_convert_pdfname:n {#2} } |
| 866 |
} |
| 867 |
} |
| 868 |
} |
| 869 |
{ |
| 870 |
\msg_error:nnn { pdfmanagement } { unknown-dict } { #1 } |
| 871 |
} |
| 872 |
} |
| 873 |
|
| 874 |
\cs_new_protected:Npn \@@_gremove:nn #1 #2 %path,key |
| 875 |
{ |
| 876 |
\pdfdict_if_exist:nTF { g__pdf_Core/#1 } |
| 877 |
{ |
| 878 |
\exp_args:Nne |
| 879 |
\prop_gremove:cn |
| 880 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/#1 } } |
| 881 |
{ \str_convert_pdfname:n{#2} } |
| 882 |
} |
| 883 |
{ |
| 884 |
\msg_error:nnn { pdfmanagement } { unknown-dict } { #1 } |
| 885 |
} |
| 886 |
} |
| 887 |
|
| 888 |
|
| 889 |
\cs_new_protected:Npn \@@_show:Nn #1#2 |
| 890 |
{ |
| 891 |
\cs_if_exist:cTF |
| 892 |
{ @@_handler/#2/?_show: } %general, name independent handler |
| 893 |
{ \use:c {@@_handler/#2/?_show:} } |
| 894 |
{ |
| 895 |
\prop_if_exist:cTF { \__kernel_pdfdict_name:n { g__pdf_Core/#2 } } |
| 896 |
{ |
| 897 |
#1 |
| 898 |
{ pdfmanagement } { show-dict } |
| 899 |
{ \tl_to_str:n {#2} } |
| 900 |
{ |
| 901 |
\prop_map_function:cN |
| 902 |
{\__kernel_pdfdict_name:n { g__pdf_Core/#2 }} |
| 903 |
\msg_show_item:nn |
| 904 |
} |
| 905 |
{ } { } |
| 906 |
} |
| 907 |
{ |
| 908 |
#1 { pdfmanagement } { unknown-dict } {#2}{}{}{} |
| 909 |
} |
| 910 |
} |
| 911 |
} |
| 912 |
|
| 913 |
\cs_new_protected:Npn \@@_show:n #1 %path |
| 914 |
{ |
| 915 |
\prop_show:c { \__kernel_pdfdict_name:n { g__pdf_Core/#1 } } |
| 916 |
} |
| 917 |
% \end{macrocode} |
| 918 |
% \end{macro} |
| 919 |
% |
| 920 |
% |
| 921 |
% \begin{macrocode} |
| 922 |
\cs_new_protected:Npn \pdfmanagement_show:n #1 |
| 923 |
{ |
| 924 |
\@@_show:Nn \msg_show:nneeee {#1} |
| 925 |
} |
| 926 |
% \end{macrocode} |
| 927 |
% \begin{macrocode} |
| 928 |
\cs_new_protected:Npn \pdfmanagement_remove:nn #1 #2 |
| 929 |
{ |
| 930 |
\pdfdict_if_exist:nTF { g__pdf_Core/#1 } |
| 931 |
{ |
| 932 |
\@@_handler_gremove:nn { #1 }{ #2 } |
| 933 |
} |
| 934 |
{ |
| 935 |
\msg_error:nnn{pdfmanagement}{unknown-dict}{#1} |
| 936 |
} |
| 937 |
} |
| 938 |
% \end{macrocode} |
| 939 |
% \begin{macrocode} |
| 940 |
\cs_new_protected:Npn \pdfmanagement_get:nnN #1 #2 #3 |
| 941 |
{ |
| 942 |
\pdfdict_if_exist:nTF { g__pdf_Core/#1 } |
| 943 |
{ |
| 944 |
\@@_get:nnN { #1 }{ #2 } #3 |
| 945 |
} |
| 946 |
{ |
| 947 |
\msg_error:nnn{pdfmanagement}{unknown-dict}{#1} |
| 948 |
} |
| 949 |
} |
| 950 |
% \end{macrocode} |
| 951 |
% \subsection{The Info dictionary} |
| 952 |
% Initialization of the dictionary: |
| 953 |
% \begin{macrocode} |
| 954 |
\pdfdict_new:n { g__pdf_Core/Info} |
| 955 |
% \end{macrocode} |
| 956 |
% |
| 957 |
% \begin{macro}{\@@_Info_gpush:} |
| 958 |
% \cs{@@_Info_gpush:} is the command that outputs the info dictionary (currently |
| 959 |
% in the end-of-run hooks). |
| 960 |
% \begin{macrocode} |
| 961 |
% push to the register command / issue the special |
| 962 |
\cs_new_protected:Npn \@@_Info_gpush: |
| 963 |
{ |
| 964 |
\prop_map_function:cN |
| 965 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Info} } |
| 966 |
\__pdf_backend_info_gput:nn |
| 967 |
\prop_gclear:c { \__kernel_pdfdict_name:n { g__pdf_Core/Info} } |
| 968 |
} |
| 969 |
% \end{macrocode} |
| 970 |
% \end{macro} |
| 971 |
% \subsection{The Pages dictionary code} |
| 972 |
% \begin{NOTE}{UF} |
| 973 |
% The register is normally used only a few times in a document, so it would be |
| 974 |
% okay to update the register/add the special at every change, |
| 975 |
% but with dvips/dvipdfmx this would disable removing entries. |
| 976 |
% So we issue the push code only at the end of the document. |
| 977 |
% \end{NOTE} |
| 978 |
% At first the initialisation |
| 979 |
% \begin{macrocode} |
| 980 |
\pdfdict_new:n { g__pdf_Core/Pages} |
| 981 |
% \end{macrocode} |
| 982 |
% |
| 983 |
% \begin{macro}{\@@_Pages_gpush:} |
| 984 |
% This is the command that outputs the Pages dictionary. It is used |
| 985 |
% at the end of the document in \cs{g__pdf_backend_end_run_tl} |
| 986 |
% \begin{macrocode} |
| 987 |
% push to the register command / issue the special |
| 988 |
\cs_new_protected:Npn \@@_Pages_gpush: |
| 989 |
{ |
| 990 |
\pdfdict_if_empty:nF { g__pdf_Core/Pages} |
| 991 |
{ |
| 992 |
\exp_args:Ne \__pdf_backend_Pages_primitive:n |
| 993 |
{ |
| 994 |
\pdfdict_use:n { g__pdf_Core/Pages} |
| 995 |
} |
| 996 |
} |
| 997 |
} |
| 998 |
|
| 999 |
% \end{macrocode} |
| 1000 |
% \end{macro} |
| 1001 |
% \subsection{The Page and ThisPage dictionary} |
| 1002 |
% At first the initialisation. |
| 1003 |
% \begin{macrocode} |
| 1004 |
\pdfdict_new:n { g__pdf_Core/Page } |
| 1005 |
\pdfdict_new:n { g__pdf_Core/ThisPage } |
| 1006 |
|
| 1007 |
%handler for pdfmanagement |
| 1008 |
\cs_new_protected:cpn { @@_handler/Page/?_gput:nn } #1 #2 |
| 1009 |
{ |
| 1010 |
\__pdf_backend_Page_gput:nn { #1 }{ #2 } |
| 1011 |
} |
| 1012 |
% remove: |
| 1013 |
\cs_new_protected:cpn { @@_handler/Page/?_gremove:n } #1 |
| 1014 |
{ |
| 1015 |
\__pdf_backend_Page_gremove:n { #1 } |
| 1016 |
} |
| 1017 |
|
| 1018 |
% handler for pdfmanagement |
| 1019 |
\cs_new_protected:cpn { @@_handler/ThisPage/?_gput:nn } #1 #2 |
| 1020 |
{ |
| 1021 |
\prop_gput:cnn { \__kernel_pdfdict_name:n { g__pdf_Core/ThisPage } }{ #1 } { #2 } |
| 1022 |
\__pdf_backend_ThisPage_gput:nn { #1 }{ #2 } |
| 1023 |
} |
| 1024 |
|
| 1025 |
\cs_new_protected:cpn { @@_handler/ThisPage/?_gremove:n } #1 |
| 1026 |
{ |
| 1027 |
\msg_warning:nnn { pdfmanagement } { no-removal }{ThisPage} |
| 1028 |
} |
| 1029 |
|
| 1030 |
\cs_new_protected:cpn { @@_handler/ThisPage/?_show: } |
| 1031 |
{ |
| 1032 |
\msg_warning:nnn { pdfmanagement } { no-show }{ThisPage} |
| 1033 |
} |
| 1034 |
|
| 1035 |
% \end{macrocode} |
| 1036 |
% \subsubsection{\enquote{Page/Resources}: ExtGState, ColorSpace, Shading, Pattern} |
| 1037 |
% \begin{macrocode} |
| 1038 |
\clist_const:Nn \c_@@_PageResources_clist |
| 1039 |
{ |
| 1040 |
ExtGState, |
| 1041 |
ColorSpace, |
| 1042 |
Pattern, |
| 1043 |
Shading, |
| 1044 |
} |
| 1045 |
|
| 1046 |
\clist_map_inline:Nn \c_@@_PageResources_clist |
| 1047 |
{ |
| 1048 |
\pdfdict_new:n { g__pdf_Core/Page/Resources/#1} |
| 1049 |
} |
| 1050 |
% |
| 1051 |
% setter: #1 is the name of the resource |
| 1052 |
\cs_new_protected:cpn { @@_handler/Page/Resources/ExtGState/?_gput:nn } #1 #2 |
| 1053 |
{ |
| 1054 |
\__pdf_backend_PageResources_gput:nnn {ExtGState} { #1 }{ #2 } |
| 1055 |
} |
| 1056 |
|
| 1057 |
\cs_new_protected:cpn { @@_handler/Page/Resources/ColorSpace/?_gput:nn } #1 #2 |
| 1058 |
{ |
| 1059 |
\__pdf_backend_PageResources_gput:nnn {ColorSpace} { #1 }{ #2 } |
| 1060 |
} |
| 1061 |
|
| 1062 |
\cs_new_protected:cpn { @@_handler/Page/Resources/Shading/?_gput:nn } #1 #2 |
| 1063 |
{ |
| 1064 |
\__pdf_backend_PageResources_gput:nnn {Shading} { #1 }{ #2 } |
| 1065 |
} |
| 1066 |
|
| 1067 |
\cs_new_protected:cpn { @@_handler/Page/Resources/Pattern/?_gput:nn } #1 #2 |
| 1068 |
{ |
| 1069 |
\__pdf_backend_PageResources_gput:nnn {Pattern} { #1 }{ #2 } |
| 1070 |
} |
| 1071 |
% \end{macrocode} |
| 1072 |
% \subsubsection{\enquote{Catalog}} |
| 1073 |
% The catalog has mixed entries: toplevel, subdictionaries, and entries |
| 1074 |
% which must build arrays. |
| 1075 |
% \begin{variable}[added=2019-08-24] |
| 1076 |
% { |
| 1077 |
% \c_@@_Catalog_toplevel_clist, |
| 1078 |
% \c_@@_Catalog_sub_clist, |
| 1079 |
% \c_@@_Catalog_seq_clist, |
| 1080 |
% } |
| 1081 |
% This variables hold the list of the various types of entries. With it |
| 1082 |
% the various \verb=_gput= commands are generated. |
| 1083 |
% \end{variable} |
| 1084 |
% \begin{macro}{ \@@_catalog_XX_gput:n } |
| 1085 |
% Various commands to handle subentries and special cases. |
| 1086 |
% At first we set up a few lists of the various types. |
| 1087 |
% \begin{macrocode} |
| 1088 |
\pdfdict_new:n { g__pdf_Core/Catalog} |
| 1089 |
|
| 1090 |
\clist_const:Nn \c_@@_Catalog_toplevel_clist |
| 1091 |
{ |
| 1092 |
Collection, |
| 1093 |
DPartRoot, |
| 1094 |
Lang, |
| 1095 |
Legal, |
| 1096 |
Metadata, |
| 1097 |
NeedsRendering, |
| 1098 |
OCProperties/D, |
| 1099 |
OpenAction, |
| 1100 |
PageLabels, |
| 1101 |
PageLayout, |
| 1102 |
PageMode, |
| 1103 |
Perms, |
| 1104 |
PieceInfo, |
| 1105 |
SpiderInfo, |
| 1106 |
StructTreeRoot, |
| 1107 |
Threads, |
| 1108 |
URI, |
| 1109 |
Version |
| 1110 |
} |
| 1111 |
|
| 1112 |
\clist_const:Nn \c_@@_Catalog_sub_clist |
| 1113 |
{ |
| 1114 |
AA, |
| 1115 |
AcroForm, |
| 1116 |
AcroForm/DR, |
| 1117 |
AcroForm/DR/Font, |
| 1118 |
MarkInfo, |
| 1119 |
ViewerPreferences, |
| 1120 |
OCProperties |
| 1121 |
} |
| 1122 |
|
| 1123 |
\clist_map_inline:Nn \c_@@_Catalog_sub_clist |
| 1124 |
{ |
| 1125 |
\pdfdict_new:n { g__pdf_Core/Catalog/#1} |
| 1126 |
} |
| 1127 |
|
| 1128 |
|
| 1129 |
\clist_const:Nn \c_@@_Catalog_seq_clist |
| 1130 |
{ |
| 1131 |
AF, |
| 1132 |
OCProperties/OCGs, |
| 1133 |
OCProperties/Configs, |
| 1134 |
OutputIntents, |
| 1135 |
Requirements, |
| 1136 |
AcroForm/Fields, |
| 1137 |
AcroForm/CO |
| 1138 |
} |
| 1139 |
|
| 1140 |
% \end{macrocode} |
| 1141 |
% Names trees in Catalog/Names. We prepare the full list |
| 1142 |
% but activate only AP and JavaScript for now. |
| 1143 |
% /EmbeddedFiles has special code and so is not in the name list. |
| 1144 |
% \begin{macrocode} |
| 1145 |
\clist_const:Nn \c_@@_Catalog_nametree_clist |
| 1146 |
{ |
| 1147 |
AP, |
| 1148 |
JavaScript, |
| 1149 |
% Pages, |
| 1150 |
% Templates, |
| 1151 |
% IDS, |
| 1152 |
% URLS, |
| 1153 |
% Renditions |
| 1154 |
} |
| 1155 |
% \end{macrocode} |
| 1156 |
% now we create the handler. The entries in the seq-list store in a seq |
| 1157 |
% \begin{macrocode} |
| 1158 |
\clist_map_inline:Nn \c_@@_Catalog_seq_clist |
| 1159 |
{ |
| 1160 |
\seq_new:c { g_@@_/Catalog/#1_seq } % new name later |
| 1161 |
\cs_new_protected:cpn { @@_handler/Catalog/#1_gput:n } ##1 |
| 1162 |
{ |
| 1163 |
\seq_gput_right:cn { g_@@_/Catalog/#1_seq } { ##1 } |
| 1164 |
} |
| 1165 |
} |
| 1166 |
|
| 1167 |
% \end{macrocode} |
| 1168 |
% OCProperties/D is special: it handles a default. This is done by adding to |
| 1169 |
% the left of the seq |
| 1170 |
% \begin{macrocode} |
| 1171 |
\cs_new_protected:cpn { @@_handler/Catalog/OCProperties/D_gput:n } #1 |
| 1172 |
{ |
| 1173 |
\seq_gput_left:cn |
| 1174 |
{ g_@@_/Catalog/OCProperties/Configs_seq } |
| 1175 |
{ #1 } |
| 1176 |
} |
| 1177 |
% \end{macrocode} |
| 1178 |
% The name tree keys store in a property and check for duplicates. This is done |
| 1179 |
% with an auxiliary. |
| 1180 |
% \begin{macrocode} |
| 1181 |
\cs_new_protected:Npn \@@_nametree_add_aux:nnn #1 #2 #3 |
| 1182 |
%#1 name tree, #2 sanitized name #3 value |
| 1183 |
{ |
| 1184 |
\prop_get:coNTF |
| 1185 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/Names/#1 }} |
| 1186 |
{ #2 } |
| 1187 |
\l_@@_tmpb_tl |
| 1188 |
{ |
| 1189 |
\msg_error:nnnn{pdfmanagement}{name-exist}{#2}{#1} |
| 1190 |
} |
| 1191 |
{ |
| 1192 |
\prop_gput:con |
| 1193 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/Names/#1 }} |
| 1194 |
{ #2 } |
| 1195 |
{ #3 } |
| 1196 |
} |
| 1197 |
} |
| 1198 |
% \end{macrocode} |
| 1199 |
% This is the standard handler for most names trees: |
| 1200 |
% \begin{macrocode} |
| 1201 |
\clist_map_inline:Nn \c_@@_Catalog_nametree_clist |
| 1202 |
{ |
| 1203 |
\pdfdict_new:n { g__pdf_Core/Catalog/Names/#1} |
| 1204 |
\cs_new_protected:cpn { @@_handler/Catalog/Names/#1/?_gput:nn } ##1 ##2 |
| 1205 |
{ |
| 1206 |
\pdf_string_from_unicode:nnN {utf8/string}{##1}\l_@@_tmpa_tl |
| 1207 |
\exp_args:Nno |
| 1208 |
\@@_nametree_add_aux:nnn {#1}{\l_@@_tmpa_tl}{##2} |
| 1209 |
} |
| 1210 |
} |
| 1211 |
% \end{macrocode} |
| 1212 |
% EmbeddedFiles is a bit special. For once there is special backend code |
| 1213 |
% needed by dvips. Beside this we also want the option to create the file name |
| 1214 |
% on the fly, so they are actually two access methods: |
| 1215 |
% |\pdfmanagement_add:nnn{Catalog/Names/EmbeddedFiles}{name}{reference}| |
| 1216 |
% and |
| 1217 |
% |\pdfmanagement_add:nnn{Catalog/Names}{EmbeddedFiles}{reference}| |
| 1218 |
% \begin{macrocode} |
| 1219 |
\pdfdict_new:n { g__pdf_Core/Catalog/Names/EmbeddedFiles} |
| 1220 |
\cs_new_protected:cpn { @@_handler/Catalog/Names/EmbeddedFiles/?_gput:nn } #1 #2 |
| 1221 |
{ |
| 1222 |
\pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_tmpa_tl |
| 1223 |
\exp_args:Nno |
| 1224 |
\@@_nametree_add_aux:nnn |
| 1225 |
{EmbeddedFiles}{\l_@@_tmpa_tl}{#2} |
| 1226 |
\exp_args:No |
| 1227 |
\__pdf_backend_NamesEmbeddedFiles_add:nn {\l_@@_tmpa_tl}{#2} |
| 1228 |
} |
| 1229 |
% \end{macrocode} |
| 1230 |
% \end{macro} |
| 1231 |
% % \paragraph {Building the catalog: Push order} |
| 1232 |
% \begin{macro}{\@@_Catalog_gpush:} |
| 1233 |
% \begin{macrocode} |
| 1234 |
\cs_new_protected:Npn \@@_Catalog_gpush: |
| 1235 |
{ |
| 1236 |
\use:c { @@_/Catalog/AA_gpush: } |
| 1237 |
\use:c { @@_/Catalog/AcroForm_gpush: } |
| 1238 |
\use:c { @@_/Catalog/AF_gpush: } |
| 1239 |
\use:c { @@_/Catalog/MarkInfo_gpush: } |
| 1240 |
\pdfmeta_standard_verify:nT {Catalog_no_OCProperties} |
| 1241 |
{ |
| 1242 |
\use:c { @@_/Catalog/OCProperties_gpush: } |
| 1243 |
} |
| 1244 |
\use:c { @@_/Catalog/OutputIntents_gpush: } |
| 1245 |
\use:c { @@_/Catalog/Requirements_gpush: } |
| 1246 |
\use:c { @@_/Catalog/ViewerPreferences_gpush: } |
| 1247 |
% output the single values: |
| 1248 |
\prop_map_function:cN |
| 1249 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog} } |
| 1250 |
\__pdf_backend_catalog_gput:nn |
| 1251 |
% output names tree: |
| 1252 |
\use:c{ @@_/Catalog/Names_gpush:n } {EmbeddedFiles} |
| 1253 |
\clist_map_inline:Nn \c_@@_Catalog_nametree_clist |
| 1254 |
{ |
| 1255 |
\use:c{ @@_/Catalog/Names_gpush:n } {##1} |
| 1256 |
} |
| 1257 |
} |
| 1258 |
% \end{macrocode} |
| 1259 |
% \end{macro} |
| 1260 |
% \paragraph{Building catalog entries: AA} |
| 1261 |
% \begin{macro}{\@@_/Catalog/AA_gpush:} |
| 1262 |
% \begin{macrocode} |
| 1263 |
\cs_new_protected:cpn { @@_/Catalog/AA_gpush: } |
| 1264 |
{ |
| 1265 |
\prop_if_empty:cF |
| 1266 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AA } } |
| 1267 |
{ |
| 1268 |
\pdf_object_new:n { @@/Catalog/AA } |
| 1269 |
\pdf_object_write:nne |
| 1270 |
{ @@/Catalog/AA }{ dict } |
| 1271 |
{ \pdfdict_use:n { g__pdf_Core/Catalog/AA } } |
| 1272 |
\exp_args:Nne |
| 1273 |
\__pdf_backend_catalog_gput:nn |
| 1274 |
{AA} |
| 1275 |
{ |
| 1276 |
\pdf_object_ref:n { @@/Catalog/AA } |
| 1277 |
} |
| 1278 |
} |
| 1279 |
} |
| 1280 |
% \end{macrocode} |
| 1281 |
% \end{macro} |
| 1282 |
% |
| 1283 |
% \paragraph{Building catalog entries: AcroForm} |
| 1284 |
% This is the most complicated case. |
| 1285 |
% The entries is build from |
| 1286 |
% /Catalog/AcroForm/Fields (array), |
| 1287 |
% /Catalog/AcroForm/CO (array), |
| 1288 |
% /Catalog/AcroForm/DR/Font (dict), |
| 1289 |
% /Catalog/AcroForm/DR (dict), |
| 1290 |
% /Catalog/AcroForm |
| 1291 |
% |
| 1292 |
% \begin{macro}{\@@_/Catalog/AcroForm_gpush:} |
| 1293 |
% \begin{macrocode} |
| 1294 |
\cs_new_protected:cpn { @@_/Catalog/AcroForm_gpush: } |
| 1295 |
{ |
| 1296 |
\seq_if_empty:cF { g_@@_/Catalog/AcroForm/Fields_seq } |
| 1297 |
{ |
| 1298 |
\pdf_object_new:n { @@/Catalog/AcroForm/Fields } |
| 1299 |
\pdf_object_write:nne |
| 1300 |
{ @@/Catalog/AcroForm/Fields } { array } |
| 1301 |
{ \seq_use:cn { g_@@_/Catalog/AcroForm/Fields_seq } {~} } |
| 1302 |
\exp_args:Nnne |
| 1303 |
\prop_gput:cnn %we have to use \prop here to avoid the handler ... |
| 1304 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm } } |
| 1305 |
{ Fields } |
| 1306 |
{ \pdf_object_ref:n { @@/Catalog/AcroForm/Fields } } |
| 1307 |
} |
| 1308 |
\seq_if_empty:cF { g_@@_/Catalog/AcroForm/CO_seq } |
| 1309 |
{ |
| 1310 |
\pdf_object_new:n { @@/Catalog/AcroForm/CO } |
| 1311 |
\pdf_object_write:nne |
| 1312 |
{ @@/Catalog/AcroForm/CO } { array } |
| 1313 |
{ \seq_use:cn { g_@@_/Catalog/AcroForm/CO_seq } {~} } |
| 1314 |
\exp_args:Nnne |
| 1315 |
\prop_gput:cnn %we have to use \prop here to avoid the handler ... |
| 1316 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm } } |
| 1317 |
{ CO } |
| 1318 |
{ \pdf_object_ref:n { @@/Catalog/AcroForm/CO } } |
| 1319 |
} |
| 1320 |
\prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm/DR/Font}} |
| 1321 |
{ |
| 1322 |
\pdf_object_new:n { @@/Catalog/AcroForm/DR/Font } |
| 1323 |
\pdf_object_write:nne |
| 1324 |
{ @@/Catalog/AcroForm/DR/Font } { dict } |
| 1325 |
{ \pdfdict_use:n { g__pdf_Core/Catalog/AcroForm/DR/Font } } |
| 1326 |
\exp_args:Nnne |
| 1327 |
\prop_gput:cnn %we have to use \prop here to avoid the handler ... |
| 1328 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm/DR } } |
| 1329 |
{ Font } |
| 1330 |
{ \pdf_object_ref:n { @@/Catalog/AcroForm/DR/Font } } |
| 1331 |
} |
| 1332 |
\prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm/DR}} |
| 1333 |
{ |
| 1334 |
\pdf_object_new:n { @@/Catalog/AcroForm/DR } |
| 1335 |
\pdf_object_write:nne |
| 1336 |
{ @@/Catalog/AcroForm/DR } { dict } |
| 1337 |
{ \pdfdict_use:n { g__pdf_Core/Catalog/AcroForm/DR } } |
| 1338 |
\exp_args:Nnne |
| 1339 |
\prop_gput:cnn %we have to use \prop here to avoid the handler ... |
| 1340 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm } } |
| 1341 |
{ DR } |
| 1342 |
{ \pdf_object_ref:n { @@/Catalog/AcroForm/DR } } |
| 1343 |
} |
| 1344 |
\prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm} } |
| 1345 |
{ |
| 1346 |
\pdf_object_new:n { @@/Catalog/AcroForm } |
| 1347 |
\pdf_object_write:nne |
| 1348 |
{ @@/Catalog/AcroForm } { dict } |
| 1349 |
{ \pdfdict_use:n { g__pdf_Core/Catalog/AcroForm } } |
| 1350 |
\exp_args:Nnne |
| 1351 |
\@@_handler_gput:nnn |
| 1352 |
{ Catalog } |
| 1353 |
{ AcroForm } |
| 1354 |
{ \pdf_object_ref:n { @@/Catalog/AcroForm } } |
| 1355 |
} |
| 1356 |
} |
| 1357 |
|
| 1358 |
% \end{macrocode} |
| 1359 |
% \end{macro} |
| 1360 |
% |
| 1361 |
% \paragraph{Building catalog entries: AF} |
| 1362 |
% AF is an array. |
| 1363 |
% \begin{macro}{\@@_/Catalog/AF_gpush:} |
| 1364 |
% \begin{macrocode} |
| 1365 |
\cs_new_protected:cpn { @@_/Catalog/AF_gpush: } |
| 1366 |
{ |
| 1367 |
\seq_if_empty:cF |
| 1368 |
{ g_@@_/Catalog/AF_seq } |
| 1369 |
{ |
| 1370 |
\pdf_object_new:n { @@/Catalog/AF } |
| 1371 |
\pdf_object_write:nne |
| 1372 |
{ @@/Catalog/AF } { array } |
| 1373 |
{ \seq_use:cn { g_@@_/Catalog/AF_seq } {~} } |
| 1374 |
\exp_args:Nne |
| 1375 |
\__pdf_backend_catalog_gput:nn |
| 1376 |
{AF} |
| 1377 |
{ |
| 1378 |
\pdf_object_ref:n {@@/Catalog/AF} |
| 1379 |
} |
| 1380 |
} |
| 1381 |
} |
| 1382 |
% \end{macrocode} |
| 1383 |
% \end{macro} |
| 1384 |
% % |
| 1385 |
% \paragraph{Building catalog entries: MarkInfo} |
| 1386 |
% \begin{macro}{\@@_/Catalog/MarkInfo_gpush:} |
| 1387 |
% \begin{macrocode} |
| 1388 |
\cs_new_protected:cpn { @@_/Catalog/MarkInfo_gpush: } |
| 1389 |
{ |
| 1390 |
\prop_if_empty:cF |
| 1391 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/MarkInfo } } |
| 1392 |
{ |
| 1393 |
\pdf_object_new:n { @@/Catalog/MarkInfo } |
| 1394 |
\pdf_object_write:nne |
| 1395 |
{ @@/Catalog/MarkInfo } { dict } |
| 1396 |
{ \pdfdict_use:n { g__pdf_Core/Catalog/MarkInfo } } |
| 1397 |
\exp_args:Nne |
| 1398 |
\__pdf_backend_catalog_gput:nn |
| 1399 |
{MarkInfo} |
| 1400 |
{ |
| 1401 |
\pdf_object_ref:n {@@/Catalog/MarkInfo} |
| 1402 |
} |
| 1403 |
} |
| 1404 |
} |
| 1405 |
% \end{macrocode} |
| 1406 |
% \end{macro} |
| 1407 |
% |
| 1408 |
%\paragraph{Building catalog entries: OCProperties} |
| 1409 |
% This is a dictionary with three entries: |
| 1410 |
% \begin{description} |
| 1411 |
% \item[/OCGs] (required) An array of indirect references, |
| 1412 |
% access needed for more than one package. |
| 1413 |
% \item[/D] (required) a dict (given as an object name) to the default |
| 1414 |
% configuration |
| 1415 |
% \item[/Configs] (optional) an array of indirect references to more |
| 1416 |
% configurations. |
| 1417 |
% \end{description} |
| 1418 |
% The /D entry is also a config, it is the first of the seq. |
| 1419 |
% The overall structure is nested: a dict with arrays. |
| 1420 |
% \begin{macro}{\@@_/Catalog/OCProperties_gpush:} |
| 1421 |
% \begin{macrocode} |
| 1422 |
% Catalog/OCProperties: OCGs + D is required |
| 1423 |
\cs_new_protected:cpn { @@_/Catalog/OCProperties_gpush: } |
| 1424 |
{ |
| 1425 |
\int_compare:nNnT |
| 1426 |
{ |
| 1427 |
( \seq_count:c { g_@@_/Catalog/OCProperties/OCGs_seq } )* |
| 1428 |
( \seq_count:c { g_@@_/Catalog/OCProperties/Configs_seq } ) |
| 1429 |
} |
| 1430 |
> |
| 1431 |
{ 0 } |
| 1432 |
{ |
| 1433 |
\pdf_object_new:n { @@/Catalog/OCProperties } |
| 1434 |
\seq_gpop_left:cN { g_@@_/Catalog/OCProperties/Configs_seq} \l_@@_tmpa_tl |
| 1435 |
\pdf_object_write:nne {@@/Catalog/OCProperties} {dict} |
| 1436 |
{ |
| 1437 |
/OCGs~[ \seq_use:cn { g_@@_/Catalog/OCProperties/OCGs_seq } {~} ] |
| 1438 |
/D~\l_@@_tmpa_tl~ |
| 1439 |
\seq_if_empty:cF { g_@@_/Catalog/OCProperties/Configs_seq } |
| 1440 |
{ |
| 1441 |
/Configs~ |
| 1442 |
[ \seq_use:cn { g_@@_/Catalog/OCProperties/Configs_seq} {~} ] |
| 1443 |
} |
| 1444 |
} |
| 1445 |
\exp_args:Nne |
| 1446 |
\__pdf_backend_catalog_gput:nn |
| 1447 |
{ OCProperties } |
| 1448 |
{ \pdf_object_ref:n {@@/Catalog/OCProperties} } |
| 1449 |
} |
| 1450 |
} |
| 1451 |
% \end{macrocode} |
| 1452 |
% \end{macro} |
| 1453 |
% |
| 1454 |
% \paragraph{Building catalog entries: OutputIntents} |
| 1455 |
% OutputIntents is an array. |
| 1456 |
% \begin{macro}{\@@_/Catalog/OutputIntents_gpush:} |
| 1457 |
% \begin{macrocode} |
| 1458 |
\cs_new_protected:cpn { @@_/Catalog/OutputIntents_gpush: } |
| 1459 |
{ |
| 1460 |
\seq_if_empty:cF |
| 1461 |
{ g_@@_/Catalog/OutputIntents_seq } |
| 1462 |
{ |
| 1463 |
\pdf_object_new:n { @@/Catalog/OutputIntents } |
| 1464 |
\pdf_object_write:nne |
| 1465 |
{ @@/Catalog/OutputIntents } { array } |
| 1466 |
{ \seq_use:cn { g_@@_/Catalog/OutputIntents_seq } {~} } |
| 1467 |
\exp_args:Nne |
| 1468 |
\__pdf_backend_catalog_gput:nn |
| 1469 |
{OutputIntents} |
| 1470 |
{ |
| 1471 |
\pdf_object_ref:n {@@/Catalog/OutputIntents} |
| 1472 |
} |
| 1473 |
} |
| 1474 |
} |
| 1475 |
% \end{macrocode} |
| 1476 |
% \end{macro} |
| 1477 |
% |
| 1478 |
% \paragraph{Building catalog entries: Requirements} |
| 1479 |
% Requirements is an array. |
| 1480 |
% \begin{macro}{\@@_/Catalog/Requirements_gpush:} |
| 1481 |
% \begin{macrocode} |
| 1482 |
\cs_new_protected:cpn { @@_/Catalog/Requirements_gpush: } |
| 1483 |
{ |
| 1484 |
\seq_if_empty:cF |
| 1485 |
{ g_@@_/Catalog/Requirements_seq } |
| 1486 |
{ |
| 1487 |
\pdf_object_new:n { @@/Catalog/Requirements } |
| 1488 |
\pdf_object_write:nne |
| 1489 |
{ @@/Catalog/Requirements } { array } |
| 1490 |
{ \seq_use:cn { g_@@_/Catalog/Requirements_seq } {~} } |
| 1491 |
\exp_args:Nne |
| 1492 |
\__pdf_backend_catalog_gput:nn |
| 1493 |
{Requirements} |
| 1494 |
{ |
| 1495 |
\pdf_object_ref:n { @@/Catalog/Requirements } |
| 1496 |
} |
| 1497 |
} |
| 1498 |
} |
| 1499 |
% \end{macrocode} |
| 1500 |
% \end{macro} |
| 1501 |
% |
| 1502 |
% |
| 1503 |
% \paragraph{Building catalog entries: ViewerPreferences} |
| 1504 |
% \begin{macro}{\@@_/Catalog/ViewerPreferences_gpush:} |
| 1505 |
% \begin{macrocode} |
| 1506 |
\cs_new_protected:cpn { @@_/Catalog/ViewerPreferences_gpush: } |
| 1507 |
{ |
| 1508 |
\prop_if_empty:cF |
| 1509 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/ViewerPreferences } } |
| 1510 |
{ |
| 1511 |
\pdf_object_new:n { @@/Catalog/ViewerPreferences } |
| 1512 |
\pdf_object_write:nne |
| 1513 |
{ @@/Catalog/ViewerPreferences } { dict } |
| 1514 |
{ \pdfdict_use:n { g__pdf_Core/Catalog/ViewerPreferences } } |
| 1515 |
\exp_args:Nne |
| 1516 |
\__pdf_backend_catalog_gput:nn |
| 1517 |
{ViewerPreferences} |
| 1518 |
{ |
| 1519 |
\pdf_object_ref:n {@@/Catalog/ViewerPreferences} |
| 1520 |
} |
| 1521 |
} |
| 1522 |
} |
| 1523 |
% \end{macrocode} |
| 1524 |
% \end{macro} |
| 1525 |
% \paragraph{Building catalog entries: Names/EmbeddedFiles} |
| 1526 |
% \begin{NOTE}{UF} |
| 1527 |
% TODO access function for the name in the name tree |
| 1528 |
% \end{NOTE} |
| 1529 |
% \begin{variable}{\g_@@_EmbeddedFiles_int} |
| 1530 |
% We want to create names for files on the fly. For this we use an int. |
| 1531 |
% \begin{macrocode} |
| 1532 |
\int_new:N \g_@@_EmbeddedFiles_int |
| 1533 |
% \end{macrocode} |
| 1534 |
% \end{variable} |
| 1535 |
% \begin{macro}{\@@_EmbeddedFiles_name:} |
| 1536 |
% We use the prefix l3ef, and pad numbers below 9999. |
| 1537 |
% \begin{macrocode} |
| 1538 |
\cs_new:Npn \@@_EmbeddedFiles_name: |
| 1539 |
{ |
| 1540 |
( |
| 1541 |
l3ef |
| 1542 |
\int_compare:nNnT {\g_@@_EmbeddedFiles_int} < {10} |
| 1543 |
{0} |
| 1544 |
\int_compare:nNnT {\g_@@_EmbeddedFiles_int} < {100} |
| 1545 |
{0} |
| 1546 |
\int_compare:nNnT {\g_@@_EmbeddedFiles_int} < {1000} |
| 1547 |
{0} |
| 1548 |
\int_use:N \g_@@_EmbeddedFiles_int |
| 1549 |
) |
| 1550 |
} |
| 1551 |
% \end{macrocode} |
| 1552 |
% \end{macro} |
| 1553 |
% \begin{macro}{ \@@_handler/Catalog/Names/EmbeddedFiles_gput:n } |
| 1554 |
% EmbeddedFiles is an array and needs a special handler to add values. |
| 1555 |
% \begin{macrocode} |
| 1556 |
\pdfdict_new:n { g__pdf_Core/Catalog/Names } |
| 1557 |
|
| 1558 |
\cs_new_protected:cpn { @@_handler/Catalog/Names/EmbeddedFiles_gput:n } #1 |
| 1559 |
{ |
| 1560 |
\int_gincr:N \g_@@_EmbeddedFiles_int |
| 1561 |
\exp_args:Nne |
| 1562 |
\prop_gput:cnn |
| 1563 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/Names/EmbeddedFiles }} |
| 1564 |
{ \@@_EmbeddedFiles_name: } |
| 1565 |
{ #1 } |
| 1566 |
\exp_args:Ne |
| 1567 |
\__pdf_backend_NamesEmbeddedFiles_add:nn {\@@_EmbeddedFiles_name:} { #1 } |
| 1568 |
} |
| 1569 |
% \end{macrocode} |
| 1570 |
% \end{macro} |
| 1571 |
% This pushes out the other names trees (but not with dvips). |
| 1572 |
% TODO: currently it simply write in the root of the name tree. |
| 1573 |
% That is the fastest. |
| 1574 |
% If they get longer we perhaps need to build something with Kids and Limits. |
| 1575 |
% \begin{macro}{\@@_/Catalog/Names/?_gpush:} |
| 1576 |
% \begin{macrocode} |
| 1577 |
\cs_new_protected:cpn { @@_/Catalog/Names_gpush:n } #1 %#1 name of name tree |
| 1578 |
{ |
| 1579 |
\pdfdict_if_empty:nF { g__pdf_Core/Catalog/Names/#1 } |
| 1580 |
{ |
| 1581 |
\seq_clear:N \l_@@_tmpa_seq |
| 1582 |
\prop_map_inline:cn |
| 1583 |
{\__kernel_pdfdict_name:n { g__pdf_Core/Catalog/Names/#1 }} |
| 1584 |
{ \seq_put_right:Nn \l_@@_tmpa_seq {##1~##2}} |
| 1585 |
\seq_sort:Nn \l_@@_tmpa_seq |
| 1586 |
{ |
| 1587 |
\str_compare:nNnTF {##1} > {##2} |
| 1588 |
{ \sort_return_swapped: } |
| 1589 |
{ \sort_return_same: } |
| 1590 |
} |
| 1591 |
\exp_args:Nne \__pdf_backend_Names_gpush:nn |
| 1592 |
{#1} |
| 1593 |
{ |
| 1594 |
\seq_use:Nn \l_@@_tmpa_seq {~} |
| 1595 |
} |
| 1596 |
} |
| 1597 |
} |
| 1598 |
% \end{macrocode} |
| 1599 |
% \end{macro} |
| 1600 |
% \begin{macro}{@@_handler/Catalog/?_show:} |
| 1601 |
% A handler to show the catalog. |
| 1602 |
% \begin{macrocode} |
| 1603 |
\cs_new_protected:cpn {@@_handler/Catalog/?_show:} |
| 1604 |
{ |
| 1605 |
\iow_term:e |
| 1606 |
{ |
| 1607 |
\iow_newline: |
| 1608 |
The~Catalog~contains~in~the~top~level~the~single~value~entries |
| 1609 |
\prop_map_function:cN |
| 1610 |
{\__kernel_pdfdict_name:n { g__pdf_Core/Catalog }} |
| 1611 |
\msg_show_item:nn |
| 1612 |
} |
| 1613 |
\clist_map_inline:Nn \c_@@_Catalog_seq_clist |
| 1614 |
{ |
| 1615 |
\seq_if_empty:cF { g_@@_/Catalog/##1_seq } |
| 1616 |
{ |
| 1617 |
\iow_term:e |
| 1618 |
{ |
| 1619 |
The~'##1'~array~contains~the~entries |
| 1620 |
\seq_map_function:cN { g_@@_/Catalog/##1_seq } \msg_show_item:n |
| 1621 |
} |
| 1622 |
} |
| 1623 |
} |
| 1624 |
\clist_map_inline:Nn \c_@@_Catalog_sub_clist |
| 1625 |
{ |
| 1626 |
\prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/##1 } } |
| 1627 |
{ |
| 1628 |
\iow_term:e |
| 1629 |
{ |
| 1630 |
The~Catalog~subdirectory~'##1'~contains~the~single~value~entries |
| 1631 |
\prop_map_function:cN |
| 1632 |
{\__kernel_pdfdict_name:n { g__pdf_Core/Catalog/##1 }} |
| 1633 |
\msg_show_item:nn |
| 1634 |
} |
| 1635 |
} |
| 1636 |
} |
| 1637 |
\tl_show:e {\tl_to_str:n{\pdfmanagement_show:n{Catalog}}} |
| 1638 |
} |
| 1639 |
% \end{macrocode} |
| 1640 |
% \end{macro} |
| 1641 |
% \subsection{ xform / Properties } |
| 1642 |
% \begin{macrocode} |
| 1643 |
\pdfdict_new:n { g__pdf_Core/Xform/Resources/Properties} |
| 1644 |
% \end{macrocode} |
| 1645 |
% \begin{macrocode} |
| 1646 |
%</package> |
| 1647 |
% \end{macrocode} |
| 1648 |
% |
| 1649 |
% \end{implementation} |
| 1650 |
% |
| 1651 |
% \PrintIndex |