back-imp-pdf.mkxl /size: 6287 b    last modification: 2025-02-21 11:03
1
2%D \module
3%D   [       file=back-imp-pdf,
4%D        version=2009.04.15,
5%D          title=\CONTEXT\ Backend Macros,
6%D       subtitle=\PDF,
7%D         author=Hans Hagen,
8%D           date=\currentdate,
9%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
10%C
11%C This module is part of the \CONTEXT\ macro||package and is
12%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
13%C details.
14
15%D The less there is here, the better. After a decade it is time to remove the \type
16%D {\pdf*} ones completely. For the moment I keep them commented but even that will
17%D go away.
18
19%D Todo: a few delayed binding left:
20
21% ./lpdf-ini.lmt : reserve | immediate | positions | matrix | pos | fontobject
22% ./lpdf-lmt.lmt : fontname | object | boxresources
23% ./lpdf-rul.lmt : mp stuff
24% ./back-res.lmt : boxresources
25
26\writestatus{loading}{ConTeXt Backend Macros / PDF}
27
28% \registerctxluafile{back-imp-pdf}{autosuffix} % some code will move to lpdf-*
29
30\registerctxluafile{lpdf-ini}{autosuffix}
31\registerctxluafile{lpdf-lmt}{autosuffix}
32\registerctxluafile{lpdf-sig}{autosuffix,optional}
33\registerctxluafile{lpdf-col}{autosuffix}
34\registerctxluafile{lpdf-xmp}{autosuffix}
35\registerctxluafile{lpdf-ano}{autosuffix}
36\registerctxluafile{lpdf-mis}{autosuffix}
37\registerctxluafile{lpdf-ren}{autosuffix}
38\registerctxluafile{lpdf-grp}{autosuffix}
39\registerctxluafile{lpdf-wid}{autosuffix}
40\registerctxluafile{lpdf-fld}{autosuffix}
41\registerctxluafile{lpdf-tag}{autosuffix}
42\registerctxluafile{lpdf-fmt}{autosuffix}
43\registerctxluafile{lpdf-pde}{autosuffix}
44\registerctxluafile{lpdf-img}{autosuffix}
45\registerctxluafile{lpdf-epa}{autosuffix}
46\registerctxluafile{lpdf-emb}{autosuffix}
47\registerctxluafile{lpdf-fix}{autosuffix}
48\registerctxluafile{lpdf-rul}{autosuffix}
49
50\registerctxluafile{back-imp-pdf}{autosuffix} % some code will move to lpdf-*
51\registerctxluafile{back-imp-pdp}{autosuffix}
52
53\registerctxluafile{lpdf-fix-imp-fonts}   {autosuffix} % some code will move to lpdf-*
54\registerctxluafile{lpdf-fix-imp-contents}{autosuffix} % idem
55
56\registerctxluafile{lxml-mms}{autosuffix}
57
58% \registerctxluafile{lpdf-u3d}{autosuffix}
59
60\loadmkxlfile{back-imp-u3d}
61
62\unprotect
63
64%D We will minimize the number of calls to \PDF\ specific primitives and delegate
65%D all management and injection of code to the backend.
66%D
67%D Because we do a lot in \LUA\ and don't want interferences, we nil most of the
68%D \PDFTEX\ primitives. Of course one can always use the \type {\pdfvariable},
69%D \type {\pdfextension} and \type {\pdffeedback} primitives but it will probably
70%D have bad side effects. We fake them as primitives which is why they are
71%D defined as untraced.
72
73% \pdfextension % defined in lua
74% \pdffeedback  % idem
75% \pdfvariable  % idem
76% \pdfliteral   % idem
77% \pdfobj       % idem
78% \pdflastobj   % idem
79% \pdfrefobj    % idem
80
81\untraced\permanent\protected\def\pdfrestore  {\pdfextension restore}
82\untraced\permanent\protected\def\pdfsave     {\pdfextension save}
83\untraced\permanent\protected\def\pdfsetmatrix{\pdfextension setmatrix}
84
85\untraced\permanent\def\pdfxform              {\saveboxresource}
86\untraced\permanent\def\pdflastxform          {\lastsavedboxresourceindex}
87\untraced\permanent\def\pdfrefxform           {\useboxresource}
88
89%D This is also needed for tikz:
90
91\ifdefined\pdfsavepos\else
92    \untraced\permanent\def\pdfsavepos {\savepos }
93    \untraced\permanent\def\pdflastxpos{\lastxpos}
94    \untraced\permanent\def\pdflastypos{\lastypos}
95\fi
96
97%D Here are quick and dirty compression flippers, mostly used when testing something
98%D as one can best stick to the defaults that also adapt to specific standards.
99
100% level objectlevel
101
102\untraced\permanent\protected\def\nopdfcompression        {\clf_setpdfcompression\zerocount\zerocount}
103\untraced\permanent\protected\def\nopdfobjectcompression  {\clf_setpdfcompression\plusthree\zerocount}
104\untraced\permanent\protected\def\onlypdfobjectcompression{\clf_setpdfcompression\zerocount\plusthree}
105\untraced\permanent\protected\def\maximumpdfcompression   {\clf_setpdfcompression\plusnine \plusnine }
106\untraced\permanent\protected\def\normalpdfcompression    {\clf_setpdfcompression\plusthree\plusthree}
107
108%D PDF/X (maybe combine the two lua calls)
109
110\setupbackend
111  [xmpfile=]
112
113\appendtoks
114    \edef\p_file{\backendparameter{xmpfile}}%
115    \ifempty\p_file\else
116      \clf_setxmpfile{\p_file}%
117    \fi
118\to \everysetupbackend
119
120%D This will change:
121
122\appendtoks
123    \clf_setformat
124         format  {\backendparameter\c!format}%
125         level   {\backendparameter\c!level}%
126         option  {\backendparameter\c!option}%
127         profile {\backendparameter\c!profile}%
128         intent  {\backendparameter\c!intent}%
129         file    {\backendparameter\c!file}%
130    \relax
131\to \everysetupbackend
132
133%D These are the only official methods to add stuff to the resources. If more is
134%D needed for third party low level code, it can be added.
135
136% \pdfbackendsetcatalog       #1#2 % defined in lua
137% \pdfbackendsetinfo          #1#2 % idem
138% \pdfbackendsetname          #1#2 % idem
139%
140% \pdfbackendsetpageattribute #1#2 % idem
141% \pdfbackendsetpagesattribute#1#2 % idem
142% \pdfbackendsetpageresource  #1#2 % idem
143%
144% \pdfbackendsetextgstate     #1#2 % idem
145% \pdfbackendsetcolorspace    #1#2 % idem
146% \pdfbackendsetpattern       #1#2 % idem
147% \pdfbackendsetshade         #1#2 % idem
148%
149% \pdfbackendcurrentresources      %  idem, expandable
150% \pdfcolor                     #1 %  idem, expandable
151
152%D This is a temporary hack that will be removed, improved or somehow can become
153%D default.
154
155\permanent\def\TransparencyHack{\setupcolors[\c!pagecolormodel=\v!auto]}
156
157%D Just in case one needs this \unknown:
158%D
159%D \starttyping
160%D text \pdfbackendactualtext{Meier}{Müller} text
161%D \stoptyping
162
163\untraced\permanent\protected\def\pdfbackendactualtext#1#2% not interfaced
164  {\clf_startactualtext{#2}%
165   #1%
166   \clf_stopactualtext}
167
168\aliased\let\pdfactualtext\pdfbackendactualtext
169
170\untraced\permanent\protected\def\pdfbackendalternativetext#1#2% not interfaced
171  {\clf_startalternativetext{#2}%
172   #1%
173   \clf_stopalternativetext}
174
175\aliased\let\pdfalternativetext\pdfbackendalternativetext
176
177\permanent\protected\def\startPDFalternativetext{\clf_startalternativetext}
178\permanent\protected\def\stopPDFalternativetext {\clf_stopalternativetext}
179
180\protect \endinput
181