back-pdf.mkiv /size: 5608 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\writestatus{loading}{ConTeXt Backend Macros / PDF}
19
20\registerctxluafile{lpdf-ini}{optimize}
21\registerctxluafile{lpdf-nod}{}
22\registerctxluafile{lpdf-eng}{optimize}
23\registerctxluafile{lpdf-col}{}
24\registerctxluafile{lpdf-vfc}{}
25\registerctxluafile{lpdf-xmp}{}
26\registerctxluafile{lpdf-ano}{}
27\registerctxluafile{lpdf-res}{}
28\registerctxluafile{lpdf-mis}{}
29\registerctxluafile{lpdf-ren}{}
30\registerctxluafile{lpdf-grp}{}
31\registerctxluafile{lpdf-wid}{}
32\registerctxluafile{lpdf-fld}{}
33\registerctxluafile{lpdf-mov}{}
34\registerctxluafile{lpdf-u3d}{} % this will become a module
35\registerctxluafile{lpdf-swf}{} % this will become a module
36\registerctxluafile{lpdf-tag}{}
37\registerctxluafile{lpdf-fmt}{}
38\registerctxluafile{lpdf-pde}{}
39\registerctxluafile{lpdf-epa}{}
40\registerctxluafile{lpdf-fnt}{}
41
42\registerctxluafile{back-pdp}{}
43\registerctxluafile{back-pdf}{} % some code will move to lpdf-*
44
45\loadmarkfile{back-u3d} % this will become a module
46\loadmarkfile{back-swf} % this will become a module
47
48\unprotect
49
50%D We will minimize the number of calls to \PDF\ specific primitives and delegate
51%D all management and injection of code to the backend.
52%D
53%D Because we do a lot in \LUA\ and don't want interferences, we nil most of the
54%D \PDFTEX\ primitives. Of course one can always use the \type {\pdfvariable},
55%D \type {\pdfextension} and \type {\pdffeedback} primitives but it will probably
56%D have bad side effects.
57
58\unexpanded\def\pdfextension{\clf_pdfextension}
59           \def\pdffeedback {\clf_pdffeedback}
60
61%D For the moment we keep this for tikz but hopefully it will at some point use
62%D the proper ones. Consider them obsolete:
63
64\unexpanded\def\pdfliteral  {\clf_pdfliteral}
65\unexpanded\def\pdfobj      {\clf_pdfobj}%
66\unexpanded\def\pdflastobj  {\numexpr\clf_pdflastobj\relax}
67\unexpanded\def\pdfrefobj   {\clf_pdfrefobj }
68
69\unexpanded\def\pdfrestore  {\pdfextension restore}
70\unexpanded\def\pdfsave     {\pdfextension save}
71\unexpanded\def\pdfsetmatrix{\pdfextension setmatrix}
72
73           \let\pdfxform     \saveboxresource
74           \let\pdflastxform \lastsavedboxresourceindex
75           \let\pdfrefxform  \useboxresource
76
77%D Here are quick and dirty compression flippers, mostly used when testing something
78%D as one can best stick to the defaults that also adapt to specific standards.
79
80\unexpanded\def\nopdfcompression        {\clf_setpdfcompression\zerocount\zerocount}
81\unexpanded\def\onlypdfobjectcompression{\clf_setpdfcompression\zerocount\plusthree}
82\unexpanded\def\maximumpdfcompression   {\clf_setpdfcompression\plusnine \plusnine }
83\unexpanded\def\normalpdfcompression    {\clf_setpdfcompression\plusthree\plusthree}
84
85%D PDF/X (maybe combine the two lua calls)
86
87\setupbackend
88  [xmpfile=]
89
90\appendtoks
91    \edef\p_file{\backendparameter{xmpfile}}%
92    \ifx\empty\p_file\else
93      \clf_setxmpfile{\p_file}%
94    \fi
95\to \everysetupbackend
96
97%D This will change:
98
99\appendtoks
100    \clf_setformat
101         format  {\backendparameter\c!format}%
102         level   {\backendparameter\c!level}%
103         option  {\backendparameter\c!option}%
104         profile {\backendparameter\c!profile}%
105         intent  {\backendparameter\c!intent}%
106         file    {\backendparameter\c!file}%
107    \relax
108\to \everysetupbackend
109
110%D These are the only official methods to add stuff to the resources. If more is
111%D needed for third party low level code, it can be added.
112
113\unexpanded\def\pdfbackendsetcatalog       #1#2{\clf_lpdf_addtocatalog{#1}{#2}}
114\unexpanded\def\pdfbackendsetinfo          #1#2{\clf_lpdf_addtoinfo{#1}{#2}}
115\unexpanded\def\pdfbackendsetname          #1#2{\clf_lpdf_addtonames{#1}{#2}}
116
117\unexpanded\def\pdfbackendsetpageattribute #1#2{\clf_lpdf_addtopageattributes{#1}{#2}}
118\unexpanded\def\pdfbackendsetpagesattribute#1#2{\clf_lpdf_addtopagesattributes{#1}{#2}}
119\unexpanded\def\pdfbackendsetpageresource  #1#2{\clf_lpdf_addtopageresources{#1}{#2}}
120
121\unexpanded\def\pdfbackendsetextgstate     #1#2{\clf_lpdf_adddocumentextgstate{#1}{#2}}
122\unexpanded\def\pdfbackendsetcolorspace    #1#2{\clf_lpdf_adddocumentcolorspace{#1}{#2}}
123\unexpanded\def\pdfbackendsetpattern       #1#2{\clf_lpdf_adddocumentpattern{#1}{#2}}
124\unexpanded\def\pdfbackendsetshade         #1#2{\clf_lpdf_adddocumentshade{#1}{#2}}
125
126           \def\pdfbackendcurrentresources     {\clf_lpdf_collectedresources}
127           \def\pdfcolor                     #1{\clf_lpdf_color\numexpr\thecolorattribute{#1}\relax}
128
129%D This is a temporary hack mthat will be removed, improved or somehow can become
130%D default.
131
132\def\TransparencyHack{\setupcolors[\c!pagecolormodel=\v!auto]}
133
134%D Just in case one needs this \unknown:
135%D
136%D \starttyping
137%D text \pdfbackendactualtext{Meier}{Müller} text
138%D \stoptyping
139
140\unexpanded\def\pdfbackendactualtext#1#2% not interfaced
141  {\clf_startactualtext{#2}%
142   #1%
143   \clf_stopactualtext}
144
145\let\pdfactualtext\pdfbackendactualtext
146
147%D Bah, this is also needed for tikz:
148
149\ifdefined\pdfsavepos\else
150    \let\pdfsavepos \savepos
151    \let\pdflastxpos\lastxpos
152    \let\pdflastypos\lastypos
153\fi
154
155\protect \endinput
156