summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.dtx
blob: 0591756bf0fee50acdc2af5c54589f770351819d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
% \iffalse meta-comment
%
%% File: l3pdfxform.dtx
%
% Copyright (C) 2018-2021 The LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    http://www.latex-project.org/lppl.txt
%
% This file is part of the "LaTeX PDF management testphase bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    https://github.com/latex3/pdfresources
%
% for those people who are interested.
%
%<*driver>
\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{pdfstandard=A-2b}
\makeatletter
\declare@file@substitution{doc.sty}{doc-v3beta.sty}
\makeatother
\documentclass[full]{l3doc}
\usepackage{array,booktabs,hyperxmp}
\hypersetup{pdfauthor=The LaTeX Project,pdftitle=l3pdfxform (LaTeX PDF management testphase bundle)}

\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \title{^^A
%   The \pkg{l3pdfxform} module\\ Commands for form XObjects   ^^A
%   \\ \LaTeX{} PDF management testphase bundle
% }
%
% \author{^^A
%  The \LaTeX{} Project\thanks
%    {^^A
%      E-mail:
%        \href{mailto:latex-team@latex-project.org}
%          {latex-team@latex-project.org}^^A
%    }^^A
% }
%
% \date{Version 0.95h, released 2021-07-31}
%
% \maketitle
% \begin{documentation}
%
% \section{\pkg{l3pdfxform} documentation}
% This module contains a number of commands to create \enquote{form XObjects},
% for which pdf\TeX{} introduced the short name \enquote{xforms}.
%
% The status is still beta.
% The dvips route is now better supported but there are open issus
% if landscape pages are involved or if the objects are larger than the page.
% With dvips the creation of a form involves typesetting and so can affect spacing.
%
% Probably some of the function will also need to be enhanced by hooks.
%
%  \begin{function}[added = 2019-08-05,updated=2021-02-14]
%   {
%     \pdfxform_new:nnn
%   }
%   \begin{syntax}
%     \cs{pdfxform_new:nnn} \Arg{name} \Arg{attributes} \Arg{content}
%   \end{syntax}
%    This command create a new form XObject that can be used as appearance or
%    directly later.
%    If the \meta{content} contains BDC-marks it should \emph{not} be given as a
%    previously typeset box, but directly so that the names of the
%    BDC-marks can be added to the resources of the xform. The xform will automatically
%    include the resources of the current page.
%    The content will be typeset in a hbox. With pdflatex and luatex
%    the surrounding color is \emph{not} stored in the form XObject
%    but should be if wanted added e.g. with |\color_select:n{.}|. This keeps
%    the option of color injection open.
%   \end{function}
%   \begin{function}[added = 2019-08-05]
%     {
%      \pdfxform_use:n
%     }
%   \begin{syntax}
%     \cs{pdfxform_use:n} \Arg{name}
%   \end{syntax}
%    This command uses (typesets) a previously created form XObject.
%    If the surrounding color is different, it is injected in the form XObject with the
%    engines pdftex or luatex.
%   \end{function}
%   \begin{function}[EXP,added = 2019-08-05]
%     {
%       \pdfxform_ref:n
%     }
%   \begin{syntax}
%     \cs{pdfxform_ref:n} \Arg{name}
%   \end{syntax}
%   Inserts the appropriate information to reference the xform \meta{name}
%   in for example appearance dictionaries.
%   \end{function}
%   \begin{function}[EXP,added = 2019-08-05]
%     {
%       \pdfxform_wd:n, \pdfxform_ht:n, \pdfxform_dp:n
%     }
%   \begin{syntax}
%     \cs{pdfxform_wd:n} \Arg{name}
%   \end{syntax}
%    These command give back the sizes of the form XObject. The values are stored in
%    tl-variables with the unit pt and not in dimensions!
%   \end{function}
%   \begin{function}[EXP,pTF,added = 2020-04-29]
%     {
%       \pdfxform_if_exist:n
%     }
%   \begin{syntax}
%     \cs{pdfxform_if_exist_p:n} \Arg{name}
%     \cs{pdfxform_if_exist:nTF} \meta{name} \Arg{true code} \Arg{false code}
%   \end{syntax}
%    These command tests if an xform with name \Arg{name} has been already defined.
%   \end{function}%
% \end{documentation}
%
% \begin{implementation}
%
% \section{\pkg{l3pdfxform} implementation}
%
%    \begin{macrocode}
%<@@=pdf>
%<*header>
\ProvidesExplPackage{l3pdfxform}{2021-07-31}{0.95h}
  {command to create xforms (beta)---LaTeX PDF management testphase bundle}
%</header>
%    \end{macrocode}
% \subsection{Form XObject (pdfxform)}
% \begin{NOTE}{UF}
%  - As in dvi mode the xform is immediate, this is done for pdftex/luatex too.
%    If needed a delayed version can be added later.
%  - the argument for attributes is needed to add e.g. /StructParents
%  - it is not clear if an argument for additional resources is needed, probably they
%    should / need to be added automatically.
%  - code for adding ExtGState etc to the local resource is missing, will be
%    added when the object name is clear.
%  - should the size be stored in dim or tl?
%  - dvips implementation is missing for ideas: pdfbase, atfi-dvips.def,
%  \end{NOTE}
% \begin{macro}{\pdfxform_new:nnn}
%    \begin{macrocode}
%<*package>
\cs_new_protected:Npn  \pdfxform_new:nnn #1 #2 #3
  {
    \@@_backend_xform_new:nnnn { #1 } { #2 } {  } { #3 }
  }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pdfxform_use:n}
%    \begin{macrocode}
\cs_new_protected:Npn \pdfxform_use:n #1
  {
    \@@_backend_xform_use:n { #1 }
  }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pdfxform_ref:n,\pdfxform_ref:o}
%    \begin{macrocode}
% expansion?
\cs_new:Npn \pdfxform_ref:n #1
  {
    \@@_backend_xform_ref:n { #1 }
  }

\cs_generate_variant:Nn \pdfxform_ref:n {o}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pdfxform_wd:n,\pdfxform_ht:n,\pdfxform_dp:n,}
%    \begin{macrocode}
\cs_new:Npn \pdfxform_wd:n #1
  {
    \tl_use:c { c_@@_backend_xform_wd_ \tl_to_str:n { #1 } _tl }
  }

\cs_new:Npn \pdfxform_ht:n #1
  {
    \tl_use:c { c_@@_backend_xform_ht_ \tl_to_str:n { #1 } _tl }
  }

\cs_new:Npn \pdfxform_dp:n #1
  {
    \tl_use:c { c_@@_backend_xform_dp_ \tl_to_str:n { #1 } _tl }
  }
%    \end{macrocode}
% \end{macro}
% \begin{macro}[pTF]{\pdfxform_if_exist:n}
% The command is defined in the backend (to avoid timing problems).
% \end{macro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex