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